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
108
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
67k
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
2781f20cc59b853f6ec7a82b620e3a0f1f376ff2
28,342
cc
C++
service/auto/Spi.cc
lilinj2000/cata
a4f63913fc8e2b8015fa94c3baf51b3934d57637
[ "Apache-2.0" ]
null
null
null
service/auto/Spi.cc
lilinj2000/cata
a4f63913fc8e2b8015fa94c3baf51b3934d57637
[ "Apache-2.0" ]
null
null
null
service/auto/Spi.cc
lilinj2000/cata
a4f63913fc8e2b8015fa94c3baf51b3934d57637
[ "Apache-2.0" ]
1
2021-08-21T09:19:08.000Z
2021-08-21T09:19:08.000Z
void MDSpiImpl::OnFrontConnected() { SOIL_FUNC_TRACE; } void MDSpiImpl::OnFrontDisconnected( int nReason) { SOIL_FUNC_TRACE; SOIL_DEBUG_PRINT(nReason); } void MDSpiImpl::OnHeartBeatWarning( int nTimeLapse) { SOIL_FUNC_TRACE; SOIL_DEBUG_PRINT(nTimeLapse); } void MDSpiImpl::OnRspAuthenticate( CThostFtdcRspAuthenticateField *pRspAuthenticateField, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspAuthenticate, pRspAuthenticateField, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspUserLogin( CThostFtdcRspUserLoginField *pRspUserLogin, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; SOIL_DEBUG_IF_PRINT(pRspUserLogin); SOIL_DEBUG_IF_PRINT(pRspInfo); SOIL_DEBUG_PRINT(nRequestID); SOIL_DEBUG_PRINT(bIsLast); } void MDSpiImpl::OnRspUserLogout( CThostFtdcUserLogoutField *pUserLogout, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; SOIL_DEBUG_IF_PRINT(pUserLogout); SOIL_DEBUG_IF_PRINT(pRspInfo); SOIL_DEBUG_PRINT(nRequestID); SOIL_DEBUG_PRINT(bIsLast); } void MDSpiImpl::OnRspUserPasswordUpdate( CThostFtdcUserPasswordUpdateField *pUserPasswordUpdate, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspUserPasswordUpdate, pUserPasswordUpdate, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspTradingAccountPasswordUpdate( CThostFtdcTradingAccountPasswordUpdateField *pTradingAccountPasswordUpdate, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspTradingAccountPasswordUpdate, pTradingAccountPasswordUpdate, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspUserAuthMethod( CThostFtdcRspUserAuthMethodField *pRspUserAuthMethod, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspUserAuthMethod, pRspUserAuthMethod, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspGenUserCaptcha( CThostFtdcRspGenUserCaptchaField *pRspGenUserCaptcha, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspGenUserCaptcha, pRspGenUserCaptcha, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspGenUserText( CThostFtdcRspGenUserTextField *pRspGenUserText, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspGenUserText, pRspGenUserText, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspOrderInsert( CThostFtdcInputOrderField *pInputOrder, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspOrderInsert, pInputOrder, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspParkedOrderInsert( CThostFtdcParkedOrderField *pParkedOrder, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspParkedOrderInsert, pParkedOrder, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspParkedOrderAction( CThostFtdcParkedOrderActionField *pParkedOrderAction, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspParkedOrderAction, pParkedOrderAction, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspOrderAction( CThostFtdcInputOrderActionField *pInputOrderAction, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspOrderAction, pInputOrderAction, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQueryMaxOrderVolume( CThostFtdcQueryMaxOrderVolumeField *pQueryMaxOrderVolume, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQueryMaxOrderVolume, pQueryMaxOrderVolume, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspSettlementInfoConfirm( CThostFtdcSettlementInfoConfirmField *pSettlementInfoConfirm, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspSettlementInfoConfirm, pSettlementInfoConfirm, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspRemoveParkedOrder( CThostFtdcRemoveParkedOrderField *pRemoveParkedOrder, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspRemoveParkedOrder, pRemoveParkedOrder, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspRemoveParkedOrderAction( CThostFtdcRemoveParkedOrderActionField *pRemoveParkedOrderAction, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspRemoveParkedOrderAction, pRemoveParkedOrderAction, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspExecOrderInsert( CThostFtdcInputExecOrderField *pInputExecOrder, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspExecOrderInsert, pInputExecOrder, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspExecOrderAction( CThostFtdcInputExecOrderActionField *pInputExecOrderAction, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspExecOrderAction, pInputExecOrderAction, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspForQuoteInsert( CThostFtdcInputForQuoteField *pInputForQuote, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspForQuoteInsert, pInputForQuote, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQuoteInsert( CThostFtdcInputQuoteField *pInputQuote, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQuoteInsert, pInputQuote, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQuoteAction( CThostFtdcInputQuoteActionField *pInputQuoteAction, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQuoteAction, pInputQuoteAction, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspBatchOrderAction( CThostFtdcInputBatchOrderActionField *pInputBatchOrderAction, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspBatchOrderAction, pInputBatchOrderAction, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspOptionSelfCloseInsert( CThostFtdcInputOptionSelfCloseField *pInputOptionSelfClose, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspOptionSelfCloseInsert, pInputOptionSelfClose, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspOptionSelfCloseAction( CThostFtdcInputOptionSelfCloseActionField *pInputOptionSelfCloseAction, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspOptionSelfCloseAction, pInputOptionSelfCloseAction, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspCombActionInsert( CThostFtdcInputCombActionField *pInputCombAction, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspCombActionInsert, pInputCombAction, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryOrder( CThostFtdcOrderField *pOrder, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryOrder, pOrder, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryTrade( CThostFtdcTradeField *pTrade, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryTrade, pTrade, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryInvestorPosition( CThostFtdcInvestorPositionField *pInvestorPosition, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryInvestorPosition, pInvestorPosition, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryTradingAccount( CThostFtdcTradingAccountField *pTradingAccount, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryTradingAccount, pTradingAccount, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryInvestor( CThostFtdcInvestorField *pInvestor, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryInvestor, pInvestor, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryTradingCode( CThostFtdcTradingCodeField *pTradingCode, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryTradingCode, pTradingCode, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryInstrumentMarginRate( CThostFtdcInstrumentMarginRateField *pInstrumentMarginRate, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryInstrumentMarginRate, pInstrumentMarginRate, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryInstrumentCommissionRate( CThostFtdcInstrumentCommissionRateField *pInstrumentCommissionRate, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryInstrumentCommissionRate, pInstrumentCommissionRate, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryExchange( CThostFtdcExchangeField *pExchange, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryExchange, pExchange, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryProduct( CThostFtdcProductField *pProduct, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryProduct, pProduct, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryInstrument( CThostFtdcInstrumentField *pInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryInstrument, pInstrument, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryDepthMarketData( CThostFtdcDepthMarketDataField *pDepthMarketData, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryDepthMarketData, pDepthMarketData, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQrySettlementInfo( CThostFtdcSettlementInfoField *pSettlementInfo, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQrySettlementInfo, pSettlementInfo, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryTransferBank( CThostFtdcTransferBankField *pTransferBank, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryTransferBank, pTransferBank, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryInvestorPositionDetail( CThostFtdcInvestorPositionDetailField *pInvestorPositionDetail, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryInvestorPositionDetail, pInvestorPositionDetail, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryNotice( CThostFtdcNoticeField *pNotice, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryNotice, pNotice, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQrySettlementInfoConfirm( CThostFtdcSettlementInfoConfirmField *pSettlementInfoConfirm, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQrySettlementInfoConfirm, pSettlementInfoConfirm, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryInvestorPositionCombineDetail( CThostFtdcInvestorPositionCombineDetailField *pInvestorPositionCombineDetail, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryInvestorPositionCombineDetail, pInvestorPositionCombineDetail, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryCFMMCTradingAccountKey( CThostFtdcCFMMCTradingAccountKeyField *pCFMMCTradingAccountKey, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryCFMMCTradingAccountKey, pCFMMCTradingAccountKey, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryEWarrantOffset( CThostFtdcEWarrantOffsetField *pEWarrantOffset, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryEWarrantOffset, pEWarrantOffset, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryInvestorProductGroupMargin( CThostFtdcInvestorProductGroupMarginField *pInvestorProductGroupMargin, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryInvestorProductGroupMargin, pInvestorProductGroupMargin, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryExchangeMarginRate( CThostFtdcExchangeMarginRateField *pExchangeMarginRate, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryExchangeMarginRate, pExchangeMarginRate, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryExchangeMarginRateAdjust( CThostFtdcExchangeMarginRateAdjustField *pExchangeMarginRateAdjust, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryExchangeMarginRateAdjust, pExchangeMarginRateAdjust, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryExchangeRate( CThostFtdcExchangeRateField *pExchangeRate, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryExchangeRate, pExchangeRate, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQrySecAgentACIDMap( CThostFtdcSecAgentACIDMapField *pSecAgentACIDMap, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQrySecAgentACIDMap, pSecAgentACIDMap, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryProductExchRate( CThostFtdcProductExchRateField *pProductExchRate, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryProductExchRate, pProductExchRate, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryProductGroup( CThostFtdcProductGroupField *pProductGroup, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryProductGroup, pProductGroup, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryMMInstrumentCommissionRate( CThostFtdcMMInstrumentCommissionRateField *pMMInstrumentCommissionRate, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryMMInstrumentCommissionRate, pMMInstrumentCommissionRate, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryMMOptionInstrCommRate( CThostFtdcMMOptionInstrCommRateField *pMMOptionInstrCommRate, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryMMOptionInstrCommRate, pMMOptionInstrCommRate, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryInstrumentOrderCommRate( CThostFtdcInstrumentOrderCommRateField *pInstrumentOrderCommRate, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryInstrumentOrderCommRate, pInstrumentOrderCommRate, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQrySecAgentTradingAccount( CThostFtdcTradingAccountField *pTradingAccount, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQrySecAgentTradingAccount, pTradingAccount, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQrySecAgentCheckMode( CThostFtdcSecAgentCheckModeField *pSecAgentCheckMode, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQrySecAgentCheckMode, pSecAgentCheckMode, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQrySecAgentTradeInfo( CThostFtdcSecAgentTradeInfoField *pSecAgentTradeInfo, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQrySecAgentTradeInfo, pSecAgentTradeInfo, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryOptionInstrTradeCost( CThostFtdcOptionInstrTradeCostField *pOptionInstrTradeCost, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryOptionInstrTradeCost, pOptionInstrTradeCost, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryOptionInstrCommRate( CThostFtdcOptionInstrCommRateField *pOptionInstrCommRate, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryOptionInstrCommRate, pOptionInstrCommRate, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryExecOrder( CThostFtdcExecOrderField *pExecOrder, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryExecOrder, pExecOrder, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryForQuote( CThostFtdcForQuoteField *pForQuote, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryForQuote, pForQuote, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryQuote( CThostFtdcQuoteField *pQuote, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryQuote, pQuote, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryOptionSelfClose( CThostFtdcOptionSelfCloseField *pOptionSelfClose, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryOptionSelfClose, pOptionSelfClose, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryInvestUnit( CThostFtdcInvestUnitField *pInvestUnit, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryInvestUnit, pInvestUnit, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryCombInstrumentGuard( CThostFtdcCombInstrumentGuardField *pCombInstrumentGuard, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryCombInstrumentGuard, pCombInstrumentGuard, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryCombAction( CThostFtdcCombActionField *pCombAction, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryCombAction, pCombAction, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryTransferSerial( CThostFtdcTransferSerialField *pTransferSerial, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryTransferSerial, pTransferSerial, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryAccountregister( CThostFtdcAccountregisterField *pAccountregister, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryAccountregister, pAccountregister, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspError( CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_ERROR_CALLBACK( onRspError, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRtnOrder( CThostFtdcOrderField *pOrder) { SOIL_FUNC_TRACE; CATA_ON_RTN_CALLBACK( onRtnOrder, pOrder); } void MDSpiImpl::OnRtnTrade( CThostFtdcTradeField *pTrade) { SOIL_FUNC_TRACE; CATA_ON_RTN_CALLBACK( onRtnTrade, pTrade); } void MDSpiImpl::OnRtnInstrumentStatus( CThostFtdcInstrumentStatusField *pInstrumentStatus) { SOIL_FUNC_TRACE; CATA_ON_RTN_CALLBACK( onRtnInstrumentStatus, pInstrumentStatus); } void MDSpiImpl::OnRtnBulletin( CThostFtdcBulletinField *pBulletin) { SOIL_FUNC_TRACE; CATA_ON_RTN_CALLBACK( onRtnBulletin, pBulletin); } void MDSpiImpl::OnRtnTradingNotice( CThostFtdcTradingNoticeInfoField *pTradingNoticeInfo) { SOIL_FUNC_TRACE; CATA_ON_RTN_CALLBACK( onRtnTradingNotice, pTradingNoticeInfo); } void MDSpiImpl::OnRtnErrorConditionalOrder( CThostFtdcErrorConditionalOrderField *pErrorConditionalOrder) { SOIL_FUNC_TRACE; CATA_ON_RTN_CALLBACK( onRtnErrorConditionalOrder, pErrorConditionalOrder); } void MDSpiImpl::OnRtnExecOrder( CThostFtdcExecOrderField *pExecOrder) { SOIL_FUNC_TRACE; CATA_ON_RTN_CALLBACK( onRtnExecOrder, pExecOrder); } void MDSpiImpl::OnRtnQuote( CThostFtdcQuoteField *pQuote) { SOIL_FUNC_TRACE; CATA_ON_RTN_CALLBACK( onRtnQuote, pQuote); } void MDSpiImpl::OnRtnForQuoteRsp( CThostFtdcForQuoteRspField *pForQuoteRsp) { SOIL_FUNC_TRACE; CATA_ON_RTN_CALLBACK( onRtnForQuoteRsp, pForQuoteRsp); } void MDSpiImpl::OnRtnCFMMCTradingAccountToken( CThostFtdcCFMMCTradingAccountTokenField *pCFMMCTradingAccountToken) { SOIL_FUNC_TRACE; CATA_ON_RTN_CALLBACK( onRtnCFMMCTradingAccountToken, pCFMMCTradingAccountToken); } void MDSpiImpl::OnRtnOptionSelfClose( CThostFtdcOptionSelfCloseField *pOptionSelfClose) { SOIL_FUNC_TRACE; CATA_ON_RTN_CALLBACK( onRtnOptionSelfClose, pOptionSelfClose); } void MDSpiImpl::OnRtnCombAction( CThostFtdcCombActionField *pCombAction) { SOIL_FUNC_TRACE; CATA_ON_RTN_CALLBACK( onRtnCombAction, pCombAction); } void MDSpiImpl::OnRspQryContractBank( CThostFtdcContractBankField *pContractBank, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryContractBank, pContractBank, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryParkedOrder( CThostFtdcParkedOrderField *pParkedOrder, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryParkedOrder, pParkedOrder, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryParkedOrderAction( CThostFtdcParkedOrderActionField *pParkedOrderAction, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryParkedOrderAction, pParkedOrderAction, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryTradingNotice( CThostFtdcTradingNoticeField *pTradingNotice, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryTradingNotice, pTradingNotice, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryBrokerTradingParams( CThostFtdcBrokerTradingParamsField *pBrokerTradingParams, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryBrokerTradingParams, pBrokerTradingParams, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryBrokerTradingAlgos( CThostFtdcBrokerTradingAlgosField *pBrokerTradingAlgos, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryBrokerTradingAlgos, pBrokerTradingAlgos, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQueryCFMMCTradingAccountToken( CThostFtdcQueryCFMMCTradingAccountTokenField *pQueryCFMMCTradingAccountToken, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQueryCFMMCTradingAccountToken, pQueryCFMMCTradingAccountToken, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRtnFromBankToFutureByBank( CThostFtdcRspTransferField *pRspTransfer) { SOIL_FUNC_TRACE; CATA_ON_RTN_CALLBACK( onRtnFromBankToFutureByBank, pRspTransfer); } void MDSpiImpl::OnRtnFromFutureToBankByBank( CThostFtdcRspTransferField *pRspTransfer) { SOIL_FUNC_TRACE; CATA_ON_RTN_CALLBACK( onRtnFromFutureToBankByBank, pRspTransfer); } void MDSpiImpl::OnRtnRepealFromBankToFutureByBank( CThostFtdcRspRepealField *pRspRepeal) { SOIL_FUNC_TRACE; CATA_ON_RTN_CALLBACK( onRtnRepealFromBankToFutureByBank, pRspRepeal); } void MDSpiImpl::OnRtnRepealFromFutureToBankByBank( CThostFtdcRspRepealField *pRspRepeal) { SOIL_FUNC_TRACE; CATA_ON_RTN_CALLBACK( onRtnRepealFromFutureToBankByBank, pRspRepeal); } void MDSpiImpl::OnRtnFromBankToFutureByFuture( CThostFtdcRspTransferField *pRspTransfer) { SOIL_FUNC_TRACE; CATA_ON_RTN_CALLBACK( onRtnFromBankToFutureByFuture, pRspTransfer); } void MDSpiImpl::OnRtnFromFutureToBankByFuture( CThostFtdcRspTransferField *pRspTransfer) { SOIL_FUNC_TRACE; CATA_ON_RTN_CALLBACK( onRtnFromFutureToBankByFuture, pRspTransfer); } void MDSpiImpl::OnRtnRepealFromBankToFutureByFutureManual( CThostFtdcRspRepealField *pRspRepeal) { SOIL_FUNC_TRACE; CATA_ON_RTN_CALLBACK( onRtnRepealFromBankToFutureByFutureManual, pRspRepeal); } void MDSpiImpl::OnRtnRepealFromFutureToBankByFutureManual( CThostFtdcRspRepealField *pRspRepeal) { SOIL_FUNC_TRACE; CATA_ON_RTN_CALLBACK( onRtnRepealFromFutureToBankByFutureManual, pRspRepeal); } void MDSpiImpl::OnRtnQueryBankBalanceByFuture( CThostFtdcNotifyQueryAccountField *pNotifyQueryAccount) { SOIL_FUNC_TRACE; CATA_ON_RTN_CALLBACK( onRtnQueryBankBalanceByFuture, pNotifyQueryAccount); } void MDSpiImpl::OnRtnRepealFromBankToFutureByFuture( CThostFtdcRspRepealField *pRspRepeal) { SOIL_FUNC_TRACE; CATA_ON_RTN_CALLBACK( onRtnRepealFromBankToFutureByFuture, pRspRepeal); } void MDSpiImpl::OnRtnRepealFromFutureToBankByFuture( CThostFtdcRspRepealField *pRspRepeal) { SOIL_FUNC_TRACE; CATA_ON_RTN_CALLBACK( onRtnRepealFromFutureToBankByFuture, pRspRepeal); } void MDSpiImpl::OnRspFromBankToFutureByFuture( CThostFtdcReqTransferField *pReqTransfer, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspFromBankToFutureByFuture, pReqTransfer, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspFromFutureToBankByFuture( CThostFtdcReqTransferField *pReqTransfer, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspFromFutureToBankByFuture, pReqTransfer, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQueryBankAccountMoneyByFuture( CThostFtdcReqQueryAccountField *pReqQueryAccount, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQueryBankAccountMoneyByFuture, pReqQueryAccount, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRtnOpenAccountByBank( CThostFtdcOpenAccountField *pOpenAccount) { SOIL_FUNC_TRACE; CATA_ON_RTN_CALLBACK( onRtnOpenAccountByBank, pOpenAccount); } void MDSpiImpl::OnRtnCancelAccountByBank( CThostFtdcCancelAccountField *pCancelAccount) { SOIL_FUNC_TRACE; CATA_ON_RTN_CALLBACK( onRtnCancelAccountByBank, pCancelAccount); } void MDSpiImpl::OnRtnChangeAccountByBank( CThostFtdcChangeAccountField *pChangeAccount) { SOIL_FUNC_TRACE; CATA_ON_RTN_CALLBACK( onRtnChangeAccountByBank, pChangeAccount); }
19.586731
78
0.811975
lilinj2000
27836637b1c8d8e2ece8d9fcebc6989f35efa4f0
34,419
cpp
C++
src/widgetopengldraw.cpp
jonpas/FERI-OpenGL
6cdf079dc2ed27ead53774ca5fdeb518a83fada9
[ "MIT" ]
null
null
null
src/widgetopengldraw.cpp
jonpas/FERI-OpenGL
6cdf079dc2ed27ead53774ca5fdeb518a83fada9
[ "MIT" ]
null
null
null
src/widgetopengldraw.cpp
jonpas/FERI-OpenGL
6cdf079dc2ed27ead53774ca5fdeb518a83fada9
[ "MIT" ]
null
null
null
#include "widgetopengldraw.h" WidgetOpenGLDraw::WidgetOpenGLDraw(QWidget *parent) : QOpenGLWidget(parent) { setMouseTracking(true); updateCameraFront(); std::random_device rd; rng = std::mt19937(rd()); } WidgetOpenGLDraw::~WidgetOpenGLDraw() { // Clean state gl.glDeleteProgram(programShaderID); gl.glDeleteShader(vertexShaderID); gl.glDeleteShader(fragmentShaderID); for (const auto &object : objects) { gl.glDeleteVertexArrays(1, &object.VAO); gl.glDeleteBuffers(1, &object.VBO); gl.glDeleteBuffers(1, &object.IBO); gl.glDeleteBuffers(2, object.TBO); } } void WidgetOpenGLDraw::printProgramInfoLog(GLuint obj) { int infologLength = 0; gl.glGetProgramiv(obj, GL_INFO_LOG_LENGTH, &infologLength); if (infologLength > 0) { std::unique_ptr<char[]> infoLog(new char[infologLength]); int charsWritten = 0; gl.glGetProgramInfoLog(obj, infologLength, &charsWritten, infoLog.get()); std::cerr << infoLog.get() << std::endl; } } void WidgetOpenGLDraw::printShaderInfoLog(GLuint obj) { int infologLength = 0; gl.glGetShaderiv(obj, GL_INFO_LOG_LENGTH, &infologLength); if (infologLength > 0) { std::unique_ptr<char[]> infoLog(new char[infologLength]); int charsWritten = 0; gl.glGetShaderInfoLog(obj, infologLength, &charsWritten, infoLog.get()); std::cerr << infoLog.get() << std::endl; } } const GLchar* WidgetOpenGLDraw::vertexShaderSource = R"glsl( #version 330 core const uint MAPPING_TYPE_SIMPLE = uint(0); const uint MAPPING_TYPE_PLANAR = uint(1); const uint MAPPING_TYPE_CYLINDRICAL = uint(2); const uint MAPPING_TYPE_SPHERICAL = uint(3); const uint MAPPING_AXIS_X = uint(0); const uint MAPPING_AXIS_Y = uint(1); const uint MAPPING_AXIS_Z = uint(2); layout(location=0) in vec3 position; layout(location=1) in vec2 uv; layout(location=2) in vec3 normal; uniform mat4 P; uniform mat4 V; uniform mat4 M; uniform uint TextureMappingType; uniform uint TextureMappingAxis; uniform vec3 BoundingBoxMin; uniform vec3 BoundingBoxMax; out vec2 TextureUV; out vec3 VertexPosition; out vec3 NormalInterpolated; vec2 textureMapping(vec2 uv) { vec3 objectSize = BoundingBoxMax - BoundingBoxMin; // Distance from one edge of bounding box to another vec3 objectCenter = BoundingBoxMin + objectSize / 2; // Bounding box center vec3 objectCenterToVertex = position - objectCenter; // Vector from vertex to bounding box center // GLSL atan(y, x): x and y parameters inversed! if (TextureMappingType == MAPPING_TYPE_SIMPLE) { if (TextureMappingAxis == MAPPING_AXIS_Y) { uv = vec2(uv.y, uv.x); } } else if (TextureMappingType == MAPPING_TYPE_PLANAR) { if (TextureMappingAxis == MAPPING_AXIS_X) { uv.x = (position.z - BoundingBoxMin.z) / objectSize.z; uv.y = (position.y - BoundingBoxMin.y) / objectSize.y; } else if (TextureMappingAxis == MAPPING_AXIS_Y) { uv.x = (position.x - BoundingBoxMin.x) / objectSize.x; uv.y = (position.z - BoundingBoxMin.z) / objectSize.z; } else if (TextureMappingAxis == MAPPING_AXIS_Z) { uv.x = (position.x - BoundingBoxMin.x) / objectSize.x; uv.y = (position.y - BoundingBoxMin.y) / objectSize.y; } } else if (TextureMappingType == MAPPING_TYPE_CYLINDRICAL) { float angle = 0.0f; if (TextureMappingAxis == MAPPING_AXIS_X) { angle = atan(objectCenterToVertex.y, objectCenterToVertex.z) + 180.0f; uv.y = objectCenterToVertex.x / objectSize.x + 0.5f; } else if (TextureMappingAxis == MAPPING_AXIS_Y) { angle = atan(objectCenterToVertex.z, objectCenterToVertex.x) + 180.0f; uv.y = objectCenterToVertex.y / objectSize.y + 0.5f; } else if (TextureMappingAxis == MAPPING_AXIS_Z) { angle = atan(objectCenterToVertex.y, objectCenterToVertex.x) + 180.0f; uv.y = objectCenterToVertex.z / objectSize.z + 0.5f; } uv.x = angle / 360.0f; } else if (TextureMappingType == MAPPING_TYPE_SPHERICAL) { float angle1 = 0.0f; float angle2 = 0.0f; if (TextureMappingAxis == MAPPING_AXIS_X) { angle1 = degrees(atan(objectCenterToVertex.y, objectCenterToVertex.z)) + 180.0f; angle2 = degrees(asin(objectCenterToVertex.x / length(objectCenterToVertex))); } else if (TextureMappingAxis == MAPPING_AXIS_Y) { angle1 = degrees(atan(objectCenterToVertex.z, objectCenterToVertex.x)) + 180.0f; angle2 = degrees(asin(objectCenterToVertex.y / length(objectCenterToVertex))); } else if (TextureMappingAxis == MAPPING_AXIS_Z) { angle1 = degrees(atan(objectCenterToVertex.y, objectCenterToVertex.x)) + 180.0f; angle2 = degrees(asin(objectCenterToVertex.z / length(objectCenterToVertex))); } uv.x = angle1 / 360.0f; uv.y = angle2 / 180.0f + 0.5f; } return uv; } void main() { // Calculate final render matrix (PVM) gl_Position = P * V * M * vec4(position, 1.0); // Map texture by given type and axis TextureUV = textureMapping(uv); // Calculate vertex position in global space vec4 vertPos4 = M * vec4(position, 1.0); VertexPosition = vec3(vertPos4) / vertPos4.w; // Calculate normal interpolated around vertices mat4 normalMatrix = transpose(inverse(M)); NormalInterpolated = vec3(normalMatrix * vec4(normal, 0.0)); } )glsl"; const GLchar* WidgetOpenGLDraw::fragmentShaderSource = R"glsl( #version 330 core // Mesh uniform sampler2D Texture; uniform sampler2D BumpMap; // Light uniform vec3 LightPos; uniform float LightPower; uniform vec3 LightColor; // Material uniform vec3 AmbientColor; uniform vec3 DiffuseColor; uniform vec3 SpecularColor; uniform float SpecularPower; // Shininess factor in vec2 TextureUV; in vec3 VertexPosition; in vec3 NormalInterpolated; out vec4 outColor; const float screenGamma = 2.2; // Assume the monitor is calibrated to the sRGB color space // Bump mapping vec3 bumpMappingFromHeight(vec3 normal, float height) { float bumpU = dFdx(height); float bumpV = dFdy(height); vec3 sU = dFdx(VertexPosition); vec3 sV = dFdy(VertexPosition); vec3 d = bumpU * normalize(cross(normal, sV)) + bumpV * normalize(cross(sU, normal)); return normalize(normal + d); } // Blinn-Phon shading model, gamma corrected vec3 shading(vec3 normal) { vec3 lightDir = LightPos - VertexPosition; float distance = length(lightDir); distance = distance * distance; lightDir = normalize(lightDir); float lambertian = max(dot(lightDir, normal), 0.0); float specular = 0.0; if (lambertian > 0.0) { vec3 viewDir = normalize(-VertexPosition); // Blinn-Phong vec3 halfDir = normalize(lightDir + viewDir); float specAngle = max(dot(halfDir, normal), 0.0); specular = pow(specAngle, SpecularPower); } vec3 colorLinear = AmbientColor + DiffuseColor * lambertian * LightColor * LightPower / distance + SpecularColor * specular * LightColor * LightPower / distance; // Apply gamma correction (assume AmbientColor, DiffuseColor and SpecularColor // have been linearized, i.e. have no gamma correction in them) return pow(colorLinear, vec3(1.0 / screenGamma)); } void main() { // Apply bump mapping float height = length(texture2D(BumpMap, TextureUV.st).xyz); vec3 normal = bumpMappingFromHeight(NormalInterpolated, height); // Apply lighting/shading/reflection vec3 colorGammaCorrected = shading(normal); // Apply texture and use the gamma corrected color in the fragment outColor = texture(Texture, TextureUV) * vec4(colorGammaCorrected, 1.0); } )glsl"; void WidgetOpenGLDraw::compileShaders() { programShaderID = gl.glCreateProgram(); // Create and compile the vertex shader vertexShaderID = gl.glCreateShader(GL_VERTEX_SHADER); std::cout << vertexShaderSource; gl.glShaderSource(vertexShaderID, 1, &vertexShaderSource, nullptr); gl.glCompileShader(vertexShaderID); gl.glAttachShader(programShaderID, vertexShaderID); // Create and compile the fragment shader fragmentShaderID = gl.glCreateShader(GL_FRAGMENT_SHADER); std::cout << fragmentShaderSource; gl.glShaderSource(fragmentShaderID, 1, &fragmentShaderSource, nullptr); gl.glCompileShader(fragmentShaderID); gl.glAttachShader(programShaderID, fragmentShaderID); // Link and use created shader program gl.glLinkProgram(programShaderID); gl.glUseProgram(programShaderID); // Print compiled shaders and program printShaderInfoLog(vertexShaderID); printShaderInfoLog(fragmentShaderID); printProgramInfoLog(programShaderID); } void WidgetOpenGLDraw::initializeGL() { // Load OpenGL functions std::cout << "OpenGL context version: " << context()->format().majorVersion() << "." << context()->format().minorVersion() << std::endl; if (!gl.initializeOpenGLFunctions()) { std::cerr << "Required openGL not supported" << std::endl; QApplication::exit(1); } std::cout << gl.glGetString(GL_VENDOR) << std::endl; std::cout << gl.glGetString(GL_VERSION) << std::endl; std::cout << gl.glGetString(GL_RENDERER) << std::endl; compileShaders(); // In case we drive more overlapping triangles, we want front to cover the ones in the back glEnable(GL_DEPTH_TEST); // Draw only one side of triangles glEnable(GL_CULL_FACE); // Define data (test objects) light = { "Light", {0.0f, 2.0f, 0.0f}, 40.0f }; objects = { { "Ground", { // Lighting will only work from top (ground doesn't go upside down usually) {glm::vec3(-5.0f, 0.0f, 5.0f), glm::vec2(0.0f, 1.0f), glm::vec3(0.0f, 1.0f, 0.0f)}, {glm::vec3(5.0f, 0.0f, 5.0f), glm::vec2(0.0f, 0.0f), glm::vec3(0.0f, 1.0f, 0.0f)}, {glm::vec3(5.0f, 0.0f, -5.0f), glm::vec2(1.0f, 0.0f), glm::vec3(0.0f, 1.0f, 0.0f)}, {glm::vec3(-5.0f, 0.0f, -5.0f), glm::vec2(1.0f, 1.0f), glm::vec3(0.0f, 1.0f, 0.0f)}, }, {0, 1, 2, 2, 3, 0} } }; applyTextureFromFile("../test/textures/bricks.jpg", 0, 0, &objects.back(), true); applyBumpMapFromFile("../test/bumpMaps/bricks.jpg", &objects.back(), true); objects.push_back(makePyramid(3, "Pyramid")); objects.back().translation.x = -5.0f; objects.back().translation.z = -5.0f; applyBumpMapFromFile("../test/bumpMaps/leather.jpg", &objects.back(), true); objects.push_back(makeCube("Cube")); objects.back().translation.y += 2.0f; objects.back().translation.z += 5.0f; QImage cubeTex(512, 512, QImage::Format_RGB32); cubeTex.fill(Qt::red); objects.back().textureImage = cubeTex; applyBumpMapFromFile("../test/bumpMaps/dots.jpg", &objects.back(), true); QStringList paths = {"../test/models/icoSphere.obj"}; loadModelsFromFile(paths, true); objects.back().name = "IcoSphere"; objects.back().translation.x = -1.0f; applyTextureFromFile("../test/textures/steelMesh.jpg", 0, 0, &objects.back(), true); applyBumpMapFromFile("../test/bumpMaps/metalScales.jpg", &objects.back(), true); // Connect object selection ComboBox and fill it QObject::connect(objectSelection, SIGNAL(currentIndexChanged(int)), this, SLOT(selectObject(int))); // Add light to object selection dropdown and make it first selected object (same as ComboBox) objectSelection->addItem(light.name); selectedObject = &light; // Buffer data to GPU for (auto &object : objects) { generateObjectBuffers(object); loadObjectTexture(object); loadObjectBumpMap(object); } // Set background color gl.glClearColor(0.2f, 0.2f, 0.2f, 1); const unsigned int err = gl.glGetError(); if (err != 0) { std::cerr << "OpenGL init error: " << err << std::endl; } } void WidgetOpenGLDraw::generateObjectBuffers(MeshObject &object) { // Create Vertex Array Object, carrying properties related with buffer (eg. state of glEnableVertexAttribArray etc.) gl.glGenVertexArrays(1, &object.VAO); gl.glBindVertexArray(object.VAO); // Create and bind Vertex Buffer and load vertices into it gl.glGenBuffers(1, &object.VBO); gl.glBindBuffer(GL_ARRAY_BUFFER, object.VBO); gl.glBufferData(GL_ARRAY_BUFFER, static_cast<GLsizeiptr>(object.vertices.size() * sizeof(Vertex)), &object.vertices.front(), GL_STATIC_DRAW); // Create and bind Index Buffer and load vertex indices into it gl.glGenBuffers(1, &object.IBO); gl.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, object.IBO); gl.glBufferData(GL_ELEMENT_ARRAY_BUFFER, static_cast<GLsizeiptr>(object.indices.size() * sizeof(GLuint)), &object.indices.front(), GL_STATIC_DRAW); // Setup vertex attributes (specify layout of vertex data) gl.glEnableVertexAttribArray(0); // We use: layout(location=0) and vec3 position; gl.glEnableVertexAttribArray(1); // We use: layout(location=1) and vec2 uv; gl.glEnableVertexAttribArray(2); // We use: layout(location=2) and vec3 normal; gl.glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast<void *>(offsetof(Vertex, position))); gl.glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast<void *>(offsetof(Vertex, uv))); gl.glVertexAttribPointer(2, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast<void *>(offsetof(Vertex, normal))); // Create Texture Buffer gl.glGenTextures(2, object.TBO); #ifdef QT_DEBUG // Unbind to avoid accidental modification gl.glBindVertexArray(0); // VAO must be first! gl.glBindBuffer(GL_ARRAY_BUFFER, 0); gl.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); #endif // Add to object selection dropdown objectSelection->addItem(object.name); } void WidgetOpenGLDraw::loadObjectTexture(MeshObject &object) { if (object.textureImage.isNull()) { std::cerr << "Loading object texture failed! No texture image loaded for object! [" << object.name.toStdString() << "]" << std::endl; return; } // Bind Texture Buffer and load texture into it gl.glBindTexture(GL_TEXTURE_2D, object.TBO[0]); gl.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, object.textureImage.width(), object.textureImage.height(), 0, GL_BGRA, GL_UNSIGNED_BYTE, object.textureImage.bits()); gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); // Use linear filtering for upscaled textures gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); // Use nearest neighbour filtering for downscaled textures #ifdef QT_DEBUG // Unbind to avoid accidental modification gl.glBindTexture(GL_TEXTURE_2D, 0); #endif // Calculate bounding box object.boundingBoxMin = {INFINITY, INFINITY, INFINITY}; object.boundingBoxMax = {-INFINITY, -INFINITY, -INFINITY}; for (auto &vertex : object.vertices) { object.boundingBoxMin = {std::min(vertex.position.x, object.boundingBoxMin.x), std::min(vertex.position.y, object.boundingBoxMin.y), std::min(vertex.position.z, object.boundingBoxMin.z)}; object.boundingBoxMax = {std::max(vertex.position.x, object.boundingBoxMax.x), std::max(vertex.position.y, object.boundingBoxMax.y), std::max(vertex.position.z, object.boundingBoxMax.z)}; } } void WidgetOpenGLDraw::loadObjectBumpMap(MeshObject &object) { if (object.bumpMapImage.isNull()) { std::cerr << "Loading object bump map failed! No bump map image loaded for object! [" << object.name.toStdString() << "]" << std::endl; return; } // Bind Texture Buffer and load bump map into it gl.glBindTexture(GL_TEXTURE_2D, object.TBO[1]); gl.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, object.bumpMapImage.width(), object.bumpMapImage.height(), 0, GL_BGRA, GL_UNSIGNED_BYTE, object.bumpMapImage.bits()); gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); #ifdef QT_DEBUG // Unbind to avoid accidental modification gl.glBindTexture(GL_TEXTURE_2D, 0); #endif } void WidgetOpenGLDraw::resizeGL(int w, int h) { gl.glViewport(0, 0, w, h); } void WidgetOpenGLDraw::paintGL() { // Clean color and depth buffer (clean frame start) gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Projection matrix glm::mat4 P; if (projectionOrtho) P = glm::ortho(-10.0f, 10.0f, -10.0f, 10.0f, -1000.0f, 1000.0f); else P = glm::perspective(glm::radians(70.0f), float(width()) / height(), 0.01f, 1000.0f); // View matrix (camera position, direction ...) glm::mat4 V = glm::lookAt(cameraPos, cameraPos + cameraFront, cameraUp); // Object for (const auto &object : objects) { // Bind textures to texture units if (!object.textureImage.isNull()) { gl.glActiveTexture(GL_TEXTURE0); gl.glBindTexture(GL_TEXTURE_2D, object.TBO[0]); // Texture } if (!object.bumpMapImage.isNull()) { gl.glActiveTexture(GL_TEXTURE1); gl.glBindTexture(GL_TEXTURE_2D, object.TBO[1]); // Bump Map } gl.glBindVertexArray(object.VAO); // Model matrix (object movement) glm::mat4 M = glm::mat4(1); M = glm::translate(M, object.translation); M = glm::rotate(M, object.rotation.x, glm::vec3(1, 0, 0)); M = glm::rotate(M, object.rotation.y, glm::vec3(0, 0, 1)); M = glm::rotate(M, object.rotation.z, glm::vec3(0, 1, 0)); M = glm::scale(M, object.scale); // Uniforms gl.glUniformMatrix4fv(gl.glGetUniformLocation(programShaderID, "P"), 1, GL_FALSE, glm::value_ptr(P)); gl.glUniformMatrix4fv(gl.glGetUniformLocation(programShaderID, "V"), 1, GL_FALSE, glm::value_ptr(V)); gl.glUniformMatrix4fv(gl.glGetUniformLocation(programShaderID, "M"), 1, GL_FALSE, glm::value_ptr(M)); gl.glUniform1i(gl.glGetUniformLocation(programShaderID, "Texture"), 0); gl.glUniform1i(gl.glGetUniformLocation(programShaderID, "BumpMap"), 1); gl.glUniform3fv(gl.glGetUniformLocation(programShaderID, "LightPos"), 1, glm::value_ptr(light.translation)); gl.glUniform1f(gl.glGetUniformLocation(programShaderID, "LightPower"), light.scale.x); gl.glUniform3fv(gl.glGetUniformLocation(programShaderID, "LightColor"), 1, glm::value_ptr(light.color)); gl.glUniform3fv(gl.glGetUniformLocation(programShaderID, "AmbientColor"), 1, glm::value_ptr(object.material.ambientColor)); gl.glUniform3fv(gl.glGetUniformLocation(programShaderID, "DiffuseColor"), 1, glm::value_ptr(object.material.diffuseColor)); gl.glUniform3fv(gl.glGetUniformLocation(programShaderID, "SpecularColor"), 1, glm::value_ptr(object.material.specularColor)); gl.glUniform1f(gl.glGetUniformLocation(programShaderID, "SpecularPower"), object.material.specularPower); gl.glUniform1ui(gl.glGetUniformLocation(programShaderID, "TextureMappingType"), object.textureMappingType); gl.glUniform1ui(gl.glGetUniformLocation(programShaderID, "TextureMappingAxis"), object.textureMappingAxis); gl.glUniform3fv(gl.glGetUniformLocation(programShaderID, "BoundingBoxMin"), 1, glm::value_ptr(object.boundingBoxMin)); gl.glUniform3fv(gl.glGetUniformLocation(programShaderID, "BoundingBoxMax"), 1, glm::value_ptr(object.boundingBoxMax)); // Draw gl.glDrawElements(GL_TRIANGLES, static_cast<GLsizei>(object.indices.size()), GL_UNSIGNED_INT, nullptr); // Unbind texture specifically to prevent error or already bound texture from being applied (and general cleanup) gl.glActiveTexture(GL_TEXTURE0); gl.glBindTexture(GL_TEXTURE_2D, 0); gl.glActiveTexture(GL_TEXTURE1); gl.glBindTexture(GL_TEXTURE_2D, 0); #ifdef QT_DEBUG // Unbind to avoid accidental modification gl.glBindVertexArray(0); #endif } const unsigned int err = gl.glGetError(); if (err != 0) { std::cerr << "OpenGL draw error: " << err << std::endl; } } void WidgetOpenGLDraw::handleKeys(QSet<int> keys, Qt::KeyboardModifiers modifiers) { // Camera movement if (keys.contains(Qt::Key_W)) { // Move camera in the direction its facing cameraPos += cameraFront * cameraSpeed; } if (keys.contains(Qt::Key_S)) { // Move camera away from the direction its facing cameraPos -= cameraFront * cameraSpeed; } if (keys.contains(Qt::Key_D)) { // Create a vector pointing to the right of the camera (perpendicular to facing direction) and move along it // Normalize to retain move speed independent of cameraFront size cameraPos += glm::normalize(glm::cross(cameraFront, cameraUp)) * cameraSpeed; } if (keys.contains(Qt::Key_A)) { // Create a vector pointing to the left of the camera (perpendicular to facing direction) and move along it // Normalize to retain move speed independent of cameraFront size cameraPos -= glm::normalize(glm::cross(cameraFront, cameraUp)) * cameraSpeed; } if (keys.contains(Qt::Key_Q)) { // Move camera in the direction of up vector cameraPos += cameraUp * cameraSpeed; } if (keys.contains(Qt::Key_E)) { // Move camera in the opposite direction of up vector cameraPos -= cameraUp * cameraSpeed; } // Selected Object movement if (keys.contains(Qt::Key_U)) { // Move up selectedObject->translation.y += 0.25f; } if (keys.contains(Qt::Key_N)) { // Move down selectedObject->translation.y -= 0.25f; } if (keys.contains(Qt::Key_H)) { // Move right selectedObject->translation.x += 0.25f; } if (keys.contains(Qt::Key_L)) { // Move left selectedObject->translation.x -= 0.25f; } if (keys.contains(Qt::Key_K)) { // Move forward selectedObject->translation.z += 0.25f; } if (keys.contains(Qt::Key_J)) { // Move backward selectedObject->translation.z -= 0.25f; } if (keys.contains(Qt::Key_Plus)) { // Scale up selectedObject->scale *= glm::vec3(1.05f); } if (keys.contains(Qt::Key_Minus)) { // Scale down selectedObject->scale *= glm::vec3(0.95f); } if (keys.contains(Qt::Key_X)) { // Rotate on X int8_t dir = (modifiers.testFlag(Qt::ControlModifier)) ? -1 : 1; selectedObject->rotation.x += 0.1f * dir; } if (keys.contains(Qt::Key_Y)) { // Rotate on Y int8_t dir = (modifiers.testFlag(Qt::ControlModifier)) ? -1 : 1; selectedObject->rotation.z += 0.1f * dir; } if (keys.contains(Qt::Key_C)) { // Rotate on Z int8_t dir = (modifiers.testFlag(Qt::ControlModifier)) ? -1 : 1; selectedObject->rotation.y += 0.1f * dir; } // Misc if (keys.contains(Qt::Key_P)) { // Swap projection (orthogonal or perspective) projectionOrtho = !projectionOrtho; } update(); // Redraw scene } void WidgetOpenGLDraw::mousePressEvent(QMouseEvent *event) { if (event->buttons() & Qt::RightButton) { mousePos = event->pos(); } } void WidgetOpenGLDraw::mouseMoveEvent(QMouseEvent *event) { if (event->buttons() & Qt::RightButton) { QPoint mousePosNew = event->pos(); cameraYaw -= static_cast<float>(mousePosNew.x() - mousePos.x()) * cameraSensitivity; cameraPitch -= static_cast<float>(mousePosNew.y() - mousePos.y()) * cameraSensitivity; // Sensible pitch limits if (cameraPitch > 89.0f) cameraPitch = 89.0f; else if (cameraPitch < -89.0f) cameraPitch = -89.0f; updateCameraFront(); mousePos = mousePosNew; } } void WidgetOpenGLDraw::updateCameraFront() { double pitchRad = static_cast<double>(glm::radians(cameraPitch)); double yawRad = static_cast<double>(glm::radians(cameraYaw)); glm::vec3 front; front.x = static_cast<float>(cos(pitchRad) * sin(yawRad)); front.y = static_cast<float>(sin(pitchRad)); front.z = static_cast<float>(cos(pitchRad) * cos(yawRad)); cameraFront = glm::normalize(front); update(); // Redraw scene } void WidgetOpenGLDraw::selectObject(int index) { if (index == 0) { selectedObject = &light; } else { selectedObject = &objects.at(static_cast<uint32_t>(index - 1)); } } bool WidgetOpenGLDraw::isMeshObjectSelected() { return selectedObject != &light; } void WidgetOpenGLDraw::loadModelsFromFile(QStringList &paths, bool preload) { for (auto &path : paths) { QFileInfo fileInfo(path); MeshObject object(fileInfo.fileName()); bool loaded = loadModelOBJ(path.toUtf8().constData(), object); if (loaded) { objects.push_back(object); if (!preload) { // Buffer new data to GPU generateObjectBuffers(objects.back()); // Reference from objects vector, as it is moved in memory when placing into vector! } } } if (!preload) { // Select last added object // (objects index + 1) due to light being at position 0 in ComboBox, but not in objects vector objectSelection->setCurrentIndex(static_cast<int>(objects.size())); update(); // Redraw scene } } void WidgetOpenGLDraw::applyTextureFromFile(QString path, GLuint mappingType, GLuint mappingAxis, MeshObject *object, bool preload) { if (object == nullptr) { object = static_cast<MeshObject *>(selectedObject); } QImage img; if (!img.load(path)) { std::cerr << "Texture image loading failed! [" << path.toStdString() << "]" << std::endl; return; } object->textureImage = img.convertToFormat(QImage::Format_ARGB32); object->textureMappingType = mappingType; object->textureMappingAxis = mappingAxis; if (!preload) { // Buffer new data to GPU loadObjectTexture(*object); update(); // Redraw scene } } void WidgetOpenGLDraw::applyBumpMapFromFile(QString path, MeshObject *object, bool preload) { if (object == nullptr) { object = static_cast<MeshObject *>(selectedObject); } QImage img; if (!img.load(path)) { std::cerr << "Bump map image loading failed! [" << path.toStdString() << "]" << std::endl; return; } object->bumpMapImage = img.convertToFormat(QImage::Format_ARGB32); if (!preload) { // Buffer new data to GPU loadObjectBumpMap(*object); update(); // Redraw scene } } bool WidgetOpenGLDraw::loadModelOBJ(const char *path, MeshObject &object) { std::vector<uint32_t> vertexIndices, uvIndices, normalIndices; std::vector<glm::vec3> tmpPositions; std::vector<glm::vec2> tmpUvs; std::vector<glm::vec3> tmpNormals; std::ifstream ifs; ifs.open(path); // Read file bool error = false; while (!error) { std::string lineHeader; ifs >> lineHeader; if (ifs.eof()) break; if (lineHeader == "v") { glm::vec3 vertex; if (!(ifs >> vertex.x >> vertex.y >> vertex.z)) error = true; tmpPositions.push_back(vertex); } else if (lineHeader == "vt") { glm::vec2 uv; if (!(ifs >> uv.x >> uv.y)) error = true; tmpUvs.push_back(uv); } else if (lineHeader == "vn") { glm::vec3 normal; if (!(ifs >> normal.x >> normal.y >> normal.z)) error = true; tmpNormals.push_back(normal); } else if (lineHeader == "f") { uint32_t vertexIndex[3], uvIndex[3], normalIndex[3]; char s; // Indices separated by '/' (slash) if (!(ifs >> vertexIndex[0] >> s >> uvIndex[0] >> s >> normalIndex[0] >> vertexIndex[1] >> s >> uvIndex[1] >> s >> normalIndex[1] >> vertexIndex[2] >> s >> uvIndex[2] >> s >> normalIndex[2])) error = true; vertexIndices.insert(vertexIndices.end(), {vertexIndex[0], vertexIndex[1], vertexIndex[2]}); uvIndices.insert(uvIndices.end(), {uvIndex[0], uvIndex[1], uvIndex[2]}); normalIndices.insert(normalIndices.end(), {normalIndex[0], normalIndex[1], normalIndex[2]}); } else { // Probably a comment (or something else we don't support), eat up the rest of the line ifs.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); } } if (error) { std::cerr << "Model OBJ file parsing failed! [" << path << "]" << std::endl; ifs.close(); return false; } // Rearrange data - OBJ indexes all parts separately, OpenGL only supports 1 index buffer // Ignore OBJ indexing and just duplicate data for non-index usage (but still directly index them to keep the rest of the code clean) // Each triangle for (uint32_t v = 0; v < vertexIndices.size(); v += 3) { // Each vertex of the triangle for (uint32_t i = 0; i < 3; ++i) { // Get indices of wanted parts uint32_t vertexIndex = vertexIndices[v + i]; glm::vec3 position = tmpPositions[vertexIndex - 1]; uint32_t uvIndex = uvIndices[v + i]; glm::vec2 uv = tmpUvs[uvIndex - 1]; uint32_t normalIndex = normalIndices[v + i]; glm::vec3 normal = tmpNormals[normalIndex - 1]; // Save parts into Vertex and use current overall index object.vertices.push_back({position, uv, normal}); object.indices.push_back(v + i); } } ifs.close(); return true; } MeshObject WidgetOpenGLDraw::makeCube(QString name) { return makeCubeOffset(glm::vec3(0.0f, 0.0f, 0.0f), 0, name); } MeshObject WidgetOpenGLDraw::makeCubeOffset(glm::vec3 baseVertex, GLuint baseIndex, QString name) { MeshObject cube = { name, // Some vertices duplicated to fit indexing of UVs { {baseVertex + glm::vec3(0.0f, 1.0f, 0.0f), glm::vec2(0.0f, 0.66f), glm::vec3(-1.0f, 2.0f, -1.0f)}, {baseVertex + glm::vec3(0.0f, 0.0f, 0.0f), glm::vec2(0.25f, 0.66f), glm::vec3(-1.0f, -1.0f, -1.0f)}, {baseVertex + glm::vec3(1.0f, 1.0f, 0.0f), glm::vec2(0.0f, 0.33f), glm::vec3(2.0f, 2.0f, -1.0f)}, {baseVertex + glm::vec3(1.0f, 0.0f, 0.0f), glm::vec2(0.25f, 0.33f), glm::vec3(2.0f, -1.0f, -1.0f)}, {baseVertex + glm::vec3(0.0f, 0.0f, 1.0f), glm::vec2(0.5f, 0.66f), glm::vec3(-1.0f, -1.0f, 2.0f)}, {baseVertex + glm::vec3(1.0f, 0.0f, 1.0f), glm::vec2(0.5f, 0.33f), glm::vec3(2.0f, -1.0f, 2.0f)}, {baseVertex + glm::vec3(0.0f, 1.0f, 1.0f), glm::vec2(0.75f, 0.66f), glm::vec3(-1.0f, 2.0f, -1.0f)}, {baseVertex + glm::vec3(1.0f, 1.0f, 1.0f), glm::vec2(0.75f, 0.33f), glm::vec3(2.0f, 2.0f, 2.0f)}, {baseVertex + glm::vec3(0.0f, 1.0f, 0.0f), glm::vec2(1.0f, 0.66f), glm::vec3(-1.0f, 2.0f, -1.0f)}, {baseVertex + glm::vec3(1.0f, 1.0f, 0.0f), glm::vec2(1.0f, 0.33f), glm::vec3(2.0f, 2.0f, -1.0f)}, {baseVertex + glm::vec3(0.0f, 1.0f, 0.0f), glm::vec2(0.25f, 1.0f), glm::vec3(-1.0f, 2.0f, -1.0f)}, {baseVertex + glm::vec3(0.0f, 1.0f, 1.0f), glm::vec2(0.5f, 1.0f), glm::vec3(-1.0f, 2.0f, 2.0f)}, {baseVertex + glm::vec3(1.0f, 1.0f, 0.0f), glm::vec2(0.25f, 0.0f), glm::vec3(2.0f, 2.0f, -1.0f)}, {baseVertex + glm::vec3(1.0f, 1.0f, 1.0f), glm::vec2(0.5f, 0.0f), glm::vec3(2.0f, 2.0f, 2.0f)}, }, { baseIndex + 0, baseIndex + 2, baseIndex + 1,baseIndex + 1, baseIndex + 2, baseIndex + 3, // Front baseIndex + 4, baseIndex + 5, baseIndex + 6, baseIndex + 5, baseIndex + 7, baseIndex + 6, // Back baseIndex + 6, baseIndex + 7, baseIndex + 8, baseIndex + 7, baseIndex + 9, baseIndex + 8, // Top baseIndex + 1, baseIndex + 3, baseIndex + 4, baseIndex + 3, baseIndex + 5, baseIndex + 4, // Bottom baseIndex + 1, baseIndex + 11, baseIndex + 10, baseIndex + 1, baseIndex + 4, baseIndex + 11, // Left baseIndex + 3, baseIndex + 12, baseIndex + 5, baseIndex + 5, baseIndex + 12, baseIndex + 13, // Right } }; return cube; } MeshObject WidgetOpenGLDraw::makePyramid(uint32_t rows, QString name) { MeshObject pyramid(name); float offset = 0.0f; for (uint32_t row = 0; row < rows; ++row) { for (uint32_t i = 0; i < rows - row; ++i) { for (uint32_t j = 0; j < rows - row; ++j) { // Make cube and merge it into the pyramid MeshObject cube = makeCubeOffset(glm::vec3(offset + i, row, offset + j), static_cast<GLuint>(pyramid.vertices.size())); pyramid.vertices.insert(std::end(pyramid.vertices), std::begin(cube.vertices), std::end(cube.vertices)); pyramid.indices.insert(std::end(pyramid.indices), std::begin(cube.indices), std::end(cube.indices)); // Note: Normals should be corrected here, but they aren't } } offset += 0.5f; } // Random solid color texture std::uniform_int_distribution<> dist(0, 255); QColor rngColor(dist(rng), dist(rng), dist(rng)); QImage img(1, 1, QImage::Format_ARGB32); img.fill(rngColor); pyramid.textureImage = img; return pyramid; }
40.350528
164
0.630175
jonpas
95970213c76d95fd6fc8c0f6d18e242c1c502780
4,419
cpp
C++
code/clustered_setup/fgm-master/LSGMcode-master/algorithms/graphm-0.52/algorithm_umeyama.cpp
mk2510/jointGraphMatchingAndClustering
52f579a07d106cb241d21dbc29a2ec9e9c77b254
[ "Unlicense" ]
10
2015-08-27T14:10:38.000Z
2021-02-08T21:38:55.000Z
code/clustered_setup/fgm-master/LSGMcode-master/algorithms/graphm-0.52/algorithm_umeyama.cpp
mk2510/jointGraphMatchingAndClustering
52f579a07d106cb241d21dbc29a2ec9e9c77b254
[ "Unlicense" ]
2
2015-02-20T01:53:58.000Z
2016-08-24T11:14:00.000Z
code/clustered_setup/fgm-master/LSGMcode-master/algorithms/graphm-0.52/algorithm_umeyama.cpp
mk2510/jointGraphMatchingAndClustering
52f579a07d106cb241d21dbc29a2ec9e9c77b254
[ "Unlicense" ]
7
2016-08-23T11:44:05.000Z
2021-08-06T01:41:25.000Z
/*************************************************************************** * Copyright (C) 2008 by Mikhail Zaslavskiy * * mikhail.zaslavskiy@ensmp.fr * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #include "algorithm_umeyama.h" match_result algorithm_umeyama::match(graph& g, graph& h,gsl_matrix* gm_P_i,gsl_matrix* gm_ldh,double dalpha_ldh) { if (bverbose) *gout<<"Umeyama algorithm"<<std::endl; bool bblast_match_end=(get_param_i("blast_match_proj")==1); //some duplicate variables gsl_matrix* gm_Ag_d=g.get_descmatrix(cdesc_matrix); gsl_matrix* gm_Ah_d=h.get_descmatrix(cdesc_matrix); if (pdebug.ivalue) gsl_matrix_printout(gm_Ag_d,"Ag",pdebug.strvalue); if (pdebug.ivalue) gsl_matrix_printout(gm_Ah_d,"Ah",pdebug.strvalue); //memory allocation gsl_eigen_symmv_workspace * gesw= gsl_eigen_symmv_alloc (N); gsl_vector* eval_g=gsl_vector_alloc(N); gsl_vector* eval_h=gsl_vector_alloc(N); gsl_matrix* evec_g=gsl_matrix_alloc(N,N); gsl_matrix* evec_h=gsl_matrix_alloc(N,N); if (bverbose) *gout<<"Memory allocation finished"<<std::endl; //eigenvalues and eigenvectors for both matrices gsl_eigen_symmv (gm_Ag_d, eval_g,evec_g,gesw); if (bverbose) *gout<<"Ag eigen vectors"<<std::endl; gsl_eigen_symmv (gm_Ah_d, eval_h,evec_h,gesw); gsl_matrix_free(gm_Ag_d); gsl_matrix_free(gm_Ah_d); if (bverbose) *gout<<"Ah eigen vectors"<<std::endl; gsl_eigen_symmv_sort (eval_g, evec_g, GSL_EIGEN_SORT_VAL_DESC); gsl_eigen_symmv_sort (eval_h, evec_h, GSL_EIGEN_SORT_VAL_DESC); if (pdebug.ivalue){ gsl_matrix_printout(eval_g,"eval_g",pdebug.strvalue); gsl_matrix_printout(eval_h,"eval_h",pdebug.strvalue); gsl_matrix_printout(evec_g,"evec_g",pdebug.strvalue); gsl_matrix_printout(evec_h,"evec_h",pdebug.strvalue);}; gsl_matrix_abs(evec_g); gsl_matrix_abs(evec_h); if (pdebug.ivalue) gsl_matrix_printout(evec_g,"abs(evec_g)",pdebug.strvalue); if (pdebug.ivalue) gsl_matrix_printout(evec_h,"abs(evec_h)",pdebug.strvalue); //loss matrix construction gsl_matrix* C=gsl_matrix_alloc(N,N); if (bverbose) *gout<<"Loss function matrix allocation"<<std::endl; gsl_blas_dgemm(CblasNoTrans,CblasTrans,1,evec_g,evec_h,0,C); if (pdebug.ivalue) gsl_matrix_printout(C,"C=abs(evec_g)*abs(evec_h')",pdebug.strvalue); //label cost matrix update_C_hungarian(C,-1); //scaling for hungarian double dscale_factor =gsl_matrix_max_abs(C); dscale_factor=(dscale_factor>EPSILON)?dscale_factor:EPSILON; dscale_factor=10000/dscale_factor; gsl_matrix_scale(C,-dscale_factor); gsl_matrix_transpose(C); if (pdebug.ivalue) gsl_matrix_printout(C,"scale(C)",pdebug.strvalue); gsl_matrix* gm_P=gsl_matrix_alloc(N,N); gsl_matrix_hungarian(C,gm_P,NULL,NULL,false,(bblast_match_end?gm_ldh:NULL),false); if (pdebug.ivalue) gsl_matrix_printout(gm_P,"gm_P",pdebug.strvalue); if (bverbose) *gout<<"Hungarian solved"<<std::endl; match_result mres; mres.gm_P=gm_P; //initial score mres.vd_trace.push_back(graph_dist(g,h,cscore_matrix)); //final score mres.vd_trace.push_back(graph_dist(g,h,gm_P,cscore_matrix)); //other output parameters mres.dres=mres.vd_trace.at(1); mres.inum_iteration=2; //transpose matrix save mres.gm_P=gm_P; mres.gm_P_exact=NULL; return mres; }
47.010638
113
0.661914
mk2510
9598d34a7577c3b1097b2cdac4e5058f7affa603
683
cpp
C++
drivers/port_io/port_io.cpp
Tomer2003/ro-os
843b0258e8d14de7cc24f9ae9bfa19fe02ccd00d
[ "MIT" ]
null
null
null
drivers/port_io/port_io.cpp
Tomer2003/ro-os
843b0258e8d14de7cc24f9ae9bfa19fe02ccd00d
[ "MIT" ]
null
null
null
drivers/port_io/port_io.cpp
Tomer2003/ro-os
843b0258e8d14de7cc24f9ae9bfa19fe02ccd00d
[ "MIT" ]
null
null
null
#include "port_io.hpp" void portWriteByte(unsigned short portAddress, unsigned char data) { __asm__ __volatile__("out %%al, %%dx" :: "a"(data), "d"(portAddress)); } unsigned char portReadByte(unsigned short portAddress) { unsigned char result; __asm__ __volatile__("in %%dx, %%al" : "=a"(result) : "d"(portAddress)); return result; } void portWriteWord(unsigned short portAddress, unsigned short data) { __asm__ __volatile__("out %%ax, %%dx" :: "a"(data), "d"(portAddress)); } unsigned short portReadWord(unsigned short portAddress) { unsigned short result; __asm__ __volatile__("in %%dx, %%ax" : "=a"(result) : "d"(portAddress)); return result; }
27.32
76
0.679356
Tomer2003
95991eec4f58418a24c0ac505366c668ae00c770
459
hpp
C++
include/portable/cxx.hpp
matrixjoeq/candy
53fe18d8b68d2f131c8e1c8f76c7d9b7f752bbdc
[ "MIT" ]
null
null
null
include/portable/cxx.hpp
matrixjoeq/candy
53fe18d8b68d2f131c8e1c8f76c7d9b7f752bbdc
[ "MIT" ]
null
null
null
include/portable/cxx.hpp
matrixjoeq/candy
53fe18d8b68d2f131c8e1c8f76c7d9b7f752bbdc
[ "MIT" ]
null
null
null
#pragma once #include <type_traits> namespace candy { template <bool B, class T = void> using EnableIf = typename std::enable_if<B, T>::type; template <class T> using ResultOf = typename std::result_of<T>::type; template <class Base, class Derived> inline constexpr bool isBaseOf() { return std::is_base_of<Base, Derived>::value; } template <class T> inline constexpr bool isPointer() { return std::is_pointer<T>::value; } } // namespace candy
17.653846
53
0.714597
matrixjoeq
959b5abb8eb5b8790f60e6eb93d6b4aa7fad2380
5,731
cpp
C++
client/http_secure_args.cpp
boazsade/http_client
5e7a97c73da7e22685c29177581bf9c95e73f2ec
[ "MIT" ]
null
null
null
client/http_secure_args.cpp
boazsade/http_client
5e7a97c73da7e22685c29177581bf9c95e73f2ec
[ "MIT" ]
null
null
null
client/http_secure_args.cpp
boazsade/http_client
5e7a97c73da7e22685c29177581bf9c95e73f2ec
[ "MIT" ]
null
null
null
#include "http_secure_args.h" namespace http { namespace { namespace ssl = boost::asio::ssl; ssl::context init_context(const https_config& conf) { int proto = conf.security_type(); if (proto == -1) { proto = ssl::context_base::sslv23; } ssl::context ctx((ssl::context::method)proto); if (conf.cert_conf().use_default()) { ctx.set_default_verify_paths(); } else { if (conf.cert_conf().is_file()) { ctx.load_verify_file(conf.cert_conf().get_path()); } else { ctx.add_verify_path(conf.cert_conf().get_path()); } } return ctx; } #if 0 bool is_server_side(int value) { switch (value) { case -1: return false; case ssl::context_base::sslv2_server: case ssl::context_base::sslv3_server: case ssl::context_base::tlsv1_server: case ssl::context_base::tlsv11_server: case ssl::context_base::tlsv12_server: case ssl::context_base::sslv23_server: return true; default: return false; } } bool is_any_side(int value) { switch(value) { case -1: return false; case ssl::context_base::sslv2: case ssl::context_base::sslv3: case ssl::context_base::tlsv1: case ssl::context_base::tlsv11: case ssl::context_base::tlsv12: case ssl::context_base::sslv23: return true; default: return false; } } bool is_client_side(int value) { return !(is_any_side(value) || is_server_side(value)); } #endif int type2boost_type_client(https_config::type t) { switch (t) { case https_config::SSL_V2: return ssl::context_base::sslv2_client; case https_config::SSL_V3: return ssl::context_base::sslv3_client; case https_config::TLS_V1: return ssl::context_base::tlsv1_client; case https_config::TLS_V11: return ssl::context_base::tlsv11_client; case https_config::TLS_V12: return ssl::context_base::tlsv12_client; case https_config::SSL_TLS: return ssl::context_base::sslv23_client; case https_config::TYPE_NOT_SET: return -1; } } int type2boost_type_sever(https_config::type t) { switch (t) { case https_config::SSL_V2: return ssl::context_base::sslv2_server; case https_config::SSL_V3: return ssl::context_base::sslv3_server; case https_config::TLS_V1: return ssl::context_base::tlsv1_server; case https_config::TLS_V11: return ssl::context_base::tlsv11_server; case https_config::TLS_V12: return ssl::context_base::tlsv12_server; case https_config::SSL_TLS: return ssl::context_base::sslv23_server; case https_config::TYPE_NOT_SET: return -1; } } int type2boost_type(https_config::type t) { switch (t) { case https_config::SSL_V2: return ssl::context_base::sslv2; case https_config::SSL_V3: return ssl::context_base::sslv3; case https_config::TLS_V1: return ssl::context_base::tlsv1; case https_config::TLS_V11: return ssl::context_base::tlsv11; case https_config::TLS_V12: return ssl::context_base::tlsv12; case https_config::SSL_TLS: return ssl::context_base::sslv23; case https_config::TYPE_NOT_SET: return -1; } } int convert2action(https_config::type t, https_config::which w) { switch (w) { case https_config::CLIENT_ONLY: return type2boost_type_client(t); case https_config::SERVER_ONLY: return type2boost_type_sever(t); default: return type2boost_type(t); } } /////////////////////////////////////////////////////////////////////////////// } // end of local namespce https_cert::https_cert() : fformat(NOT_SET), file(false) { } https_cert::https_cert(const std::string& p, format f) : path(p), fformat(f), file(false) { } https_cert::https_cert(const std::string& p, bool is_file, format f) : path(p), fformat(f), file(is_file) { } bool https_cert::use_default() const { return path.empty(); } https_cert::format https_cert::get_format() const { return fformat; } const char* https_cert::get_path() const { return use_default() ? nullptr : path.c_str(); } bool https_cert::is_file() const { return file; } /////////////////////////////////////////////////////////////////////////////// https_config::https_config(type t, which w, const https_cert& c) : sec_type(convert2action(t, w)), cert(c) { } const https_cert& https_config::cert_conf() const { return cert; } https_config& https_config::set_protocol(type t, which w) { sec_type = convert2action(t, w); return *this; } https_config& https_config::operator = (const https_cert& c) { cert = c; return *this; } int https_config::security_type() const { return sec_type; } /////////////////////////////////////////////////////////////////////////////// security_args::security_args(const https_config& conf) : context(std::move(init_context(conf))), verify_action(security_args::DONT_APPLY) { } security_args::security_args(int verify_type, const https_config& conf) : context(std::move(init_context(conf))), verify_action(verify_type) { } void security_args::sec_method(int type) { verify_action = type; } security_args::ssl_context& security_args::security_handle() { return context; } int security_args::security_method() const { return verify_action;; } } // end of namespace http
24.491453
140
0.61019
boazsade
95a2502d0f83bdf392fc3037a78b0db10a6d1f06
15,415
cpp
C++
src/apps/mplayerc/EditListEditor.cpp
chinajeffery/MPC-BE--1.2.3
2229fde5535f565ba4a496a7f73267bd2c1ad338
[ "MIT" ]
null
null
null
src/apps/mplayerc/EditListEditor.cpp
chinajeffery/MPC-BE--1.2.3
2229fde5535f565ba4a496a7f73267bd2c1ad338
[ "MIT" ]
1
2019-11-14T04:18:32.000Z
2019-11-14T04:18:32.000Z
src/apps/mplayerc/EditListEditor.cpp
chinajeffery/MPC-BE--1.2.3
2229fde5535f565ba4a496a7f73267bd2c1ad338
[ "MIT" ]
null
null
null
/* * $Id: EditListEditor.cpp 2326 2013-03-21 12:41:26Z aleksoid $ * * (C) 2006-2013 see Authors.txt * * This file is part of MPC-BE. * * MPC-BE is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * MPC-BE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ #include "stdafx.h" #include "EditListEditor.h" CClip::CClip() { m_rtIn = INVALID_TIME; m_rtOut = INVALID_TIME; } void CClip::SetIn(LPCTSTR strVal) { m_rtIn = StringToReftime (strVal); } void CClip::SetOut(LPCTSTR strVal) { m_rtOut = StringToReftime (strVal); } void CClip::SetIn (REFERENCE_TIME rtVal) { m_rtIn = rtVal; if (m_rtIn > m_rtOut) { m_rtOut = INVALID_TIME; } }; void CClip::SetOut (REFERENCE_TIME rtVal) { m_rtOut = rtVal; if (m_rtIn > m_rtOut) { m_rtIn = INVALID_TIME; } }; CString CClip::GetIn() { if (m_rtIn == INVALID_TIME) { return _T(""); } else { return ReftimeToString(m_rtIn); } } CString CClip::GetOut() { if (m_rtOut == INVALID_TIME) { return _T(""); } else { return ReftimeToString(m_rtOut); } } IMPLEMENT_DYNAMIC(CEditListEditor, CPlayerBar) CEditListEditor::CEditListEditor(void) { m_CurPos = NULL; m_bDragging = FALSE; m_nDragIndex = -1; m_nDropIndex = -1; m_bFileOpen = false; } CEditListEditor::~CEditListEditor(void) { SaveEditListToFile(); } BEGIN_MESSAGE_MAP(CEditListEditor, CPlayerBar) ON_WM_SIZE() ON_NOTIFY(LVN_ITEMCHANGED, IDC_EDITLIST, OnLvnItemchanged) ON_NOTIFY(LVN_KEYDOWN, IDC_EDITLIST, OnLvnKeyDown) ON_WM_DRAWITEM() ON_NOTIFY(LVN_BEGINDRAG, IDC_EDITLIST, OnBeginDrag) ON_WM_MOUSEMOVE() ON_WM_LBUTTONUP() ON_WM_TIMER() ON_NOTIFY(LVN_BEGINLABELEDIT, IDC_EDITLIST, OnBeginlabeleditList) ON_NOTIFY(LVN_DOLABELEDIT, IDC_EDITLIST, OnDolabeleditList) ON_NOTIFY(LVN_ENDLABELEDIT, IDC_EDITLIST, OnEndlabeleditList) END_MESSAGE_MAP() BOOL CEditListEditor::Create(CWnd* pParentWnd, UINT defDockBarID) { if (!__super::Create(ResStr(IDS_EDIT_LIST_EDITOR), pParentWnd, ID_VIEW_EDITLISTEDITOR, defDockBarID, _T("Edit List Editor"))) { return FALSE; } m_stUsers.Create (_T("User :"), WS_VISIBLE|WS_CHILD, CRect (5,5,100,21), this, 0); m_cbUsers.Create (WS_CHILD|WS_VISIBLE|CBS_DROPDOWNLIST, CRect (90,0, 260, 21), this, 0); FillCombo(_T("Users.txt"), m_cbUsers, false); m_stHotFolders.Create (_T("Hot folder :"), WS_VISIBLE|WS_CHILD, CRect (5,35,100,51), this, 0); m_cbHotFolders.Create (WS_CHILD|WS_VISIBLE|CBS_DROPDOWNLIST, CRect (90,30, 260, 21), this, 0); FillCombo(_T("HotFolders.txt"), m_cbHotFolders, true); m_list.CreateEx( WS_EX_DLGMODALFRAME|WS_EX_CLIENTEDGE, WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|WS_CLIPCHILDREN|WS_TABSTOP |LVS_OWNERDRAWFIXED |LVS_REPORT|LVS_SINGLESEL|LVS_AUTOARRANGE|LVS_NOSORTHEADER, CRect(0,0,100,100), this, IDC_EDITLIST); m_list.SetExtendedStyle(m_list.GetExtendedStyle()|LVS_EX_FULLROWSELECT|LVS_EX_DOUBLEBUFFER); m_list.InsertColumn(COL_IN, _T("Nb."), LVCFMT_LEFT, 35); m_list.InsertColumn(COL_IN, _T("In"), LVCFMT_LEFT, 100); m_list.InsertColumn(COL_OUT, _T("Out"), LVCFMT_LEFT, 100); m_list.InsertColumn(COL_NAME, _T("Name"), LVCFMT_LEFT, 150); m_fakeImageList.Create(1, 16, ILC_COLOR4, 10, 10); m_list.SetImageList(&m_fakeImageList, LVSIL_SMALL); return TRUE; } void CEditListEditor::OnSize(UINT nType, int cx, int cy) { CSizingControlBarG::OnSize(nType, cx, cy); ResizeListColumn(); } void CEditListEditor::ResizeListColumn() { if (::IsWindow(m_list.m_hWnd)) { CRect r; GetClientRect(r); r.DeflateRect(2, 2); r.top += 60; m_list.SetRedraw(FALSE); m_list.MoveWindow(r); m_list.GetClientRect(r); m_list.SetRedraw(TRUE); } } void CEditListEditor::SaveEditListToFile() { if ((m_bFileOpen || m_EditList.GetCount() >0) && !m_strFileName.IsEmpty()) { CStdioFile EditListFile; if (EditListFile.Open (m_strFileName, CFile::modeCreate|CFile::modeWrite)) { CString strLine; int nIndex; CString strUser; CString strHotFolders; nIndex = m_cbUsers.GetCurSel(); if (nIndex >= 0) { m_cbUsers.GetLBText(nIndex, strUser); } nIndex = m_cbHotFolders.GetCurSel(); if (nIndex >= 0) { m_cbHotFolders.GetLBText(nIndex, strHotFolders); } POSITION pos = m_EditList.GetHeadPosition(); for (int i = 0; pos; i++, m_EditList.GetNext(pos)) { CClip& CurClip = m_EditList.GetAt(pos); if (CurClip.HaveIn() && CurClip.HaveOut()) { strLine.Format(_T("%s\t%s\t%s\t%s\t%s\n"), CurClip.GetIn(), CurClip.GetOut(), CurClip.GetName(), strUser, strHotFolders); EditListFile.WriteString (strLine); } } EditListFile.Close(); } } } void CEditListEditor::CloseFile() { SaveEditListToFile(); m_EditList.RemoveAll(); m_list.DeleteAllItems(); m_CurPos = NULL; m_strFileName = ""; m_bFileOpen = false; m_cbHotFolders.SetCurSel(0); } void CEditListEditor::OpenFile(LPCTSTR lpFileName) { CString strLine; CStdioFile EditListFile; CString strUser; CString strHotFolders; CloseFile(); m_strFileName.Format(_T("%s.edl"), lpFileName); if (EditListFile.Open (m_strFileName, CFile::modeRead)) { m_bFileOpen = true; while (EditListFile.ReadString(strLine)) { //int nPos = 0; CString strIn; // = strLine.Tokenize(_T(" \t"), nPos); CString strOut; // = strLine.Tokenize(_T(" \t"), nPos); CString strName; // = strLine.Tokenize(_T(" \t"), nPos); AfxExtractSubString (strIn, strLine, 0, _T('\t')); AfxExtractSubString (strOut, strLine, 1, _T('\t')); AfxExtractSubString (strName, strLine, 2, _T('\t')); if (strUser.IsEmpty()) { AfxExtractSubString (strUser, strLine, 3, _T('\t')); SelectCombo(strUser, m_cbUsers); } if (strHotFolders.IsEmpty()) { AfxExtractSubString (strHotFolders, strLine, 4, _T('\t')); SelectCombo(strHotFolders, m_cbHotFolders); } if (!strIn.IsEmpty() && !strOut.IsEmpty()) { CClip NewClip; NewClip.SetIn (strIn); NewClip.SetOut (strOut); NewClip.SetName(strName); InsertClip (NULL, NewClip); } } EditListFile.Close(); } else { m_bFileOpen = false; } if (m_NameList.GetCount() == 0) { CStdioFile NameFile; CString str; if (NameFile.Open (_T("EditListNames.txt"), CFile::modeRead)) { while (NameFile.ReadString(str)) { m_NameList.Add(str); } NameFile.Close(); } } } void CEditListEditor::SetIn (REFERENCE_TIME rtIn) { if (m_CurPos != NULL) { CClip& CurClip = m_EditList.GetAt (m_CurPos); CurClip.SetIn (rtIn); m_list.Invalidate(); } } void CEditListEditor::SetOut(REFERENCE_TIME rtOut) { if (m_CurPos != NULL) { CClip& CurClip = m_EditList.GetAt (m_CurPos); CurClip.SetOut (rtOut); m_list.Invalidate(); } } void CEditListEditor::NewClip(REFERENCE_TIME rtVal) { CClip NewClip; if (m_CurPos != NULL) { CClip& CurClip = m_EditList.GetAt (m_CurPos); if (CurClip.HaveIn()) { if (!CurClip.HaveOut()) { CurClip.SetOut (rtVal); } } } m_CurPos = InsertClip (m_CurPos, NewClip); m_list.Invalidate(); } void CEditListEditor::Save() { SaveEditListToFile(); } int CEditListEditor::FindIndex(POSITION pos) { int iItem = 0; POSITION CurPos = m_EditList.GetHeadPosition(); while (CurPos && CurPos != pos) { m_EditList.GetNext (CurPos); iItem++; } return iItem; } POSITION CEditListEditor::InsertClip(POSITION pos, CClip& NewClip) { LVITEM lv; POSITION NewClipPos; if (pos == NULL) { NewClipPos = m_EditList.AddTail (NewClip); } else { NewClipPos = m_EditList.InsertAfter (pos, NewClip); } lv.mask = LVIF_STATE | LVIF_TEXT; lv.iItem = FindIndex (pos); lv.iSubItem = 0; lv.pszText = _T(""); lv.state = m_list.GetItemCount()==0 ? LVIS_SELECTED : 0; m_list.InsertItem(&lv); return NewClipPos; } void CEditListEditor::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct) { if (nIDCtl != IDC_EDITLIST) { return; } int nItem = lpDrawItemStruct->itemID; CRect rcItem = lpDrawItemStruct->rcItem; POSITION pos = m_EditList.FindIndex(nItem); if (pos != NULL) { bool fSelected = (pos == m_CurPos); UNREFERENCED_PARAMETER(fSelected); CClip& CurClip = m_EditList.GetAt(pos); CString strTemp; CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC); if (!!m_list.GetItemState(nItem, LVIS_SELECTED)) { FillRect(pDC->m_hDC, rcItem, CBrush(0xf1dacc)); FrameRect(pDC->m_hDC, rcItem, CBrush(0xc56a31)); } else { FillRect(pDC->m_hDC, rcItem, CBrush(GetSysColor(COLOR_WINDOW))); } COLORREF textcolor = RGB(0,0,0); if (!CurClip.HaveIn() || !CurClip.HaveOut()) { textcolor = RGB(255,0,0); } for (int i=0; i<COL_MAX; i++) { m_list.GetSubItemRect(nItem, i, LVIR_LABEL, rcItem); pDC->SetTextColor(textcolor); switch (i) { case COL_INDEX : strTemp.Format (_T("%d"), nItem+1); pDC->DrawText (strTemp, rcItem, DT_CENTER | DT_VCENTER); break; case COL_IN : pDC->DrawText (CurClip.GetIn(), rcItem, DT_CENTER | DT_VCENTER); break; case COL_OUT : pDC->DrawText (CurClip.GetOut(), rcItem, DT_CENTER | DT_VCENTER); break; case COL_NAME : pDC->DrawText (CurClip.GetName(), rcItem, DT_LEFT | DT_VCENTER); break; } } } } void CEditListEditor::OnLvnItemchanged(NMHDR *pNMHDR, LRESULT *pResult) { LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR); if (pNMLV->iItem >= 0) { m_CurPos = m_EditList.FindIndex (pNMLV->iItem); } } void CEditListEditor::OnLvnKeyDown(NMHDR* pNMHDR, LRESULT* pResult) { LPNMLVKEYDOWN pLVKeyDown = reinterpret_cast<LPNMLVKEYDOWN>(pNMHDR); *pResult = FALSE; if (pLVKeyDown->wVKey == VK_DELETE) { POSITION pos = m_list.GetFirstSelectedItemPosition(); POSITION ClipPos; int nItem = -1; while (pos) { nItem = m_list.GetNextSelectedItem(pos); ClipPos = m_EditList.FindIndex (nItem); if (ClipPos) { m_EditList.RemoveAt (ClipPos); } m_list.DeleteItem (nItem); } if (nItem != -1) { m_list.SetItemState (min (nItem, m_list.GetItemCount()-1), LVIS_SELECTED, LVIS_SELECTED); } m_list.Invalidate(); } } void CEditListEditor::OnBeginDrag(NMHDR* pNMHDR, LRESULT* pResult) { ModifyStyle(WS_EX_ACCEPTFILES, 0); m_nDragIndex = ((LPNMLISTVIEW)pNMHDR)->iItem; CPoint p(0, 0); m_pDragImage = m_list.CreateDragImageEx(&p); CPoint p2 = ((LPNMLISTVIEW)pNMHDR)->ptAction; m_pDragImage->BeginDrag(0, p2 - p); m_pDragImage->DragEnter(GetDesktopWindow(), ((LPNMLISTVIEW)pNMHDR)->ptAction); m_bDragging = TRUE; m_nDropIndex = -1; SetCapture(); } void CEditListEditor::OnMouseMove(UINT nFlags, CPoint point) { if (m_bDragging) { m_ptDropPoint = point; ClientToScreen(&m_ptDropPoint); m_pDragImage->DragMove(m_ptDropPoint); m_pDragImage->DragShowNolock(FALSE); WindowFromPoint(m_ptDropPoint)->ScreenToClient(&m_ptDropPoint); m_pDragImage->DragShowNolock(TRUE); { int iOverItem = m_list.HitTest(m_ptDropPoint); int iTopItem = m_list.GetTopIndex(); int iBottomItem = m_list.GetBottomIndex(); if (iOverItem == iTopItem && iTopItem != 0) { // top of list SetTimer(1, 100, NULL); } else { KillTimer(1); } if (iOverItem >= iBottomItem && iBottomItem != (m_list.GetItemCount() - 1)) { // bottom of list SetTimer(2, 100, NULL); } else { KillTimer(2); } } } __super::OnMouseMove(nFlags, point); } void CEditListEditor::OnTimer(UINT_PTR nIDEvent) { int iTopItem = m_list.GetTopIndex(); int iBottomItem = iTopItem + m_list.GetCountPerPage() - 1; if (m_bDragging) { m_pDragImage->DragShowNolock(FALSE); if (nIDEvent == 1) { m_list.EnsureVisible(iTopItem - 1, false); m_list.UpdateWindow(); if (m_list.GetTopIndex() == 0) { KillTimer(1); } } else if (nIDEvent == 2) { m_list.EnsureVisible(iBottomItem + 1, false); m_list.UpdateWindow(); if (m_list.GetBottomIndex() == (m_list.GetItemCount() - 1)) { KillTimer(2); } } m_pDragImage->DragShowNolock(TRUE); } __super::OnTimer(nIDEvent); } void CEditListEditor::OnLButtonUp(UINT nFlags, CPoint point) { if (m_bDragging) { ::ReleaseCapture(); m_bDragging = FALSE; m_pDragImage->DragLeave(GetDesktopWindow()); m_pDragImage->EndDrag(); delete m_pDragImage; m_pDragImage = NULL; KillTimer(1); KillTimer(2); CPoint pt(point); ClientToScreen(&pt); if (WindowFromPoint(pt) == &m_list) { DropItemOnList(); } } ModifyStyle(0, WS_EX_ACCEPTFILES); __super::OnLButtonUp(nFlags, point); } void CEditListEditor::DropItemOnList() { m_ptDropPoint.y -= 10; m_nDropIndex = m_list.HitTest(CPoint(10, m_ptDropPoint.y)); POSITION DragPos = m_EditList.FindIndex (m_nDragIndex); POSITION DropPos = m_EditList.FindIndex (m_nDropIndex); if ((DragPos!=NULL) && (DropPos!=NULL)) { CClip& DragClip = m_EditList.GetAt(DragPos); m_EditList.InsertAfter (DropPos, DragClip); m_EditList.RemoveAt (DragPos); m_list.Invalidate(); } } void CEditListEditor::OnBeginlabeleditList(NMHDR* pNMHDR, LRESULT* pResult) { LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR; LV_ITEM* pItem = &pDispInfo->item; *pResult = FALSE; if (pItem->iItem < 0) { return; } if (pItem->iSubItem == COL_NAME) { *pResult = TRUE; } } void CEditListEditor::OnDolabeleditList(NMHDR* pNMHDR, LRESULT* pResult) { LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR; LV_ITEM* pItem = &pDispInfo->item; *pResult = FALSE; if (pItem->iItem < 0) { return; } if (m_CurPos != NULL && pItem->iSubItem == COL_NAME) { CClip& CurClip = m_EditList.GetAt (m_CurPos); int nSel = FindNameIndex (CurClip.GetName()); CAtlList<CString> sl; for (int i=0; i<m_NameList.GetCount(); i++) { sl.AddTail(m_NameList.GetAt(i)); } m_list.ShowInPlaceComboBox(pItem->iItem, pItem->iSubItem, sl, nSel, true); *pResult = TRUE; } } void CEditListEditor::OnEndlabeleditList(NMHDR* pNMHDR, LRESULT* pResult) { LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR; LV_ITEM* pItem = &pDispInfo->item; *pResult = FALSE; if (!m_list.m_fInPlaceDirty) { return; } if (pItem->iItem < 0) { return; } CString& CurName = m_NameList.GetAt(pItem->lParam); if (m_CurPos != NULL && pItem->iSubItem == COL_NAME) { CClip& CurClip = m_EditList.GetAt (m_CurPos); CurClip.SetName(CurName); *pResult = TRUE; } } int CEditListEditor::FindNameIndex(LPCTSTR strName) { int nResult = -1; for (int i = 0; i<m_NameList.GetCount(); i++) { CString& CurName = m_NameList.GetAt(i); if (CurName == strName) { nResult = i; break; } } return nResult; } void CEditListEditor::FillCombo(LPCTSTR strFileName, CComboBox& Combo, bool bAllowNull) { CStdioFile NameFile; CString str; if (NameFile.Open (strFileName, CFile::modeRead)) { if (bAllowNull) { Combo.AddString(_T("")); } while (NameFile.ReadString(str)) { Combo.AddString(str); } NameFile.Close(); } } void CEditListEditor::SelectCombo(LPCTSTR strValue, CComboBox& Combo) { for (int i=0; i<Combo.GetCount(); i++) { CString strTemp; Combo.GetLBText(i, strTemp); if (strTemp == strValue) { Combo.SetCurSel(i); break; } } }
22.50365
128
0.69108
chinajeffery
95a359e0389511a9ef04afe8b0c37ab9c07567f2
1,801
cpp
C++
leetcode/ComboSumIV.cpp
tzaffi/cpp
43d99e70d8fa712f90ea0f6147774e4e0f2b11da
[ "MIT" ]
null
null
null
leetcode/ComboSumIV.cpp
tzaffi/cpp
43d99e70d8fa712f90ea0f6147774e4e0f2b11da
[ "MIT" ]
null
null
null
leetcode/ComboSumIV.cpp
tzaffi/cpp
43d99e70d8fa712f90ea0f6147774e4e0f2b11da
[ "MIT" ]
null
null
null
// // Created by zeph on 11/25/16. // /** * Combination Sum IV Difficulty: Medium Given an integer array with all positive numbers and no duplicates, find the number of possible combinations that add up to a positive integer target. Example: nums = [1, 2, 3] target = 4 The possible combination ways are: (1, 1, 1, 1) (1, 1, 2) (1, 2, 1) (1, 3) (2, 1, 1) (2, 2) (3, 1) Note that different sequences are counted as different combinations. Therefore the output is 7. Follow up: What if negative numbers are allowed in the given array? How does it change the problem? What limitation we need to add to the question to allow negative numbers? Credits: Special thanks to @pbrother for adding this problem and creating all test cases. */ #include <iostream> #include <vector> #include <cassert> #include <cmath> using namespace std; class Solution { public: int combinationSum4(vector<int>& nums, int target){ return bruteForce(nums, target); } private: int bruteForce(vector<int>& nums, int target){ int ans = 0; if (target <= 0){ return ans; } else if (find(nums.cbegin(), nums.cend(), target) != nums.cend()){ ans++; } for(auto& x: nums){ int newTarget = target - x; if( newTarget > 0 ){ ans += combinationSum4(nums, newTarget); } } return ans; } }; int main() { cout << "Combination Sums IV\n\n\n"; vector<int> nums = {1, 2, 3}; int target = 4; Solution s; int ans = s.combinationSum4(nums, target); cout << "got " << ans << " solutions\n\n"; assert(ans == 7); nums = {4,2,1}; target = 32; ans = s.combinationSum4(nums, target); cout << "got " << ans << " solutions\n\n"; return 0; }
21.963415
83
0.605219
tzaffi
95a3a88dfd385f25bc0715b90db46922bea8d373
5,625
cpp
C++
src/mongo/util/alarm.cpp
benety/mongo
203430ac9559f82ca01e3cbb3b0e09149fec0835
[ "Apache-2.0" ]
null
null
null
src/mongo/util/alarm.cpp
benety/mongo
203430ac9559f82ca01e3cbb3b0e09149fec0835
[ "Apache-2.0" ]
null
null
null
src/mongo/util/alarm.cpp
benety/mongo
203430ac9559f82ca01e3cbb3b0e09149fec0835
[ "Apache-2.0" ]
null
null
null
/** * Copyright (C) 2018-present MongoDB, Inc. * * This program is free software: you can redistribute it and/or modify * it under the terms of the Server Side Public License, version 1, * as published by MongoDB, Inc. * * 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 * Server Side Public License for more details. * * You should have received a copy of the Server Side Public License * along with this program. If not, see * <http://www.mongodb.com/licensing/server-side-public-license>. * * As a special exception, the copyright holders give permission to link the * code of portions of this program with the OpenSSL library under certain * conditions as described in each individual source file and distribute * linked combinations including the program with the OpenSSL library. You * must comply with the Server Side Public License in all respects for * all of the code used other than as permitted herein. If you modify file(s) * with this exception, you may extend this exception to your version of the * file(s), but you are not obligated to do so. If you do not wish to do so, * delete this exception statement from your version. If you delete this * exception statement from all source files in the program, then also delete * it in the license file. */ #include "mongo/platform/basic.h" #include "mongo/util/alarm.h" namespace mongo { class AlarmSchedulerPrecise::HandleImpl final : public AlarmScheduler::Handle, public std::enable_shared_from_this<AlarmSchedulerPrecise::HandleImpl> { public: HandleImpl(std::weak_ptr<AlarmSchedulerPrecise> service, AlarmSchedulerPrecise::AlarmMapIt it) : _service(std::move(service)), _myIt(std::move(it)) {} struct MakeEmptyHandle {}; explicit HandleImpl(MakeEmptyHandle) : _service(std::shared_ptr<AlarmSchedulerPrecise>(nullptr)), _myIt(), _done(true) {} Status cancel() override { auto service = _service.lock(); if (!service) { return {ErrorCodes::ShutdownInProgress, "The alarm scheduler was shutdown"}; } stdx::unique_lock<Latch> lk(service->_mutex); if (_done) { return {ErrorCodes::AlarmAlreadyFulfilled, "The alarm has already been canceled"}; } auto state = std::move(_myIt->second); service->_alarms.erase(_myIt); lk.unlock(); std::move(state.promise) .setError({ErrorCodes::CallbackCanceled, "The alarm was canceled before it expired or could be processed"}); return Status::OK(); } void setDone() { _done = true; } private: std::weak_ptr<AlarmSchedulerPrecise> const _service; AlarmSchedulerPrecise::AlarmMapIt _myIt; bool _done = false; }; AlarmSchedulerPrecise::~AlarmSchedulerPrecise() { clearAllAlarms(); } AlarmScheduler::Alarm AlarmSchedulerPrecise::alarmAt(Date_t date) { stdx::unique_lock<Latch> lk(_mutex); if (_shutdown) { Alarm ret; ret.future = Future<void>::makeReady( Status(ErrorCodes::ShutdownInProgress, "Alarm scheduler has been shut down.")); ret.handle = std::make_shared<HandleImpl>(HandleImpl::MakeEmptyHandle{}); return ret; } auto pf = makePromiseFuture<void>(); auto it = _alarms.emplace(date, AlarmData(std::move(pf.promise))); auto nextAlarm = _alarms.begin()->first; auto ret = std::make_shared<HandleImpl>(shared_from_this(), it); it->second.handle = ret; lk.unlock(); callRegisterHook(nextAlarm, shared_from_this()); return {std::move(pf.future), std::move(ret)}; } void AlarmSchedulerPrecise::processExpiredAlarms( boost::optional<AlarmScheduler::AlarmExpireHook> hook) { AlarmCount processed = 0; auto now = clockSource()->now(); std::vector<Promise<void>> toExpire; AlarmMapIt it; stdx::unique_lock<Latch> lk(_mutex); for (it = _alarms.begin(); it != _alarms.end();) { if (hook && !(*hook)(processed + 1)) { break; } if (it->first > now) { break; } processed++; toExpire.push_back(std::move(it->second.promise)); auto handle = it->second.handle.lock(); if (handle) { handle->setDone(); } it = _alarms.erase(it); } lk.unlock(); for (auto& promise : toExpire) { promise.emplaceValue(); } } Date_t AlarmSchedulerPrecise::nextAlarm() { stdx::lock_guard<Latch> lk(_mutex); return (_alarms.empty()) ? Date_t::max() : _alarms.begin()->first; } void AlarmSchedulerPrecise::clearAllAlarms() { stdx::unique_lock<Latch> lk(_mutex); _clearAllAlarmsImpl(lk); } void AlarmSchedulerPrecise::clearAllAlarmsAndShutdown() { stdx::unique_lock<Latch> lk(_mutex); _shutdown = true; _clearAllAlarmsImpl(lk); } void AlarmSchedulerPrecise::_clearAllAlarmsImpl(stdx::unique_lock<Latch>& lk) { std::vector<Promise<void>> toExpire; for (AlarmMapIt it = _alarms.begin(); it != _alarms.end();) { toExpire.push_back(std::move(it->second.promise)); auto handle = it->second.handle.lock(); if (handle) { handle->setDone(); } it = _alarms.erase(it); } lk.unlock(); for (auto& alarm : toExpire) { alarm.setError({ErrorCodes::CallbackCanceled, "Alarm scheduler was cleared"}); } } } // namespace mongo
32.894737
98
0.657244
benety
95ac5b8bf81d55048ebc62024c8209171266b8cd
7,064
cpp
C++
Nacro/SDK/FN_QuestUpdatesLog_functions.cpp
Milxnor/Nacro
eebabf662bbce6d5af41820ea0342d3567a0aecc
[ "BSD-2-Clause" ]
11
2021-08-08T23:25:10.000Z
2022-02-19T23:07:22.000Z
Nacro/SDK/FN_QuestUpdatesLog_functions.cpp
Milxnor/Nacro
eebabf662bbce6d5af41820ea0342d3567a0aecc
[ "BSD-2-Clause" ]
1
2022-01-01T22:51:59.000Z
2022-01-08T16:14:15.000Z
Nacro/SDK/FN_QuestUpdatesLog_functions.cpp
Milxnor/Nacro
eebabf662bbce6d5af41820ea0342d3567a0aecc
[ "BSD-2-Clause" ]
8
2021-08-09T13:51:54.000Z
2022-01-26T20:33:37.000Z
// Fortnite (1.8) SDK #ifdef _MSC_VER #pragma pack(push, 0x8) #endif #include "../SDK.hpp" namespace SDK { //--------------------------------------------------------------------------- //Functions //--------------------------------------------------------------------------- // Function QuestUpdatesLog.QuestUpdatesLog_C.CanDisplayAnotherObjective // (Public, HasOutParms, BlueprintCallable, BlueprintEvent, BlueprintPure) // Parameters: // bool Result (Parm, OutParm, ZeroConstructor, IsPlainOldData) void UQuestUpdatesLog_C::CanDisplayAnotherObjective(bool* Result) { static auto fn = UObject::FindObject<UFunction>("Function QuestUpdatesLog.QuestUpdatesLog_C.CanDisplayAnotherObjective"); UQuestUpdatesLog_C_CanDisplayAnotherObjective_Params params; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; if (Result != nullptr) *Result = params.Result; } // Function QuestUpdatesLog.QuestUpdatesLog_C.GetTotalDisplayedObjectives // (Public, HasOutParms, BlueprintCallable, BlueprintEvent, BlueprintPure) // Parameters: // int NumObjectives (Parm, OutParm, ZeroConstructor, IsPlainOldData) void UQuestUpdatesLog_C::GetTotalDisplayedObjectives(int* NumObjectives) { static auto fn = UObject::FindObject<UFunction>("Function QuestUpdatesLog.QuestUpdatesLog_C.GetTotalDisplayedObjectives"); UQuestUpdatesLog_C_GetTotalDisplayedObjectives_Params params; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; if (NumObjectives != nullptr) *NumObjectives = params.NumObjectives; } // Function QuestUpdatesLog.QuestUpdatesLog_C.CreateAnnouncementUpdate // (Public, HasDefaults, BlueprintCallable, BlueprintEvent) // Parameters: // struct FDynamicQuestUpdateInfo UpdateInfo (Parm) void UQuestUpdatesLog_C::CreateAnnouncementUpdate(const struct FDynamicQuestUpdateInfo& UpdateInfo) { static auto fn = UObject::FindObject<UFunction>("Function QuestUpdatesLog.QuestUpdatesLog_C.CreateAnnouncementUpdate"); UQuestUpdatesLog_C_CreateAnnouncementUpdate_Params params; params.UpdateInfo = UpdateInfo; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; } // Function QuestUpdatesLog.QuestUpdatesLog_C.HandleQuestUpdateWidgetFinished // (Public, HasDefaults, BlueprintCallable, BlueprintEvent) // Parameters: // class UQuestUpdateEntry_C* UpdateWidget (Parm, ZeroConstructor, IsPlainOldData) void UQuestUpdatesLog_C::HandleQuestUpdateWidgetFinished(class UQuestUpdateEntry_C* UpdateWidget) { static auto fn = UObject::FindObject<UFunction>("Function QuestUpdatesLog.QuestUpdatesLog_C.HandleQuestUpdateWidgetFinished"); UQuestUpdatesLog_C_HandleQuestUpdateWidgetFinished_Params params; params.UpdateWidget = UpdateWidget; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; } // Function QuestUpdatesLog.QuestUpdatesLog_C.GetAvailableQuestUpdateWidget // (Public, HasOutParms, BlueprintCallable, BlueprintEvent) // Parameters: // struct FDynamicQuestUpdateInfo UpdateInfo (Parm) // class UQuestUpdateEntry_C* AvailableWIdget (Parm, OutParm, ZeroConstructor, IsPlainOldData) void UQuestUpdatesLog_C::GetAvailableQuestUpdateWidget(const struct FDynamicQuestUpdateInfo& UpdateInfo, class UQuestUpdateEntry_C** AvailableWIdget) { static auto fn = UObject::FindObject<UFunction>("Function QuestUpdatesLog.QuestUpdatesLog_C.GetAvailableQuestUpdateWidget"); UQuestUpdatesLog_C_GetAvailableQuestUpdateWidget_Params params; params.UpdateInfo = UpdateInfo; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; if (AvailableWIdget != nullptr) *AvailableWIdget = params.AvailableWIdget; } // Function QuestUpdatesLog.QuestUpdatesLog_C.TryDisplayDynamicQuestStatusUpdate // (Public, HasDefaults, BlueprintCallable, BlueprintEvent) void UQuestUpdatesLog_C::TryDisplayDynamicQuestStatusUpdate() { static auto fn = UObject::FindObject<UFunction>("Function QuestUpdatesLog.QuestUpdatesLog_C.TryDisplayDynamicQuestStatusUpdate"); UQuestUpdatesLog_C_TryDisplayDynamicQuestStatusUpdate_Params params; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; } // Function QuestUpdatesLog.QuestUpdatesLog_C.CreateQuestUpdateWIdgets // (Public, BlueprintCallable, BlueprintEvent) void UQuestUpdatesLog_C::CreateQuestUpdateWIdgets() { static auto fn = UObject::FindObject<UFunction>("Function QuestUpdatesLog.QuestUpdatesLog_C.CreateQuestUpdateWIdgets"); UQuestUpdatesLog_C_CreateQuestUpdateWIdgets_Params params; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; } // Function QuestUpdatesLog.QuestUpdatesLog_C.HandleDisplayDynamicQuestUpdate // (Public, HasDefaults, BlueprintCallable, BlueprintEvent) // Parameters: // class UFortQuestObjectiveInfo* QuestObjective (Parm, ZeroConstructor, IsPlainOldData) // bool bDisplayStatusUpdate (Parm, ZeroConstructor, IsPlainOldData) // bool bDisplayAnnouncementUpdate (Parm, ZeroConstructor, IsPlainOldData) void UQuestUpdatesLog_C::HandleDisplayDynamicQuestUpdate(class UFortQuestObjectiveInfo* QuestObjective, bool bDisplayStatusUpdate, bool bDisplayAnnouncementUpdate) { static auto fn = UObject::FindObject<UFunction>("Function QuestUpdatesLog.QuestUpdatesLog_C.HandleDisplayDynamicQuestUpdate"); UQuestUpdatesLog_C_HandleDisplayDynamicQuestUpdate_Params params; params.QuestObjective = QuestObjective; params.bDisplayStatusUpdate = bDisplayStatusUpdate; params.bDisplayAnnouncementUpdate = bDisplayAnnouncementUpdate; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; } // Function QuestUpdatesLog.QuestUpdatesLog_C.Construct // (BlueprintCosmetic, Event, Public, BlueprintEvent) void UQuestUpdatesLog_C::Construct() { static auto fn = UObject::FindObject<UFunction>("Function QuestUpdatesLog.QuestUpdatesLog_C.Construct"); UQuestUpdatesLog_C_Construct_Params params; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; } // Function QuestUpdatesLog.QuestUpdatesLog_C.ExecuteUbergraph_QuestUpdatesLog // () // Parameters: // int EntryPoint (Parm, ZeroConstructor, IsPlainOldData) void UQuestUpdatesLog_C::ExecuteUbergraph_QuestUpdatesLog(int EntryPoint) { static auto fn = UObject::FindObject<UFunction>("Function QuestUpdatesLog.QuestUpdatesLog_C.ExecuteUbergraph_QuestUpdatesLog"); UQuestUpdatesLog_C_ExecuteUbergraph_QuestUpdatesLog_Params params; params.EntryPoint = EntryPoint; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; } } #ifdef _MSC_VER #pragma pack(pop) #endif
31.67713
163
0.76359
Milxnor
95afc1b5eb96e3c20a7a848421c691ce9c46a11a
12,766
cpp
C++
EXAMPLES/Controls/SingleInst/singleinstance.cpp
earthsiege2/borland-cpp-ide
09bcecc811841444338e81b9c9930c0e686f9530
[ "Unlicense", "FSFAP", "Apache-1.1" ]
1
2022-01-13T01:03:55.000Z
2022-01-13T01:03:55.000Z
EXAMPLES/Controls/SingleInst/singleinstance.cpp
earthsiege2/borland-cpp-ide
09bcecc811841444338e81b9c9930c0e686f9530
[ "Unlicense", "FSFAP", "Apache-1.1" ]
null
null
null
EXAMPLES/Controls/SingleInst/singleinstance.cpp
earthsiege2/borland-cpp-ide
09bcecc811841444338e81b9c9930c0e686f9530
[ "Unlicense", "FSFAP", "Apache-1.1" ]
null
null
null
//--------------------------------------------------------------------------- #include <vcl.h> #pragma hdrstop #define NDEBUG #include <cassert> #include "SingleInstance.h" #pragma package(smart_init) //--------------------------------------------------------------------------- // ValidCtrCheck is used to assure that the components created do not have // any pure virtual functions. // static inline void ValidCtrCheck(TSingleAppInstance *) { new TSingleAppInstance(NULL); } //--------------------------------------------------------------------------- // We introduce a global boolean to serve as // a marker. If a component is "activated" // to serve as a single instance guarantee, // we flag this here. // This provides a mechanism that prevents // more than a single component from getting // active at any time. // This is extremely important in those cases // where the user might accidentally instatiate // a second copy of the component in *the same* // process. // Alert: as with all global variables this // is NOT thread-safe. bool SingleAppInstanceComponentActive = false; //--------------------------------------------------------------------------- void __fastcall TSingleAppInstance::AssertValidMarkerText(const String& Value) { int Len; // Note the Windows API documentation: // "The name can contain any character except the backslash character (\)" Len = Value.Length(); for (int i = 1; i <= Len; ++i) { if (Value[i] == '\\') { throw Exception("A marker may not contain the '\\' character"); } } } bool __fastcall TSingleAppInstance::IsValidMarkerText(const String& Value) { int Len; bool IsValid; // Note the Windows API documentation: // "The name can contain any character except the backslash character (\)" IsValid = true; Len = Value.Length(); for (int i = 1; i <= Len; ++i) { if (Value[i] == '\\') { IsValid = false; break; } } return IsValid; } String __fastcall TSingleAppInstance::TranslateSlashes(const String& Value) { // Since slashes are not allowed in certain // strings (see above), provide an internal // mapping that replaces these slashes with // something else. const char ReplacementCharacter = '_'; int Len; String Result; Result = Value; Len = Result.Length(); for (int i = 1; i <= Len; ++i) { if (Result[i] == '\\') { Result[i] = ReplacementCharacter; } } return Result; } //--------------------------------------------------------------------------- // We are storing some data in the marking // memory-mapped file. The following struct // makes the data structure reasonably opaque. struct MappedData { HANDLE FirstInstanceHandle; }; typedef MappedData* PMappedData; //--------------------------------------------------------------------------- __fastcall TSingleAppInstance::TSingleAppInstance(TComponent* Owner) : TComponent(Owner) { InitializeCriticalSection(&FWndProcCriticalSection); FHiddenWindow = AllocateHWnd(LocalWinProc); FPassCommandLine = true; // If we are loaded as part of a stream, // set Enabled = true - the default streaming // value specified in the property declaration. // // If this is not the case, it is very likely // that the user manually instantiates the // component. Start disabled then and allow // (rather: force) the user to assign events // and only then enable the component. FEnabled = true; FEnabled = (Owner != NULL) && Owner->ComponentState.Contains(csLoading); } __fastcall TSingleAppInstance::~TSingleAppInstance(void) { ReleaseInternalMapFile(); DeleteCriticalSection(&FWndProcCriticalSection); DeallocateHWnd(FHiddenWindow); FHiddenWindow = INVALID_HANDLE_VALUE; delete[] FPassedCommandLine; FPassedCommandLine = NULL; } void __fastcall TSingleAppInstance::DoOnSecondInstance(bool& DoTerminate) { if (FOnSecondInstance != NULL) FOnSecondInstance(this, DoTerminate); } void __fastcall TSingleAppInstance::Loaded(void) { inherited::Loaded(); if (!ComponentState.Contains(csDesigning)) { if (SingleAppInstanceComponentActive) { // In case an instance is already active, // we simply unconditionally set FEnabled // to false. if (FEnabled) FEnabled = false; } else { PerformSingletonCode(); } } } void __fastcall TSingleAppInstance::LocalWinProc(Messages::TMessage &Message) { if (Message.Msg != WM_COPYDATA) { Message.Result = DefWindowProc(FHiddenWindow, Message.Msg, Message.WParam, Message.LParam); } else { DWORD CountData; PCOPYDATASTRUCT PassedCopyDataStruct; // We need to be left alone for a moment, // so lock everyone out of this code sequence. // // Design issue: // // This piece of code will BLOCK the SENDING // application until we have made our call // to ReplyMessage below. // This means that if multiple "single-instance" // processes are launched roughly at the same // time ALL these processes will block at the // same time. // The provided critical section should guarantee, // though, that we have a nice, serialized access. // (no mutex, since we stay inside the same process) EnterCriticalSection(&FWndProcCriticalSection); try { if (FPassedCommandLine != NULL) { delete[] FPassedCommandLine; FPassedCommandLine = NULL; } assert(Message.LParam != NULL); PassedCopyDataStruct = reinterpret_cast<COPYDATASTRUCT*>(Message.LParam); // We copy the passed command-line to a local // buffer in order to be able to return to the // calling application as soon as possible, // without it waiting for us to process the data. CountData = PassedCopyDataStruct->cbData; if (CountData > 0) { FPassedCommandLine = new char[CountData]; if (PassedCopyDataStruct->lpData != NULL) memmove(FPassedCommandLine, PassedCopyDataStruct->lpData, CountData); } FPassedData = PassedCopyDataStruct->dwData; // Fine, so we have the data let the other process // off the SendMessage "hook" (metaphorically speaking). Win32Check( ReplyMessage(true) ); DoReceiveCommandLine(FPassedCommandLine); } __finally { LeaveCriticalSection(&FWndProcCriticalSection); } } } void __fastcall TSingleAppInstance::DoReceiveCommandLine(const char * const CommandLine) { if (FOnReceiveCommandLine != NULL) { FOnReceiveCommandLine(this, FPassedCommandLine); } } // Return true if the memory mapped file was successfully created; // false if this was not done. bool __fastcall TSingleAppInstance::CreateInternalMapFile(void) { LPVOID MapView; bool CreateResult; DWORD LastErrorCode; CreateResult = false; assert(FMappingObject == NULL); FMappingObject = CreateFileMapping( reinterpret_cast<HANDLE>(0xFFFFFFFF), NULL, PAGE_READWRITE | SEC_COMMIT, 0, sizeof(MappedData), FMarker.c_str() ); if (FMappingObject == NULL) RaiseLastWin32Error(); LastErrorCode = GetLastError(); if (LastErrorCode == ERROR_ALREADY_EXISTS) { // Whoops. Somebody already has created this memory mapped file. // Do nothing; CreateResult has the right value // already and will signal that the memory mapped file // (and thus the marker) already existed. // TODO: Is this the right thing to do? Return with false? Or throw an exception? } else { MapView = MapViewOfFile(FMappingObject, FILE_MAP_ALL_ACCESS, 0, 0, 0); if (MapView == NULL) RaiseLastWin32Error(); try { assert(FHiddenWindow != INVALID_HANDLE_VALUE); static_cast<PMappedData>(MapView)->FirstInstanceHandle = FHiddenWindow; } __finally { Win32Check( UnmapViewOfFile(MapView) ); } CreateResult = true; } return CreateResult; } void __fastcall TSingleAppInstance::ReleaseInternalMapFile(void) { if (FMappingObject != NULL) { Win32Check( CloseHandle(FMappingObject) ); FMappingObject = NULL; } } void __fastcall TSingleAppInstance::PerformSingletonCode(void) { if (FEnabled) { // It is pretty pointless to have an empty marker. // Use a default marker (i.e. the name of the executable) // if we are in dire need of one. if (FMarker.Length() == 0) { // Note that we have to translate backslashes ('\') // into something else (here: underscores ('_')) // as the Windows API does not allow names for // memory mapped files that contain backslashes. // And we use the creating process's name // as the "default" marker which definitely does // contain backslashes. SetMarker(TranslateSlashes(ParamStr(0))); } if (CreateInternalMapFile()) { SingleAppInstanceComponentActive = true; } else { // The memory mapped file already existed. TakeSecondInstanceAction(); } } else { ReleaseInternalMapFile(); } } void __fastcall TSingleAppInstance::PassThisInstanceCommandLine(void) { HANDLE FileMapping; LPVOID MapView; HANDLE FirstInstance; // Before sending over the command line, we need to // retrieve the handle from the present memory-mapped // file. FileMapping = OpenFileMapping(FILE_MAP_READ, false, FMarker.c_str()); if (FileMapping == NULL) RaiseLastWin32Error(); try { MapView = MapViewOfFile(FileMapping, FILE_MAP_READ, 0, 0, 0); if (MapView == NULL) RaiseLastWin32Error(); try { FirstInstance = static_cast<PMappedData>(MapView)->FirstInstanceHandle; } __finally { Win32Check( UnmapViewOfFile(MapView) ); } } __finally { Win32Check( CloseHandle(FileMapping) ); } // Now we pass on our command-line. Note that we must // use SendMessage in combination with WM_COPYDATA; only // then does the Win32 kernel marshal the data across // process boundaries. COPYDATASTRUCT CopyData = { 0, strlen(CmdLine) + sizeof(char), CmdLine }; // We don't bother about a return value... SendMessage( FirstInstance, WM_COPYDATA, reinterpret_cast<WPARAM>(FHiddenWindow), reinterpret_cast<LPARAM>(&CopyData)); } void __fastcall TSingleAppInstance::TakeSecondInstanceAction(void) { bool TerminateApplication; // Send command line to other application if this is desired. if (FPassCommandLine) PassThisInstanceCommandLine(); // Fire the event for this application, "notifying" // it that there is something else. // By default, terminate the application. TerminateApplication = true; if (FOnSecondInstance != NULL) { FOnSecondInstance(this, TerminateApplication); } if (TerminateApplication) Application->Terminate(); } void __fastcall TSingleAppInstance::SetEnabled(const bool Value) { if (Value != FEnabled) { // Is there an attempt to enable a second // instance of the component at runtime? // We cannot allow this to pass through, // as there can be only one entry point // for command line parameter messages. if (SingleAppInstanceComponentActive && Value /* == true */ && !ComponentState.Contains(csDesigning)) { // TODO: Possibly throw an exception here? /* AnsiString ExceptionMessage; ExceptionMessage.sprintf( "Only one instance of %s may be active at a time", AnsiString(this->ClassName()).c_str() ); throw Exception(ExceptionMessage); */ return; } FEnabled = Value; // We only react to changes in the Enabled // state if // a) this happens at runtime (!csDesigning) // b) the component data is not streaming // [because for *streaming*, we use the Loaded // method which is a tad bit better.] if (!ComponentState.Contains(csDesigning) && !ComponentState.Contains(csReading)) { PerformSingletonCode(); } } } void __fastcall TSingleAppInstance::SetMarker(const String Value) { if (Value != FMarker) { AssertValidMarkerText(Value); FMarker = Value; } }
26.819328
96
0.624315
earthsiege2
95aff5bb20c5b67c58315b74f1a3c25b255d2b2f
996
hpp
C++
library/ATF/_attack_selfdestruction_result_zoclInfo.hpp
lemkova/Yorozuya
f445d800078d9aba5de28f122cedfa03f26a38e4
[ "MIT" ]
29
2017-07-01T23:08:31.000Z
2022-02-19T10:22:45.000Z
library/ATF/_attack_selfdestruction_result_zoclInfo.hpp
kotopes/Yorozuya
605c97d3a627a8f6545cc09f2a1b0a8afdedd33a
[ "MIT" ]
90
2017-10-18T21:24:51.000Z
2019-06-06T02:30:33.000Z
library/ATF/_attack_selfdestruction_result_zoclInfo.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 <_attack_selfdestruction_result_zocl.hpp> START_ATF_NAMESPACE namespace Info { using _attack_selfdestruction_result_zoclctor__attack_selfdestruction_result_zocl2_ptr = void (WINAPIV*)(struct _attack_selfdestruction_result_zocl*); using _attack_selfdestruction_result_zoclctor__attack_selfdestruction_result_zocl2_clbk = void (WINAPIV*)(struct _attack_selfdestruction_result_zocl*, _attack_selfdestruction_result_zoclctor__attack_selfdestruction_result_zocl2_ptr); using _attack_selfdestruction_result_zoclsize4_ptr = int (WINAPIV*)(struct _attack_selfdestruction_result_zocl*); using _attack_selfdestruction_result_zoclsize4_clbk = int (WINAPIV*)(struct _attack_selfdestruction_result_zocl*, _attack_selfdestruction_result_zoclsize4_ptr); }; // end namespace Info END_ATF_NAMESPACE
55.333333
241
0.828313
lemkova
95b10c3e682f252f91eb832efa205268280b326f
3,264
cpp
C++
NativePlugin/CaptainAsteroid/src/physics/Game.cpp
axoloto/CaptainAsteroid
fcdcb6bc6987ecf53226daa7027116e40d74401a
[ "Apache-2.0" ]
null
null
null
NativePlugin/CaptainAsteroid/src/physics/Game.cpp
axoloto/CaptainAsteroid
fcdcb6bc6987ecf53226daa7027116e40d74401a
[ "Apache-2.0" ]
null
null
null
NativePlugin/CaptainAsteroid/src/physics/Game.cpp
axoloto/CaptainAsteroid
fcdcb6bc6987ecf53226daa7027116e40d74401a
[ "Apache-2.0" ]
null
null
null
#include "Game.hpp" #include "Logging.hpp" #include "systems/ControlByPlayer.hpp" #include "systems/Move.hpp" #include "systems/Collide.hpp" #include "systems/FireLaser.hpp" #include "systems/ReduceLifeTime.hpp" #include "systems/SplitAsteroid.hpp" #include "systems/RemoveDead.hpp" #include "components/Motion.hpp" #include "components/Position.hpp" #include "components/PlayerControl.hpp" #include "components/Laser.hpp" #include "events/PlayGame.hpp" namespace CaptainAsteroidCPP { Game::Game() : m_eventManager(), m_entityManager(m_eventManager), m_systemManager(m_entityManager, m_eventManager), m_gameManager(m_entityManager, m_eventManager), m_spaceShip(m_entityManager), m_asteroidField(m_entityManager, m_eventManager), m_laserShots(m_entityManager) { Utils::InitializeLogger(); LOG_INFO("Game Created"); } void Game::init(Def::InitParams initParams) { m_gameManager.init(); m_spaceShip.init(); m_asteroidField.init(initParams); createSystems(initParams.boundaryDomainV, initParams.boundaryDomainH); m_eventManager.emit<Ev::PlayGame>(); LOG_INFO("Game Initialized"); } void Game::createSystems(float boundaryV, float boundaryH) { m_systemManager.add<Sys::ControlByPlayer>(); m_systemManager.add<Sys::Move>(boundaryV, boundaryH); m_systemManager.add<Sys::Collide>(); m_systemManager.add<Sys::FireLaser>(m_laserShots); m_systemManager.add<Sys::ReduceLifeTime>(); m_systemManager.add<Sys::SplitAsteroid>(m_asteroidField); m_systemManager.add<Sys::RemoveDead>(m_asteroidField, m_laserShots); m_systemManager.configure(); LOG_INFO("DOD Systems Initialized"); } void Game::update(Def::KeyState keyState, float deltaTime) { m_eventManager.emit<Ev::PlayerInput>(keyState); if (m_gameManager.isGameRunning()) { m_systemManager.update<Sys::ControlByPlayer>(deltaTime); m_systemManager.update<Sys::Move>(deltaTime); m_systemManager.update<Sys::Collide>(deltaTime); m_systemManager.update<Sys::FireLaser>(deltaTime); m_systemManager.update<Sys::ReduceLifeTime>(deltaTime); m_systemManager.update<Sys::SplitAsteroid>(deltaTime); m_systemManager.update<Sys::RemoveDead>(deltaTime); } } void Game::getSpaceShipCoords(float &x, float &y, float &angle) const { const std::array<float, 3> coordsAndRot = m_spaceShip.getPosAndDir(); x = coordsAndRot[0]; y = coordsAndRot[1]; angle = coordsAndRot[2]; } void Game::fillPosEntityList(float *posEntities, int size, int *nbEntities, Def::EntityType entityType) const { if (entityType & Def::EntityType::Asteroid_XXL || entityType & Def::EntityType::Asteroid_M || entityType & Def::EntityType::Asteroid_S) { m_asteroidField.fillPosEntityList(posEntities, size, nbEntities, entityType); } else if (entityType & Def::EntityType::LaserShot) { m_laserShots.fillPosEntityList(posEntities, size, nbEntities, entityType); } } Def::GameState Game::currentGameState() const { return m_gameManager.gameState(); } std::int32_t Game::currentScore() const { return m_gameManager.score(); } std::int32_t Game::currentNbAsteroids() const { return m_asteroidField.totalNbAsteroids(); } }// namespace CaptainAsteroidCPP
27.897436
109
0.739583
axoloto
95b24eb6996724fd198d8985c5323221ad48343b
1,240
cpp
C++
dep/include/yse/synth/synthManager.cpp
ChrSacher/MyEngine
8fe71fd9e84b9536148e0d4ebb4e53751ab49ce8
[ "Apache-2.0" ]
2
2015-10-27T21:36:59.000Z
2017-03-17T21:52:19.000Z
dep/include/yse/synth/synthManager.cpp
ChrSacher/MyEngine
8fe71fd9e84b9536148e0d4ebb4e53751ab49ce8
[ "Apache-2.0" ]
null
null
null
dep/include/yse/synth/synthManager.cpp
ChrSacher/MyEngine
8fe71fd9e84b9536148e0d4ebb4e53751ab49ce8
[ "Apache-2.0" ]
null
null
null
/* ============================================================================== synthManager.cpp Created: 6 Jul 2014 10:01:40pm Author: yvan ============================================================================== */ #include "synthManager.h" #include "../internalHeaders.h" YSE::SYNTH::managerObject & YSE::SYNTH::Manager() { static managerObject m; return m; } YSE::SYNTH::implementationObject * YSE::SYNTH::managerObject::addImplementation(YSE::SYNTH::interfaceObject * head) { implementations.emplace_front(head); return &implementations.front(); } void YSE::SYNTH::managerObject::update() { bool remove = false; for (auto i = implementations.begin(); i != implementations.end(); ++i) { if (!(*i).sync()) { remove = true; } } // I assume that removing a synth happens not very often. So it's // faster to do a second run if this is the case, instead of updating // 2 iterators all the time if (remove) { auto previous = implementations.before_begin(); for (auto i = implementations.begin(); i != implementations.end(); ++i) { if (!(*i).hasInterface()) { implementations.erase_after(previous); return; } previous++; } } }
27.555556
117
0.560484
ChrSacher
95b3726da577384740325b9d5cb46370d37a5f58
789
cpp
C++
Applications/cli/commands/less.cpp
mschwartz/amos
345a4f8f52b9805722c10ac4cedb24b480fe2dc7
[ "MIT" ]
4
2020-08-18T00:11:09.000Z
2021-04-05T11:16:32.000Z
Applications/cli/commands/less.cpp
mschwartz/amos
345a4f8f52b9805722c10ac4cedb24b480fe2dc7
[ "MIT" ]
1
2020-08-15T20:39:13.000Z
2020-08-15T20:39:13.000Z
Applications/cli/commands/less.cpp
mschwartz/amos
345a4f8f52b9805722c10ac4cedb24b480fe2dc7
[ "MIT" ]
null
null
null
#include "commands.hpp" TInt64 CliTask::command_less(TInt ac, char **av) { if (ac != 2) { return Error("%s requires 1 argument", av[0]); } FileDescriptor *fd; fd = OpenFile(av[1]); if (!fd) { return Error("Could not open %s", av[1]); } else { char buf[512]; TInt count = 0; for (;;) { TUint64 actual = ReadFile(fd, buf, 512); if (actual == 0) { break; } // TODO: count lines, use mWindow console height (rows) for (TUint64 x = 0; x < actual; x++) { if (buf[x] == '\n') { mWindow->Write(buf[x]); count++; if (count >= mWindow->Rows()) { count = 0; } } else { mWindow->Write(buf[x]); } } } CloseFile(fd); } return 0; }
20.230769
61
0.47275
mschwartz
95b556d3ea0b81e90c7fa3021b1864eca830ff22
1,346
hpp
C++
siar_driver/include/siar_driver/arm_firewall.hpp
robotics-upo/siar_packages
2b9b3e7acbc9bc5845b03d63eb18dbc50bfd3c98
[ "BSD-3-Clause" ]
3
2020-02-06T13:36:38.000Z
2020-11-10T08:52:23.000Z
siar_driver/include/siar_driver/arm_firewall.hpp
robotics-upo/siar_packages
2b9b3e7acbc9bc5845b03d63eb18dbc50bfd3c98
[ "BSD-3-Clause" ]
null
null
null
siar_driver/include/siar_driver/arm_firewall.hpp
robotics-upo/siar_packages
2b9b3e7acbc9bc5845b03d63eb18dbc50bfd3c98
[ "BSD-3-Clause" ]
2
2017-03-20T16:08:37.000Z
2018-04-22T04:26:12.000Z
#ifndef __ARM_FIREWALL_HPP__ #define __ARM_FIREWALL_HPP__ #include "ros/ros.h" #include "siar_driver/SiarArmCommand.h" #include "siar_driver/SiarStatus.h" #include <boost/array.hpp> class ArmFirewall { public: static bool checkJointLimits(const boost::array<int16_t, 5> joint_values) { bool ret_val = (joint_values[0]<805 && joint_values[0]>208); ret_val &= (joint_values[1]<1568 && joint_values[1]>220); ret_val &= (joint_values[2]<2020 && joint_values[2]>191); // Limits from the Arm Reference Value spreadsheet of Carlos Marques ret_val &= (joint_values[3]<958 && joint_values[3]>30); ret_val &= (joint_values[4]<1000 && joint_values[4]>30); return ret_val; } static bool checkTemperatureAndStatus(const boost::array<uint8_t,5> &herculex_temperature, const boost::array<uint8_t,5> &herculex_status) { bool ret_val = true; for(int i = 0; i < 5; i++) { if (herculex_temperature[i]<0 && herculex_temperature[i]>50) { ROS_ERROR("TEMPERATURE OF THE %d LINK IS OUT OF RANGE: %d", i, herculex_temperature[i]); ret_val = false; } // if (herculex_status[i]!=1) // TODO: Check this!! // { // ROS_ERROR("%d LINK STATUS: %d", i, herculex_status[i]); // ret_val = false; // } } return ret_val; } }; #endif
25.884615
142
0.643388
robotics-upo
95c08918687ae80cd970c1829c9e0d39c02ad59a
2,210
cpp
C++
FrameworkLib/DX11VertApi.cpp
DashW/Ingenuity
f7944a9e8063beaa3dda31e8372d18b4147782e2
[ "Zlib" ]
null
null
null
FrameworkLib/DX11VertApi.cpp
DashW/Ingenuity
f7944a9e8063beaa3dda31e8372d18b4147782e2
[ "Zlib" ]
null
null
null
FrameworkLib/DX11VertApi.cpp
DashW/Ingenuity
f7944a9e8063beaa3dda31e8372d18b4147782e2
[ "Zlib" ]
null
null
null
#include "stdafx.h" #include "DX11VertApi.h" #ifdef USE_DX11_GPUAPI ID3D11InputLayout* DX11Vertex_Pos::inputLayout = 0; ID3D11InputLayout* DX11Vertex_PosCol::inputLayout = 0; ID3D11InputLayout* DX11Vertex_PosNor::inputLayout = 0; ID3D11InputLayout* DX11Vertex_PosNorTex::inputLayout = 0; bool DX11_VertApi::InitInputLayout(VertexType type, ID3D11Device* device, const void* shaderBytecode, SIZE_T bytecodeLength){ switch(type) { case VertexType_Pos: return DX11Vertex_Pos::initInputLayout(device,shaderBytecode,bytecodeLength); case VertexType_PosCol: return DX11Vertex_PosCol::initInputLayout(device,shaderBytecode,bytecodeLength); case VertexType_PosNor: return DX11Vertex_PosNor::initInputLayout(device,shaderBytecode,bytecodeLength); case VertexType_PosNorTex: return DX11Vertex_PosNorTex::initInputLayout(device,shaderBytecode,bytecodeLength); default: OutputDebugString(L"Could not initialise unrecognized vertex type\n"); return false; } } void DX11_VertApi::ReleaseVertices(){ if(DX11Vertex_Pos::inputLayout) DX11Vertex_Pos::inputLayout->Release(); if(DX11Vertex_PosCol::inputLayout) DX11Vertex_PosCol::inputLayout->Release(); if(DX11Vertex_PosNor::inputLayout) DX11Vertex_PosNor::inputLayout->Release(); if(DX11Vertex_PosNorTex::inputLayout) DX11Vertex_PosNorTex::inputLayout->Release(); } ID3D11InputLayout* DX11_VertApi::GetInputLayout(VertexType type) { switch(type) { case VertexType_Pos: return DX11Vertex_Pos::inputLayout; case VertexType_PosCol: return DX11Vertex_PosCol::inputLayout; case VertexType_PosNor: return DX11Vertex_PosNor::inputLayout; case VertexType_PosNorTex: return DX11Vertex_PosNorTex::inputLayout; default: //OutputDebugString(L"Could not get declaration of unrecognized vertex type\n"); return 0; } } unsigned DX11_VertApi::GetSize(VertexType type) { switch(type) { case VertexType_Pos: return sizeof(DX11Vertex_Pos); case VertexType_PosCol: return sizeof(DX11Vertex_PosCol); case VertexType_PosNor: return sizeof(DX11Vertex_PosNor); case VertexType_PosNorTex: return sizeof(DX11Vertex_PosNorTex); default: //OutputDebugString(L"Could not get size of unrecognized vertex type\n"); return 0; } } #endif
32.028986
85
0.808597
DashW
95c156ec977b003837947dd71df125dc1385831e
2,106
cpp
C++
cci/graph.cpp
vino-ebe/int-pgms
124e63d46092bd974d44afe67bd17727892afefa
[ "BSD-2-Clause" ]
null
null
null
cci/graph.cpp
vino-ebe/int-pgms
124e63d46092bd974d44afe67bd17727892afefa
[ "BSD-2-Clause" ]
null
null
null
cci/graph.cpp
vino-ebe/int-pgms
124e63d46092bd974d44afe67bd17727892afefa
[ "BSD-2-Clause" ]
null
null
null
#include<iostream> using namespace std; struct graphNode { int vertex; struct graphNode* next; }; class graph { private: static const int NUM_VERTEX = 10; graphNode* V[NUM_VERTEX]; int numEdges[NUM_VERTEX]; bool visited[NUM_VERTEX]; graphNode* createNode(int vertex) { graphNode *temp = new graphNode(); temp->vertex = vertex; temp->next = NULL; return temp; } public: graph() { for (int i = 0; i < NUM_VERTEX; i++) { V[i] = NULL; numEdges[i] = 0; visited = false; } } void addEdge(int fromVertex, int toVertex) { if (!V[fromVertex]) { V[fromVertex] = createNode(fromVertex); } graphNode* temp = createNode(toVertex); temp->next = V[fromVertex]->next; V[fromVertex]->next = temp; } void printGraph() { graphNode *temp = NULL; for (int i = 0; i < NUM_VERTEX; i++) { temp = V[i]; if (temp) { cout<<"Vertex ["<<i<<"] --->"; while (temp) { cout<<temp->vertex; temp = temp->next; cout<<"--->"; } } cout<<endl; } } bool routeExist(int vertex1, int vertex2) { graphNode* temp = V[vertex1]; while (temp) { if (temp->vertex == vertex2) { return true; } temp = temp->next; } return false; } }; int main() { graph g; g.addEdge(1,2); g.addEdge(1,3); g.addEdge(2,1); g.addEdge(2,3); g.addEdge(3,1); g.addEdge(3,2); g.addEdge(3,4); g.addEdge(4,3); g.printGraph(); if (g.routeExist(3,5)) { cout<<"Route Exist"<<endl; } else { cout<<"Route does not exist"<<endl; } }
22.645161
55
0.420228
vino-ebe
95c32850a295113d071f24e4730031c3f0412056
2,712
cpp
C++
LinkDelay/LinkDelay.cpp
kravitz/transims4
ea0848bf3dc71440d54724bb3ecba3947b982215
[ "NASA-1.3" ]
2
2018-04-27T11:07:02.000Z
2020-04-24T06:53:21.000Z
LinkDelay/LinkDelay.cpp
idkravitz/transims4
ea0848bf3dc71440d54724bb3ecba3947b982215
[ "NASA-1.3" ]
null
null
null
LinkDelay/LinkDelay.cpp
idkravitz/transims4
ea0848bf3dc71440d54724bb3ecba3947b982215
[ "NASA-1.3" ]
null
null
null
//********************************************************* // LinkDelay.cpp - manipulate the link delay file //********************************************************* #include "LinkDelay.hpp" char * LinkDelay::PREVIOUS_LINK_DELAY_FILE = "PREVIOUS_LINK_DELAY_FILE"; char * LinkDelay::PREVIOUS_LINK_DELAY_FORMAT = "PREVIOUS_LINK_DELAY_FORMAT"; char * LinkDelay::PREVIOUS_WEIGHTING_FACTOR = "PREVIOUS_WEIGHTING_FACTOR"; char * LinkDelay::PREVIOUS_LINK_FILE = "PREVIOUS_LINK_FILE"; char * LinkDelay::TIME_OF_DAY_FORMAT = "TIME_OF_DAY_FORMAT"; char * LinkDelay::PROCESSING_METHOD = "PROCESSING_METHOD"; char * LinkDelay::SMOOTH_GROUP_SIZE = "SMOOTH_GROUP_SIZE"; char * LinkDelay::PERCENT_MOVED_FORWARD = "PERCENT_MOVED_FORWARD"; char * LinkDelay::PERCENT_MOVED_BACKWARD = "PERCENT_MOVED_BACKWARD"; char * LinkDelay::NUMBER_OF_ITERATIONS = "NUMBER_OF_ITERATIONS"; char * LinkDelay::CIRCULAR_GROUP_FLAG = "CIRCULAR_GROUP_FLAG"; char * LinkDelay::TIME_PERIOD_SORT = "TIME_PERIOD_SORT"; //--------------------------------------------------------- // LinkDelay constructor //--------------------------------------------------------- LinkDelay::LinkDelay (void) : Demand_Service () { Program ("LinkDelay"); Version ("4.0.11"); Title ("Manipulate the Link Delay File"); Network_File required_network [] = { LINK, END_NETWORK }; Network_File optional_network [] = { DIRECTORY, LANE_CONNECTIVITY, END_NETWORK }; Demand_File required_demand [] = { NEW_LINK_DELAY, END_DEMAND }; Demand_File optional_demand [] = { LINK_DELAY, END_DEMAND }; char *keys [] = { PREVIOUS_LINK_DELAY_FILE, PREVIOUS_LINK_DELAY_FORMAT, PREVIOUS_WEIGHTING_FACTOR, PREVIOUS_LINK_FILE, PROCESSING_METHOD, SMOOTH_GROUP_SIZE, PERCENT_MOVED_FORWARD, PERCENT_MOVED_BACKWARD, NUMBER_OF_ITERATIONS, CIRCULAR_GROUP_FLAG, TIME_PERIOD_SORT, NULL }; Key_List (keys); Required_Network_Files (required_network); Optional_Network_Files (optional_network); Required_Demand_Files (required_demand); Optional_Demand_Files (optional_demand); previous_flag = link_flag = false; method = SIMPLE_AVERAGE; factor = 1.0; nerror = 0; niter = 3; naverage = 3; forward = 20.0; backward = 20.0; loop_flag = true; sort_flag = false; } //--------------------------------------------------------- // LinkDelay destructor //--------------------------------------------------------- LinkDelay::~LinkDelay (void) { } //--------------------------------------------------------- // main program //--------------------------------------------------------- int main (int commands, char *control []) { LinkDelay *exe = new LinkDelay (); return (exe->Start_Execution (commands, control)); }
28.25
76
0.620575
kravitz
95c41364396c72ef419b126279ffe3586e0ae5df
475
cpp
C++
Train/T.cpp
dangercard/Uva_Challenges
735bf80da5d1995fece4614d38174d1ea276e7c2
[ "Apache-2.0" ]
null
null
null
Train/T.cpp
dangercard/Uva_Challenges
735bf80da5d1995fece4614d38174d1ea276e7c2
[ "Apache-2.0" ]
null
null
null
Train/T.cpp
dangercard/Uva_Challenges
735bf80da5d1995fece4614d38174d1ea276e7c2
[ "Apache-2.0" ]
null
null
null
#include <iostream> #include <stack> #include <string> using namespace std ; int main() { string stI, stO ; int j = 0 ; cin >> stI ; cin >> stO ; stack <char> S ; // S.push(stI[0]) ; for(int i = 0; i < stI.length() ; i++) { if(stO[j] == S.top()) { S.pop() ; j++ ; } else { S.push(stI[i]) ; } } if(S.empty()) { cout << "True" << endl ; } else { cout << "False" << endl ; } return 0 ; }
11.046512
40
0.427368
dangercard
95ca8f857cc1908926568a8676fa040c1de51f9e
212
cpp
C++
dataStructure/sort/insert.cpp
jinbooooom/coding-for-interview
4164a3c7ddc19a61fa58aebefff29620029ac42c
[ "MIT" ]
8
2019-08-21T10:57:29.000Z
2019-10-14T03:35:22.000Z
dataStructure/sort/insert.cpp
jinbooooom/coding-for-interview
4164a3c7ddc19a61fa58aebefff29620029ac42c
[ "MIT" ]
null
null
null
dataStructure/sort/insert.cpp
jinbooooom/coding-for-interview
4164a3c7ddc19a61fa58aebefff29620029ac42c
[ "MIT" ]
null
null
null
void insert(int *arr, int len) { int i, j, t; for (i = 1; i < len; ++i) // 从第二个数开始(索引1),一共 len - 1 轮 { t = arr[i]; for (j = i - 1; j >= 0 && t < arr[j]; --j) arr[j + 1] = arr[j]; arr[j + 1] = t; } }
19.272727
56
0.419811
jinbooooom
95cbec5d7d2291e6f2b109179f40f62aa22c908a
623
cpp
C++
USACO Bronze/December 2016 Contest/cowsignal.cpp
Alecs-Li/Competitive-Programming
39941ff8e2c8994abbae8c96a1ed0a04b10058b8
[ "MIT" ]
1
2021-07-06T02:14:03.000Z
2021-07-06T02:14:03.000Z
USACO Bronze/December 2016 Contest/cowsignal.cpp
Alex01890-creator/competitive-programming
39941ff8e2c8994abbae8c96a1ed0a04b10058b8
[ "MIT" ]
null
null
null
USACO Bronze/December 2016 Contest/cowsignal.cpp
Alex01890-creator/competitive-programming
39941ff8e2c8994abbae8c96a1ed0a04b10058b8
[ "MIT" ]
null
null
null
#include <iostream> #include <fstream> using namespace std; int main() { ifstream fin("cowsignal.in"); ofstream fout("cowsignal.out"); int m, n, k; fin >> m >> n >> k; char arr[m*n]; string temp = ""; char ans[(m*k)*(n*k)]; for(int a=0; a<m*n; a++){ fin >> arr[a]; } for(int a=0; a<=m*n; a++){ if(a % n == 0 && a != 0){ fout << "\n"; for(int b=0; b<k-1; b++){ fout << temp << "\n"; } temp = ""; if(a == m*n){ break; } } for(int b=0; b<k; b++){ ans[a + b] = arr[a]; temp += arr[a]; fout << ans[a+b]; } } }
18.323529
34
0.410915
Alecs-Li
95d1cf50c77c13f8caa762f74792d59c3b2dcdb1
1,396
hpp
C++
framework/include/planet.hpp
der-freddy/computergrafik
c47e32de23edc1c2aff45f2c789286219afcbf8f
[ "MIT" ]
null
null
null
framework/include/planet.hpp
der-freddy/computergrafik
c47e32de23edc1c2aff45f2c789286219afcbf8f
[ "MIT" ]
null
null
null
framework/include/planet.hpp
der-freddy/computergrafik
c47e32de23edc1c2aff45f2c789286219afcbf8f
[ "MIT" ]
null
null
null
#ifndef PLANETS_HPP #define PLANETS_HPP #include <memory> #include <map> #include <glbinding/gl/gl.h> #include <glm/gtc/type_precision.hpp> #include <glm/gtc/matrix_transform.hpp> #define GLFW_INCLUDE_NONE #include <GLFW/glfw3.h> // use gl definitions from glbinding using namespace gl; struct Planet{ Planet(glm::fvec3 rotation = glm::fvec3(), glm::fvec3 translation = glm::fvec3(), glm::fvec3 scale = glm::fvec3(), double rotationSpeed = 1.0f, glm::vec3 color = glm::fvec3(), float glossyness = 1.0f, std::shared_ptr<Planet> ref_pl = nullptr, texture_object texObj = texture_object()) { rotation_ = rotation; translation_ = translation; scale_ = scale; rotationSpeed_ = rotationSpeed; color_ = color; ref_pl_ = ref_pl; glossyness_ = glossyness; texObj_ = texObj; } glm::fvec3 rotation_; glm::fvec3 translation_; glm::fvec3 scale_; double rotationSpeed_; glm::fvec3 color_; std::shared_ptr<Planet> ref_pl_; float glossyness_; texture_object texObj_; }; glm::fmat4 model_matrix(std::shared_ptr<Planet> const& planet) { glm::fmat4 matrix{}; if(planet->ref_pl_ != nullptr) { matrix *= model_matrix(planet->ref_pl_); } matrix *= glm::rotate(glm::fmat4{}, float(glfwGetTime()*planet->rotationSpeed_), planet->rotation_); matrix *= glm::translate(glm::fmat4{}, planet->translation_); return matrix; } #endif
25.381818
117
0.699857
der-freddy
95dbd0f6c9879cd5d0f0fab70fffbcf8e675ba91
106
hpp
C++
src/health.hpp
BUDDGAF/eft-packet-1
cd10a52f4ea6e98219a14e17a8a5ba6bd7d98cc0
[ "MIT" ]
13
2020-05-02T00:32:14.000Z
2021-12-28T03:01:28.000Z
src/health.hpp
BUDDGAF/eft-packet-1
cd10a52f4ea6e98219a14e17a8a5ba6bd7d98cc0
[ "MIT" ]
null
null
null
src/health.hpp
BUDDGAF/eft-packet-1
cd10a52f4ea6e98219a14e17a8a5ba6bd7d98cc0
[ "MIT" ]
8
2020-05-01T19:24:55.000Z
2022-03-14T14:47:51.000Z
std::unordered_map<std::string, std::string> healthItems = { { "544fb45d4bdc2dee738b4568", "Salewa"}, };
35.333333
61
0.707547
BUDDGAF
95de790876c884e506a77dba01c034af8b4d3503
2,009
cpp
C++
libs/viewport/impl/src/viewport/impl/center.cpp
cpreh/spacegameengine
313a1c34160b42a5135f8223ffaa3a31bc075a01
[ "BSL-1.0" ]
2
2016-01-27T13:18:14.000Z
2018-05-11T01:11:32.000Z
libs/viewport/impl/src/viewport/impl/center.cpp
cpreh/spacegameengine
313a1c34160b42a5135f8223ffaa3a31bc075a01
[ "BSL-1.0" ]
null
null
null
libs/viewport/impl/src/viewport/impl/center.cpp
cpreh/spacegameengine
313a1c34160b42a5135f8223ffaa3a31bc075a01
[ "BSL-1.0" ]
3
2018-05-11T01:11:34.000Z
2021-04-24T19:47:45.000Z
// Copyright Carl Philipp Reh 2006 - 2019. // 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 <sge/renderer/dim2.hpp> #include <sge/renderer/pixel_rect.hpp> #include <sge/renderer/pixel_unit.hpp> #include <sge/renderer/target/viewport.hpp> #include <sge/viewport/impl/center.hpp> #include <sge/window/dim.hpp> #include <fcppt/assert/error.hpp> #include <fcppt/cast/size.hpp> #include <fcppt/cast/to_signed.hpp> #include <fcppt/cast/to_signed_fun.hpp> #include <fcppt/math/dim/structure_cast.hpp> #include <fcppt/math/vector/null.hpp> namespace { sge::renderer::pixel_unit center_position( sge::window::dim::value_type const _target_size, sge::window::dim::value_type const _window_size) { FCPPT_ASSERT_ERROR(_window_size >= _target_size); return fcppt::cast::size<sge::renderer::pixel_unit>( fcppt::cast::to_signed((_window_size - _target_size) / 2U)); } } sge::renderer::target::viewport sge::viewport::impl::center(sge::window::dim const &_ref_dim, sge::window::dim const &_window_dim) { return _ref_dim.w() > _window_dim.w() || _ref_dim.h() > _window_dim.h() ? sge::renderer::target::viewport(sge::renderer::pixel_rect( fcppt::math::vector::null<sge::renderer::pixel_rect::vector>(), fcppt::math::dim:: structure_cast<sge::renderer::pixel_rect::dim, fcppt::cast::to_signed_fun>( _window_dim))) : sge::renderer::target::viewport(sge::renderer::pixel_rect( sge::renderer::pixel_rect::vector( center_position(_ref_dim.w(), _window_dim.w()), center_position(_ref_dim.h(), _window_dim.h())), fcppt::math::dim:: structure_cast<sge::renderer::pixel_rect::dim, fcppt::cast::to_signed_fun>( _ref_dim))); }
39.392157
98
0.644102
cpreh
95df578aff1c8a74dd14af06aaf5eb825204fbf2
5,648
cpp
C++
node/silkworm/db/genesis_test.cpp
elmato/silkworm
711c73547cd1f7632ff02d5f86dfac5b0d249344
[ "Apache-2.0" ]
87
2020-08-03T11:40:39.000Z
2022-03-31T10:27:58.000Z
node/silkworm/db/genesis_test.cpp
elmato/silkworm
711c73547cd1f7632ff02d5f86dfac5b0d249344
[ "Apache-2.0" ]
452
2020-08-17T16:32:00.000Z
2022-03-28T19:19:59.000Z
node/silkworm/db/genesis_test.cpp
elmato/silkworm
711c73547cd1f7632ff02d5f86dfac5b0d249344
[ "Apache-2.0" ]
28
2020-08-27T02:06:50.000Z
2022-03-03T22:30:46.000Z
/* Copyright 2021 The Silkworm 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 "genesis.hpp" #include <catch2/catch.hpp> #include <silkworm/chain/genesis.hpp> #include <silkworm/common/test_context.hpp> namespace silkworm { namespace db { TEST_CASE("Database genesis initialization") { test::Context context; auto& txn{context.txn()}; SECTION("Initialize with Mainnet") { auto source_data{silkworm::read_genesis_data(silkworm::kMainnetConfig.chain_id)}; auto genesis_json = nlohmann::json::parse(source_data, nullptr, /*allow_exceptions=*/false); REQUIRE(db::initialize_genesis(txn, genesis_json, /*allow_exceptions=*/false)); context.commit_and_renew_txn(); CHECK(db::read_chain_config(txn) == silkworm::kMainnetConfig); } SECTION("Initialize with Goerli") { auto source_data{silkworm::read_genesis_data(silkworm::kGoerliConfig.chain_id)}; auto genesis_json = nlohmann::json::parse(source_data, nullptr, /*allow_exceptions=*/false); REQUIRE(db::initialize_genesis(txn, genesis_json, /*allow_exceptions=*/false)); CHECK(db::read_chain_config(txn) == silkworm::kGoerliConfig); } SECTION("Initialize with Rinkeby") { auto source_data{silkworm::read_genesis_data(silkworm::kRinkebyConfig.chain_id)}; auto genesis_json = nlohmann::json::parse(source_data, nullptr, /*allow_exceptions=*/false); REQUIRE(db::initialize_genesis(txn, genesis_json, /*allow_exceptions=*/false)); CHECK(db::read_chain_config(txn) == silkworm::kRinkebyConfig); } SECTION("Initialize with Ropsten") { auto source_data{silkworm::read_genesis_data(silkworm::kRopstenConfig.chain_id)}; auto genesis_json = nlohmann::json::parse(source_data, nullptr, /*allow_exceptions=*/false); // We don't have json data (yet) REQUIRE(db::initialize_genesis(txn, genesis_json, /*allow_exceptions=*/false) == false); } SECTION("Initialize with invalid Json") { std::string source_data{"{chainId="}; auto genesis_json = nlohmann::json::parse(source_data, nullptr, /*allow_exceptions=*/false); REQUIRE_THROWS(db::initialize_genesis(txn, genesis_json, /*allow_exceptions=*/true)); } SECTION("Initialize with errors in Json payload") { // Base is mainnet auto source_data{silkworm::read_genesis_data(silkworm::kMainnetConfig.chain_id)}; nlohmann::json notHex = "0xgg"; // Remove mandatory members { auto genesis_json = nlohmann::json::parse(source_data, nullptr, /*allow_exceptions=*/false); REQUIRE(genesis_json.is_discarded() == false); auto removed_count = genesis_json.erase("difficulty"); removed_count += genesis_json.erase("gaslimit"); removed_count += genesis_json.erase("timestamp"); removed_count += genesis_json.erase("extraData"); removed_count += genesis_json.erase("config"); const auto& [valid, errors]{db::validate_genesis_json(genesis_json)}; REQUIRE(valid == false); CHECK(errors.size() == removed_count); } // Tamper with hex values { auto genesis_json = nlohmann::json::parse(source_data, nullptr, /*allow_exceptions=*/false); REQUIRE(genesis_json.is_discarded() == false); genesis_json["difficulty"] = notHex; genesis_json["nonce"] = notHex; const auto& [valid, errors]{db::validate_genesis_json(genesis_json)}; REQUIRE(valid == false); CHECK(errors.size() == 2); genesis_json = nlohmann::json::parse(source_data, nullptr, /*allow_exceptions=*/false); genesis_json["alloc"]["c951900c341abbb3bafbf7ee2029377071dbc36a"]["balance"] = notHex; } // Tamper with hex values on allocations { auto genesis_json = nlohmann::json::parse(source_data, nullptr, /*allow_exceptions=*/false); genesis_json["alloc"]["c951900c341abbb3bafbf7ee2029377071dbc36a"]["balance"] = notHex; genesis_json["alloc"]["c951900c341abbb3bafbf7ee2029377071dbc"]["balance"] = notHex; const auto& [valid, errors]{db::validate_genesis_json(genesis_json)}; REQUIRE(valid == false); CHECK(errors.size() == 2); } // Remove chainId from config member { auto genesis_json = nlohmann::json::parse(source_data, nullptr, /*allow_exceptions=*/false); genesis_json["config"].erase("chainId"); const auto& [valid, errors]{db::validate_genesis_json(genesis_json)}; REQUIRE(valid == false); CHECK(errors.size() == 1); } } } } // namespace db } // namespace silkworm
47.066667
108
0.625354
elmato
95df962b0c35f50c2c5dd71789129eebb8683eed
438
cpp
C++
src/ByteEngine/Utility/Shapes/ConeWithFalloff.cpp
Facundo961/Game-Studio
8f404fd9b5659e65e7c5a7fe5f191d39b7a5a071
[ "MIT" ]
10
2020-05-05T03:21:34.000Z
2022-01-22T23:01:22.000Z
src/ByteEngine/Utility/Shapes/ConeWithFalloff.cpp
Facundo961/Game-Studio
8f404fd9b5659e65e7c5a7fe5f191d39b7a5a071
[ "MIT" ]
null
null
null
src/ByteEngine/Utility/Shapes/ConeWithFalloff.cpp
Facundo961/Game-Studio
8f404fd9b5659e65e7c5a7fe5f191d39b7a5a071
[ "MIT" ]
1
2020-09-07T03:04:48.000Z
2020-09-07T03:04:48.000Z
#include "ConeWithFalloff.h" #include <GTSL/Math/Math.hpp> ConeWithFalloff::ConeWithFalloff(const float Radius, const float Length) : Cone(Radius, Length) { } ConeWithFalloff::ConeWithFalloff(const float Radius, const float Length, const float ExtraRadius) : Cone(Radius, Length), ExtraRadius(ExtraRadius) { } float ConeWithFalloff::GetOuterConeInnerRadius() const { return GTSL::Math::ArcTangent((Radius + ExtraRadius) / Length); }
25.764706
146
0.773973
Facundo961
95e1341ada4a78caed6969a85bf6aa78612254b5
28,086
cpp
C++
__Source__/Jimara/Physics/PhysX/PhysXScene.cpp
TheDonsky/Jimara
d677090e61dc1ddfd8c1be61d5202fbf09b1e3ab
[ "MIT" ]
1
2022-03-28T13:57:09.000Z
2022-03-28T13:57:09.000Z
__Source__/Jimara/Physics/PhysX/PhysXScene.cpp
TheDonsky/Jimara
d677090e61dc1ddfd8c1be61d5202fbf09b1e3ab
[ "MIT" ]
null
null
null
__Source__/Jimara/Physics/PhysX/PhysXScene.cpp
TheDonsky/Jimara
d677090e61dc1ddfd8c1be61d5202fbf09b1e3ab
[ "MIT" ]
1
2021-02-02T13:34:57.000Z
2021-02-02T13:34:57.000Z
#include "PhysXScene.h" #include "PhysXStaticBody.h" #include "PhysXDynamicBody.h" #include "../../Core/Unused.h" #include "PhysXCollider.h" #pragma warning(disable: 26812) namespace Jimara { namespace Physics { namespace PhysX { namespace { #define JIMARA_PHYSX_LAYER_COUNT 256 #define JIMARA_PHYSX_LAYER_DATA_BYTE_ID(layerId) (layerId >> 3) #define JIMARA_PHYSX_LAYER_DATA_WIDTH JIMARA_PHYSX_LAYER_DATA_BYTE_ID(JIMARA_PHYSX_LAYER_COUNT) #define JIMARA_PHYSX_LAYER_FILTER_DATA_SIZE (JIMARA_PHYSX_LAYER_COUNT * JIMARA_PHYSX_LAYER_DATA_WIDTH) #define JIMARA_PHYSX_GET_LAYER_DATA_BYTE(data, layerA, layerB) data[(layerA * JIMARA_PHYSX_LAYER_DATA_WIDTH) + JIMARA_PHYSX_LAYER_DATA_BYTE_ID(layerB)] #define JIMARA_PHYSX_LAYER_DATA_BIT(layerB) static_cast<uint8_t>(1u << (layerB & 7)) #define JIMARA_PHYSX_GET_LAYER_DATA_BIT(data, layerA, layerB) ((JIMARA_PHYSX_GET_LAYER_DATA_BYTE(data, layerA, layerB) & JIMARA_PHYSX_LAYER_DATA_BIT(layerB)) != 0) static PX_INLINE physx::PxFilterFlags SimulationFilterShader( physx::PxFilterObjectAttributes attributes0, physx::PxFilterData filterData0, physx::PxFilterObjectAttributes attributes1, physx::PxFilterData filterData1, physx::PxPairFlags& pairFlags, const void* constantBlock, physx::PxU32 constantBlockSize) { Unused(attributes0, attributes1, constantBlockSize, constantBlock); PhysicsCollider::Layer layerA = PhysXCollider::GetLayer(filterData0); PhysicsCollider::Layer layerB = PhysXCollider::GetLayer(filterData1); if (!JIMARA_PHYSX_GET_LAYER_DATA_BIT(static_cast<const uint8_t*>(constantBlock), layerA, layerB)) return physx::PxFilterFlag::eSUPPRESS; if ((PhysXCollider::GetFilterFlags(filterData0) & static_cast<PhysXCollider::FilterFlags>(PhysXCollider::FilterFlag::IS_TRIGGER)) != 0 || (PhysXCollider::GetFilterFlags(filterData1) & static_cast<PhysXCollider::FilterFlags>(PhysXCollider::FilterFlag::IS_TRIGGER)) != 0) { pairFlags = physx::PxPairFlag::eTRIGGER_DEFAULT; } else pairFlags = physx::PxPairFlag::eCONTACT_DEFAULT | physx::PxPairFlag::eNOTIFY_CONTACT_POINTS; pairFlags |= physx::PxPairFlag::eNOTIFY_TOUCH_CCD | physx::PxPairFlag::eNOTIFY_TOUCH_FOUND | physx::PxPairFlag::eNOTIFY_TOUCH_PERSISTS | physx::PxPairFlag::eNOTIFY_TOUCH_LOST | physx::PxPairFlag::eNOTIFY_THRESHOLD_FORCE_FOUND | physx::PxPairFlag::eNOTIFY_THRESHOLD_FORCE_PERSISTS | physx::PxPairFlag::eNOTIFY_THRESHOLD_FORCE_LOST; return physx::PxFilterFlag::eDEFAULT; } } PhysXScene::PhysXScene(PhysXInstance* instance, size_t maxSimulationThreads, const Vector3 gravity) : PhysicsScene(instance) { m_dispatcher = physx::PxDefaultCpuDispatcherCreate(static_cast<uint32_t>(max(maxSimulationThreads, static_cast<size_t>(1u)))); if (m_dispatcher == nullptr) { APIInstance()->Log()->Fatal("PhysicXScene - Failed to create the dispatcher!"); return; } physx::PxSceneDesc sceneDesc((*instance)->getTolerancesScale()); sceneDesc.gravity = physx::PxVec3(gravity.x, gravity.y, gravity.z); sceneDesc.cpuDispatcher = m_dispatcher; sceneDesc.filterShader = SimulationFilterShader; sceneDesc.simulationEventCallback = &m_simulationEventCallback; sceneDesc.kineKineFilteringMode = physx::PxPairFilteringMode::eKEEP; sceneDesc.staticKineFilteringMode = physx::PxPairFilteringMode::eKEEP; sceneDesc.flags |= physx::PxSceneFlag::eENABLE_CCD; m_scene = (*instance)->createScene(sceneDesc); if (m_scene == nullptr) { APIInstance()->Log()->Fatal("PhysicXScene - Failed to create the scene!"); return; } m_layerFilterData = new uint8_t[JIMARA_PHYSX_LAYER_FILTER_DATA_SIZE]; for (size_t i = 0; i < JIMARA_PHYSX_LAYER_FILTER_DATA_SIZE; i++) m_layerFilterData[i] = ~((uint8_t)0); physx::PxPvdSceneClient* pvdClient = m_scene->getScenePvdClient(); if (pvdClient != nullptr) { pvdClient->setScenePvdFlag(physx::PxPvdSceneFlag::eTRANSMIT_CONSTRAINTS, true); pvdClient->setScenePvdFlag(physx::PxPvdSceneFlag::eTRANSMIT_CONTACTS, true); pvdClient->setScenePvdFlag(physx::PxPvdSceneFlag::eTRANSMIT_SCENEQUERIES, true); pvdClient->setScenePvdFlag(physx::PxPvdSceneFlag::eTRANSMIT_CONTACTS, true); } } PhysXScene::~PhysXScene() { if (m_scene != nullptr) { m_scene->release(); m_scene = nullptr; } if (m_dispatcher != nullptr) { m_dispatcher->release(); m_dispatcher = nullptr; } if (m_layerFilterData != nullptr) { delete[] m_layerFilterData; m_layerFilterData = nullptr; } } Vector3 PhysXScene::Gravity()const { ReadLock lock(this); physx::PxVec3 gravity = m_scene->getGravity(); return Vector3(gravity.x, gravity.y, gravity.z); } void PhysXScene::SetGravity(const Vector3& value) { WriteLock lock(this); m_scene->setGravity(physx::PxVec3(value.x, value.y, value.z)); } bool PhysXScene::LayersInteract(PhysicsCollider::Layer a, PhysicsCollider::Layer b)const { if (m_layerFilterData == nullptr) return false; else return JIMARA_PHYSX_GET_LAYER_DATA_BIT(m_layerFilterData, a, b); } void PhysXScene::FilterLayerInteraction(PhysicsCollider::Layer a, PhysicsCollider::Layer b, bool enableIntaraction) { if (m_layerFilterData == nullptr) { APIInstance()->Log()->Fatal("PhysXScene::FilterLayerInteraction - layer filter data missing!"); return; } if (enableIntaraction) { JIMARA_PHYSX_GET_LAYER_DATA_BYTE(m_layerFilterData, a, b) |= JIMARA_PHYSX_LAYER_DATA_BIT(b); JIMARA_PHYSX_GET_LAYER_DATA_BYTE(m_layerFilterData, b, a) |= JIMARA_PHYSX_LAYER_DATA_BIT(a); } else { JIMARA_PHYSX_GET_LAYER_DATA_BYTE(m_layerFilterData, a, b) &= ~JIMARA_PHYSX_LAYER_DATA_BIT(b); JIMARA_PHYSX_GET_LAYER_DATA_BYTE(m_layerFilterData, b, a) &= ~JIMARA_PHYSX_LAYER_DATA_BIT(a); } m_layerFilterDataDirty = true; } Reference<DynamicBody> PhysXScene::AddRigidBody(const Matrix4& pose, bool enabled) { PhysXScene::WriteLock lock(this); return Object::Instantiate<PhysXDynamicBody>(this, pose, enabled); } Reference<StaticBody> PhysXScene::AddStaticBody(const Matrix4& pose, bool enabled) { PhysXScene::WriteLock lock(this); return Object::Instantiate<PhysXStaticBody>(this, pose, enabled); } namespace { struct LocationHitTranslator { inline static RaycastHit TranslateHit(const physx::PxLocationHit& hitInfo) { RaycastHit hit; hit.collider = ((PhysXCollider::UserData*)hitInfo.shape->userData)->Collider(); hit.normal = Translate(hitInfo.normal); hit.point = Translate(hitInfo.position); hit.distance = hitInfo.distance; return hit; } }; struct OverlapHitTranslator { inline static PhysicsCollider* TranslateHit(const physx::PxOverlapHit& hitInfo) { return ((PhysXCollider::UserData*)hitInfo.shape->userData)->Collider(); } }; struct QueryFilterCallback : public physx::PxQueryFilterCallback { const PhysicsCollider::LayerMask layers; const Function<PhysicsScene::QueryFilterFlag, PhysicsCollider*>* const preFilterCallback = nullptr; const Function<PhysicsScene::QueryFilterFlag, const RaycastHit&>* const postFilterCallback = nullptr; const bool findAll = false; const physx::PxQueryFilterData filterData; inline physx::PxQueryHitType::Enum TypeFromFlag(PhysicsScene::QueryFilterFlag flag) { return (flag == PhysicsScene::QueryFilterFlag::REPORT) ? (findAll ? physx::PxQueryHitType::eTOUCH : physx::PxQueryHitType::eBLOCK) : (flag == PhysicsScene::QueryFilterFlag::REPORT_BLOCK) ? physx::PxQueryHitType::eBLOCK : physx::PxQueryHitType::eNONE; } inline virtual physx::PxQueryHitType::Enum preFilter( const physx::PxFilterData& filterData, const physx::PxShape* shape, const physx::PxRigidActor* actor, physx::PxHitFlags& queryFlags) override { Unused(filterData, actor, queryFlags); PhysXCollider::UserData* data = (PhysXCollider::UserData*)shape->userData; if (data == nullptr) return physx::PxQueryHitType::eNONE; PhysicsCollider* collider = data->Collider(); if (collider == nullptr) return physx::PxQueryHitType::eNONE; else if (!layers[collider->GetLayer()]) return physx::PxQueryHitType::eNONE; else if (preFilterCallback != nullptr) return TypeFromFlag((*preFilterCallback)(collider)); else return (findAll ? physx::PxQueryHitType::eTOUCH : physx::PxQueryHitType::eBLOCK); } inline virtual physx::PxQueryHitType::Enum postFilter(const physx::PxFilterData& filterData, const physx::PxQueryHit& hit) override { Unused(filterData); if (hit.shape->userData == nullptr) return physx::PxQueryHitType::eNONE; RaycastHit checkHit = LocationHitTranslator::TranslateHit((physx::PxLocationHit&)hit); if (checkHit.collider == nullptr) return physx::PxQueryHitType::eNONE; else return TypeFromFlag((*postFilterCallback)(checkHit)); } inline QueryFilterCallback(const PhysicsCollider::LayerMask& mask , const Function<PhysicsScene::QueryFilterFlag, PhysicsCollider*>* preFilterCall , const Function<PhysicsScene::QueryFilterFlag, const RaycastHit&>* postFilterCall , PhysicsScene::QueryFlags flags, bool ignoreOrder = false) : layers(mask) , preFilterCallback(preFilterCall), postFilterCallback(postFilterCall) , findAll((flags & PhysicsScene::Query(PhysicsScene::QueryFlag::REPORT_MULTIPLE_HITS)) != 0) , filterData([&]() { physx::PxQueryFilterData data; data.flags = physx::PxQueryFlag::ePREFILTER; if ((flags & PhysicsScene::Query(PhysicsScene::QueryFlag::EXCLUDE_STATIC_BODIES)) == 0) data.flags |= physx::PxQueryFlag::eSTATIC; if ((flags & PhysicsScene::Query(PhysicsScene::QueryFlag::EXCLUDE_DYNAMIC_BODIES)) == 0) data.flags |= physx::PxQueryFlag::eDYNAMIC; if (postFilterCall != nullptr) data.flags |= physx::PxQueryFlag::ePOSTFILTER; bool queryAll = ((flags & PhysicsScene::Query(PhysicsScene::QueryFlag::REPORT_MULTIPLE_HITS)) != 0); if (queryAll) { if (ignoreOrder || (preFilterCall == nullptr && postFilterCall == nullptr)) data.flags |= physx::PxQueryFlag::eNO_BLOCK; } else if (ignoreOrder) data.flags |= physx::PxQueryFlag::eANY_HIT; return data; }()) {} }; template<typename HitType, typename ReportedType = const RaycastHit&, typename HitTranslator = LocationHitTranslator> class MultiHitCallbacks : public virtual physx::PxHitCallback<HitType> { private: HitType m_touchBuffer[128]; const Callback<ReportedType>* m_onHitFound; size_t m_numTouches = 0; public: inline MultiHitCallbacks(const Callback<ReportedType>* onHitFound) : physx::PxHitCallback<HitType>(m_touchBuffer, static_cast<physx::PxU32>(sizeof(m_touchBuffer) / sizeof(HitType))) , m_onHitFound(onHitFound) { } inline virtual physx::PxAgain processTouches(const HitType* buffer, physx::PxU32 nbHits) override { for (physx::PxU32 i = 0; i < nbHits; i++) (*m_onHitFound)(HitTranslator::TranslateHit(buffer[i])); m_numTouches += nbHits; return true; } inline size_t NumTouches()const { return m_numTouches; } }; inline static bool FixDirection(const Vector3& direction, float& maxDistance, physx::PxVec3& dir) { if (maxDistance < 0.0f) { maxDistance = -maxDistance; dir = -Translate(direction); } else dir = Translate(direction); float rawDirMagn = dir.magnitude(); if (rawDirMagn <= 0.0f) return false; else { dir /= rawDirMagn; return true; } } inline static size_t PhysXSweep(physx::PxScene* scene, const physx::PxGeometry& shape, const physx::PxTransform& transform , const Vector3& direction, float maxDistance, const Callback<const RaycastHit&>& onHitFound , const PhysicsCollider::LayerMask& layerMask, PhysicsScene::QueryFlags flags , const Function<PhysicsScene::QueryFilterFlag, PhysicsCollider*>* preFilter , const Function<PhysicsScene::QueryFilterFlag, const RaycastHit&>* postFilter) { physx::PxVec3 dir; if (!FixDirection(direction, maxDistance, dir)) return 0; QueryFilterCallback filterCallback(layerMask, preFilter, postFilter, flags); physx::PxHitFlags hitFlags = physx::PxHitFlag::ePOSITION | physx::PxHitFlag::eNORMAL; if (filterCallback.findAll) { MultiHitCallbacks<physx::PxSweepHit> hitBuff(&onHitFound); scene->sweep(shape, transform, dir, maxDistance, hitBuff, hitFlags | physx::PxHitFlag::eMESH_MULTIPLE, filterCallback.filterData, &filterCallback); if (hitBuff.hasBlock) { onHitFound(LocationHitTranslator::TranslateHit(hitBuff.block)); return hitBuff.NumTouches() + 1; } else return hitBuff.NumTouches(); } else { physx::PxSweepBuffer hitBuff; if (scene->sweep(shape, transform, dir, maxDistance, hitBuff, hitFlags, filterCallback.filterData, &filterCallback)) { assert(hitBuff.hasBlock); onHitFound(LocationHitTranslator::TranslateHit(hitBuff.block)); return 1; } else return 0; } } inline static size_t PhysXOverlap(physx::PxScene* scene, const physx::PxGeometry& shape, const physx::PxTransform& transform , const Callback<PhysicsCollider*>& onHitFound, const PhysicsCollider::LayerMask& layerMask, PhysicsScene::QueryFlags flags , const Function<PhysicsScene::QueryFilterFlag, PhysicsCollider*>* filter) { QueryFilterCallback filterCallback(layerMask, filter, nullptr, flags, true); if (filterCallback.findAll) { MultiHitCallbacks<physx::PxOverlapHit, PhysicsCollider*, OverlapHitTranslator> hitBuff(&onHitFound); scene->overlap(shape, transform, hitBuff, filterCallback.filterData, &filterCallback); if (hitBuff.hasBlock) { onHitFound(OverlapHitTranslator::TranslateHit(hitBuff.block)); return hitBuff.NumTouches() + 1; } else return hitBuff.NumTouches(); } else { physx::PxOverlapBuffer hitBuff; if (scene->overlap(shape, transform, hitBuff, filterCallback.filterData, &filterCallback)) { assert(hitBuff.hasBlock); onHitFound(OverlapHitTranslator::TranslateHit(hitBuff.block)); return 1; } else return 0; } } } size_t PhysXScene::Raycast(const Vector3& origin, const Vector3& direction, float maxDistance , const Callback<const RaycastHit&>& onHitFound, const PhysicsCollider::LayerMask& layerMask, QueryFlags flags , const Function<QueryFilterFlag, PhysicsCollider*>* preFilter, const Function<QueryFilterFlag, const RaycastHit&>* postFilter)const { static_assert(sizeof(physx::PxFilterData) >= sizeof(PhysicsCollider::LayerMask*)); physx::PxVec3 dir; if (!FixDirection(direction, maxDistance, dir)) return 0; QueryFilterCallback filterCallback(layerMask, preFilter, postFilter, flags); physx::PxHitFlags hitFlags = physx::PxHitFlag::ePOSITION | physx::PxHitFlag::eNORMAL; if (filterCallback.findAll) { MultiHitCallbacks<physx::PxRaycastHit> hitBuff(&onHitFound); ReadLock lock(this); m_scene->raycast(Translate(origin), dir, maxDistance, hitBuff, hitFlags | physx::PxHitFlag::eMESH_MULTIPLE, filterCallback.filterData, &filterCallback); if (hitBuff.hasBlock) { onHitFound(LocationHitTranslator::TranslateHit(hitBuff.block)); return hitBuff.NumTouches() + 1; } else return hitBuff.NumTouches(); } else { physx::PxRaycastBuffer hitBuff; ReadLock lock(this); if (m_scene->raycast(Translate(origin), dir, maxDistance, hitBuff, hitFlags, filterCallback.filterData, &filterCallback)) { assert(hitBuff.hasBlock); onHitFound(LocationHitTranslator::TranslateHit(hitBuff.block)); return 1; } else return 0; } } size_t PhysXScene::Sweep(const SphereShape& shape, const Matrix4& pose, const Vector3& direction, float maxDistance , const Callback<const RaycastHit&>& onHitFound, const PhysicsCollider::LayerMask& layerMask, QueryFlags flags , const Function<QueryFilterFlag, PhysicsCollider*>* preFilter, const Function<QueryFilterFlag, const RaycastHit&>* postFilter)const { ReadLock lock(this); return PhysXSweep( m_scene, PhysXSphereCollider::Geometry(shape), physx::PxTransform(Translate(pose)) , direction, maxDistance, onHitFound, layerMask, flags, preFilter, postFilter); } size_t PhysXScene::Sweep(const CapsuleShape& shape, const Matrix4& pose, const Vector3& direction, float maxDistance , const Callback<const RaycastHit&>& onHitFound, const PhysicsCollider::LayerMask& layerMask, QueryFlags flags , const Function<QueryFilterFlag, PhysicsCollider*>* preFilter, const Function<QueryFilterFlag, const RaycastHit&>* postFilter)const { ReadLock lock(this); return PhysXSweep( m_scene, PhysXCapusuleCollider::Geometry(shape), physx::PxTransform(Translate(pose * PhysXCapusuleCollider::Wrangle(shape.alignment).first)) , direction, maxDistance, onHitFound, layerMask, flags, preFilter, postFilter); } size_t PhysXScene::Sweep(const BoxShape& shape, const Matrix4& pose, const Vector3& direction, float maxDistance , const Callback<const RaycastHit&>& onHitFound, const PhysicsCollider::LayerMask& layerMask, QueryFlags flags , const Function<QueryFilterFlag, PhysicsCollider*>* preFilter, const Function<QueryFilterFlag, const RaycastHit&>* postFilter)const { ReadLock lock(this); return PhysXSweep( m_scene, PhysXBoxCollider::Geometry(shape), physx::PxTransform(Translate(pose)) , direction, maxDistance, onHitFound, layerMask, flags, preFilter, postFilter); } size_t PhysXScene::Overlap(const SphereShape& shape, const Matrix4& pose, const Callback<PhysicsCollider*>& onOverlapFound , const PhysicsCollider::LayerMask& layerMask, QueryFlags flags, const Function<QueryFilterFlag, PhysicsCollider*>* filter)const { ReadLock lock(this); return PhysXOverlap(m_scene, PhysXSphereCollider::Geometry(shape), physx::PxTransform(Translate(pose)), onOverlapFound, layerMask, flags, filter); } size_t PhysXScene::Overlap(const CapsuleShape& shape, const Matrix4& pose, const Callback<PhysicsCollider*>& onOverlapFound , const PhysicsCollider::LayerMask& layerMask, QueryFlags flags, const Function<QueryFilterFlag, PhysicsCollider*>* filter)const { ReadLock lock(this); return PhysXOverlap( m_scene, PhysXCapusuleCollider::Geometry(shape), physx::PxTransform(Translate(pose * PhysXCapusuleCollider::Wrangle(shape.alignment).first)), onOverlapFound, layerMask, flags, filter); } size_t PhysXScene::Overlap(const BoxShape& shape, const Matrix4& pose, const Callback<PhysicsCollider*>& onOverlapFound , const PhysicsCollider::LayerMask& layerMask, QueryFlags flags, const Function<QueryFilterFlag, PhysicsCollider*>* filter)const { ReadLock lock(this); return PhysXOverlap(m_scene, PhysXBoxCollider::Geometry(shape), physx::PxTransform(Translate(pose)), onOverlapFound, layerMask, flags, filter); } void PhysXScene::SimulateAsynch(float deltaTime) { WriteLock lock(this); if (m_layerFilterDataDirty) { m_scene->setFilterShaderData(m_layerFilterData, static_cast<physx::PxU32>(JIMARA_PHYSX_LAYER_FILTER_DATA_SIZE)); m_layerFilterDataDirty = false; } m_scene->simulate(deltaTime); } void PhysXScene::SynchSimulation() { { WriteLock lock(this); m_scene->fetchResults(true); } m_simulationEventCallback.NotifyEvents(); } PhysXScene::operator physx::PxScene* () const { return m_scene; } physx::PxScene* PhysXScene::operator->()const { return m_scene; } void PhysXScene::SimulationEventCallback::onConstraintBreak(physx::PxConstraintInfo* constraints, physx::PxU32 count) { Unused(constraints, count); } void PhysXScene::SimulationEventCallback::onWake(physx::PxActor** actors, physx::PxU32 count) { Unused(actors, count); } void PhysXScene::SimulationEventCallback::onSleep(physx::PxActor** actors, physx::PxU32 count) { Unused(actors, count); } void PhysXScene::SimulationEventCallback::onContact(const physx::PxContactPairHeader& pairHeader, const physx::PxContactPair* pairs, physx::PxU32 nbPairs) { Unused(pairHeader); std::unique_lock<std::mutex> lock(m_eventLock); uint8_t bufferId = m_backBuffer; std::vector<PhysicsCollider::ContactPoint>& pointBuffer = m_contactPoints[bufferId]; for (size_t i = 0; i < nbPairs; i++) { const physx::PxContactPair& pair = pairs[i]; PhysXCollider::UserData* data[2] = { (PhysXCollider::UserData*)pair.shapes[0]->userData, (PhysXCollider::UserData*)pair.shapes[1]->userData }; if (data[0] == nullptr || data[1] == nullptr) continue; bool isTriggerContact = data[0]->Collider()->IsTrigger() || data[1]->Collider()->IsTrigger(); ContactPairInfo info = {}; info.info.type = (((physx::PxU16)pair.events & physx::PxPairFlag::eNOTIFY_TOUCH_FOUND) != 0) ? (isTriggerContact ? PhysicsCollider::ContactType::ON_TRIGGER_BEGIN : PhysicsCollider::ContactType::ON_COLLISION_BEGIN) : (((physx::PxU16)pair.events & physx::PxPairFlag::eNOTIFY_TOUCH_LOST) != 0) ? (isTriggerContact ? PhysicsCollider::ContactType::ON_TRIGGER_END : PhysicsCollider::ContactType::ON_COLLISION_END) : (((physx::PxU16)pair.events & physx::PxPairFlag::eNOTIFY_TOUCH_PERSISTS) != 0) ? (isTriggerContact ? PhysicsCollider::ContactType::ON_TRIGGER_PERSISTS : PhysicsCollider::ContactType::ON_COLLISION_PERSISTS) : PhysicsCollider::ContactType::CONTACT_TYPE_COUNT; if (info.info.type >= PhysicsCollider::ContactType::CONTACT_TYPE_COUNT) continue; if (pair.shapes[0] < pair.shapes[1]) { info.shapes[0] = pair.shapes[0]; info.shapes[1] = pair.shapes[1]; info.info.reverseOrder = false; } else { info.shapes[0] = pair.shapes[1]; info.shapes[1] = pair.shapes[0]; info.info.reverseOrder = true; } if (m_contactPointBuffer.size() < pair.contactCount) m_contactPointBuffer.resize(pair.contactCount); size_t contactCount = pair.extractContacts(m_contactPointBuffer.data(), (uint32_t)m_contactPointBuffer.size()); info.info.pointBuffer = bufferId; info.info.firstContactPoint = pointBuffer.size(); for (size_t i = 0; i < contactCount; i++) { const physx::PxContactPairPoint& point = m_contactPointBuffer[i]; PhysicsCollider::ContactPoint info = {}; info.position = Translate(point.position); info.normal = Translate(point.normal); pointBuffer.push_back(info); } info.info.lastContactPoint = pointBuffer.size(); m_contacts.push_back(info); } } void PhysXScene::SimulationEventCallback::onTrigger(physx::PxTriggerPair* pairs, physx::PxU32 count) { std::unique_lock<std::mutex> lock(m_eventLock); uint8_t bufferId = m_backBuffer; for (size_t i = 0; i < count; i++) { const physx::PxTriggerPair& pair = pairs[i]; ContactPairInfo info = {}; info.info.type = (pair.status == physx::PxPairFlag::eNOTIFY_TOUCH_FOUND) ? PhysicsCollider::ContactType::ON_TRIGGER_BEGIN : (pair.status == physx::PxPairFlag::eNOTIFY_TOUCH_LOST) ? PhysicsCollider::ContactType::ON_TRIGGER_END : PhysicsCollider::ContactType::CONTACT_TYPE_COUNT; if (info.info.type >= PhysicsCollider::ContactType::CONTACT_TYPE_COUNT) continue; if (pair.triggerShape < pair.otherShape) { info.shapes[0] = pair.triggerShape; info.shapes[1] = pair.otherShape; info.info.reverseOrder = false; } else { info.shapes[0] = pair.otherShape; info.shapes[1] = pair.triggerShape; info.info.reverseOrder = true; } if (info.shapes[0]->userData == nullptr || info.shapes[1]->userData == nullptr) continue; info.info.pointBuffer = bufferId; m_contacts.push_back(info); } } void PhysXScene::SimulationEventCallback::onAdvance(const physx::PxRigidBody* const* bodyBuffer, const physx::PxTransform* poseBuffer, const physx::PxU32 count) { Unused(bodyBuffer, poseBuffer, count); } void PhysXScene::SimulationEventCallback::NotifyEvents() { std::unique_lock<std::mutex> lock(m_eventLock); // Current contact point buffer: const uint8_t bufferId = m_backBuffer; std::vector<PhysicsCollider::ContactPoint>& pointBuffer = m_contactPoints[bufferId]; // Notifies listeners about the pair contact (returns false, if the shapes are no longer valid): auto notifyContact = [&](const ShapePair& pair, ContactInfo& info) { PhysXCollider::UserData* listener = (PhysXCollider::UserData*)pair.shapes[0]->userData; PhysXCollider::UserData* otherListener = (PhysXCollider::UserData*)pair.shapes[1]->userData; if (listener == nullptr || otherListener == nullptr) return false; PhysicsCollider::ContactPoint* const contactPoints = pointBuffer.data() + info.firstContactPoint; const size_t contactPointCount = (info.lastContactPoint - info.firstContactPoint); auto reverse = [&]() { for (size_t i = 0; i < contactPointCount; i++) { PhysicsCollider::ContactPoint& point = contactPoints[i]; point.normal = -point.normal; } info.reverseOrder ^= 1; }; if (info.reverseOrder) { otherListener->OnContact(pair.shapes[1], pair.shapes[0], info.type, contactPoints, contactPointCount); reverse(); listener->OnContact(pair.shapes[0], pair.shapes[1], info.type, contactPoints, contactPointCount); } else { listener->OnContact(pair.shapes[0], pair.shapes[1], info.type, contactPoints, contactPointCount); reverse(); otherListener->OnContact(pair.shapes[1], pair.shapes[0], info.type, contactPoints, contactPointCount); } return true; }; // Notifies about the newly contacts and saves persistent contacts in case the actors start sleeping: for (size_t contactId = 0; contactId < m_contacts.size(); contactId++) { ContactPairInfo& info = m_contacts[contactId]; ShapePair pair; pair.shapes[0] = info.shapes[0]; pair.shapes[1] = info.shapes[1]; notifyContact(pair, info.info); if (info.info.type == PhysicsCollider::ContactType::ON_COLLISION_END || info.info.type == PhysicsCollider::ContactType::ON_TRIGGER_END) m_persistentContacts.erase(pair); else { ContactInfo contact = info.info; if (contact.type == PhysicsCollider::ContactType::ON_COLLISION_BEGIN) contact.type = PhysicsCollider::ContactType::ON_COLLISION_PERSISTS; else if (contact.type == PhysicsCollider::ContactType::ON_TRIGGER_BEGIN) contact.type = PhysicsCollider::ContactType::ON_TRIGGER_PERSISTS; m_persistentContacts[pair] = contact; } } // Notifies about sleeping persistent contacts: for (PersistentContactMap::iterator it = m_persistentContacts.begin(); it != m_persistentContacts.end(); ++it) { ContactInfo& info = it->second; if (info.pointBuffer == bufferId) continue; const size_t contactPointCount = (info.lastContactPoint - info.firstContactPoint); const PhysicsCollider::ContactPoint* const contactPoints = m_contactPoints[info.pointBuffer].data() + info.firstContactPoint; info.firstContactPoint = pointBuffer.size(); for (size_t i = 0; i < contactPointCount; i++) pointBuffer.push_back(contactPoints[i]); info.lastContactPoint = pointBuffer.size(); info.pointBuffer = bufferId; if (!notifyContact(it->first, info)) m_pairsToRemove.push_back(it->first); } // Remove invalidated persistent contacts: for (size_t i = 0; i < m_pairsToRemove.size(); i++) m_persistentContacts.erase(m_pairsToRemove[i]); m_pairsToRemove.clear(); // Swaps contact buffers: m_backBuffer ^= 1; m_contacts.clear(); m_contactPoints[m_backBuffer].clear(); } } } } #pragma warning(default: 26812)
48.257732
166
0.719504
TheDonsky
95e4a43f68f6cc9a521e6035d8e96e5bf407b08a
3,916
hpp
C++
include/polycalc/quadrature/gauss_lobatto.hpp
BryanFlynt/PolyCalc
9fe70f83647c6f5683e6e8f5cfee23b417974ebb
[ "Apache-2.0" ]
null
null
null
include/polycalc/quadrature/gauss_lobatto.hpp
BryanFlynt/PolyCalc
9fe70f83647c6f5683e6e8f5cfee23b417974ebb
[ "Apache-2.0" ]
null
null
null
include/polycalc/quadrature/gauss_lobatto.hpp
BryanFlynt/PolyCalc
9fe70f83647c6f5683e6e8f5cfee23b417974ebb
[ "Apache-2.0" ]
null
null
null
/** * \file gauss_lobatto.hpp * \author Bryan Flynt * \date Sep 02, 2021 * \copyright Copyright (C) 2021 Bryan Flynt - All Rights Reserved */ #pragma once #include <cassert> #include <vector> #include "polycalc/parameters.hpp" #include "polycalc/polynomial/jacobi.hpp" namespace polycalc { namespace quadrature { template <typename T, typename P = DefaultParameters<T>> class GaussLobatto { public: using value_type = T; using params = P; using size_type = std::size_t; using polynomial = ::polycalc::polynomial::Jacobi<T, P>; GaussLobatto() = delete; GaussLobatto(const GaussLobatto& other) = default; GaussLobatto(GaussLobatto&& other) = default; ~GaussLobatto() = default; GaussLobatto& operator=(const GaussLobatto& other) = default; GaussLobatto& operator=(GaussLobatto&& other) = default; GaussLobatto(const value_type a, const value_type b) : alpha_(a), beta_(b) {} /** Quadrature Locations * * Returns the Gauss-Lobatto quadrature locations at n locations. */ std::vector<value_type> zeros(const unsigned n) const; /** Quadrature Weights * * Returns the Gauss-Jacobi weights at n Lobatto zeros. */ std::vector<value_type> weights(const unsigned n) const; private: value_type alpha_; value_type beta_; }; template <typename T, typename P> std::vector<typename GaussLobatto<T, P>::value_type> GaussLobatto<T, P>::zeros(const unsigned n) const { assert(n > 0); // Good Decimal Calculator found at following site // https://keisan.casio.com/exec/system/1280801905 // Zeros to return std::vector<value_type> x(n); switch (n) { case 1: x[0] = 0.0; break; case 2: x[0] = -1.0; x[1] = +1.0; break; case 3: x[0] = -1.0; x[1] = 0.0; x[2] = +1.0; break; default: polynomial jac(alpha_ + 1, beta_ + 1); auto zeros = jac.zeros(n - 2); x.front() = -1.0; std::copy(zeros.begin(), zeros.end(), x.begin() + 1); x.back() = +1.0; if (!(n % 2 == 0)) { x[std::ptrdiff_t(n / 2)] = 0; // Correct 10E-16 error at zero } } return x; } template <typename T, typename P> std::vector<typename GaussLobatto<T, P>::value_type> GaussLobatto<T, P>::weights(const unsigned n) const { assert(n > 0); // Good Decimal Calculator found at following site // https://keisan.casio.com/exec/system/1280801905 // Weights to return std::vector<value_type> w(n); switch (n) { case 1: w[0] = +2.0; break; case 2: w[0] = +1.0; w[1] = +1.0; break; case 3: w[0] = 1.0L / 3.0L; w[1] = 4.0L / 3.0L; w[2] = 1.0L / 3.0L; break; default: // Get location of zeros auto z = this->zeros(n); // Evaluate Jacobi n-1 polynomial at each zero polynomial jac(alpha_, beta_); for (size_type i = 0; i < n; ++i) { w[i] = jac.eval(n - 1, z[i]); } const value_type one = 1; const value_type two = 2; const value_type apb = alpha_ + beta_; value_type fac; fac = std::pow(two, apb + one) * std::tgamma(alpha_ + n) * std::tgamma(beta_ + n); fac /= (n - 1) * std::tgamma(n) * std::tgamma(alpha_ + beta_ + n + one); for (size_type i = 0; i < n; ++i) { w[i] = fac / (w[i] * w[i]); } w[0] *= (beta_ + one); w[n - 1] *= (alpha_ + one); } return w; } } // namespace quadrature } // namespace polycalc
27.77305
106
0.522472
BryanFlynt
95e5037325108bcb3a68d454b1596a032466ddf7
1,277
cpp
C++
RPSolver/conditions/ColorConditionPosition.cpp
igui/OppositeRenderer
2442741792b3f0f426025c2015002694fab692eb
[ "MIT" ]
9
2016-06-25T15:52:05.000Z
2020-01-15T17:31:49.000Z
RPSolver/conditions/ColorConditionPosition.cpp
igui/OppositeRenderer
2442741792b3f0f426025c2015002694fab692eb
[ "MIT" ]
null
null
null
RPSolver/conditions/ColorConditionPosition.cpp
igui/OppositeRenderer
2442741792b3f0f426025c2015002694fab692eb
[ "MIT" ]
2
2018-10-17T18:33:37.000Z
2022-03-14T20:17:30.000Z
#include "ColorConditionPosition.h" #include "renderer/PMOptixRenderer.h" #include <QLocale> #include <QVector> #include <QColor> ColorConditionPosition::ColorConditionPosition(const QString& node, const optix::float3& hsvColor) : m_node(node), m_hsvColor(hsvColor) { } /// adapted from http://www.cs.rit.edu/~ncs/color/t_convert.html optix::float3 ColorConditionPosition::rgbColor() const { QColor color = QColor::fromHsvF(m_hsvColor.x / 360.f, m_hsvColor.y, m_hsvColor.z); return optix::make_float3(color.redF(), color.greenF(), color.blueF()); } void ColorConditionPosition::apply(PMOptixRenderer *renderer) const { renderer->setNodeDiffuseMaterialKd(m_node, rgbColor()); } optix::float3 ColorConditionPosition::hsvColor() const { return m_hsvColor; } float ColorConditionPosition::value() const { return m_hsvColor.z; } QString ColorConditionPosition::node() const { return m_node; } QVector<float> ColorConditionPosition::normalizedPosition() const { return QVector<float>() << value(); } QStringList ColorConditionPosition::info() const { QLocale locale; auto color = rgbColor(); auto x = locale.toString(color.x, 'f', 2); auto y = locale.toString(color.y, 'f', 2); auto z = locale.toString(color.z, 'f', 2); return QStringList() << x << y << z; }
23.648148
100
0.740016
igui
95e691961ebfa6bbdb05b501023cc8f9232bca74
470
cpp
C++
test/one_pole_test.cpp
hansen-audio/dsp-tool-box
4b73b39c4149b1a160ff9baa58830d6a4478feef
[ "MIT" ]
null
null
null
test/one_pole_test.cpp
hansen-audio/dsp-tool-box
4b73b39c4149b1a160ff9baa58830d6a4478feef
[ "MIT" ]
null
null
null
test/one_pole_test.cpp
hansen-audio/dsp-tool-box
4b73b39c4149b1a160ff9baa58830d6a4478feef
[ "MIT" ]
null
null
null
// Copyright(c) 2021 Hansen Audio. #include "ha/dsp_tool_box/filtering/one_pole.h" #include "gtest/gtest.h" using namespace ha::dtb::filtering; /** * @brief one_pole_test */ TEST(one_pole_test, test_one_pole_initialisation) { auto one_pole = OnePoleImpl::create(); EXPECT_FLOAT_EQ(one_pole.a, 0.9); EXPECT_FLOAT_EQ(one_pole.b, 0.1); EXPECT_FLOAT_EQ(one_pole.z, 0.0); } //-----------------------------------------------------------------------------
24.736842
79
0.595745
hansen-audio
95e822ec2193ba8a1afeec80b6386bec08906a22
376
cpp
C++
a12H.cpp
asokolsky/oddeven
44563d7efa07539335907dde9e17a9602b3e40fa
[ "BSD-2-Clause" ]
null
null
null
a12H.cpp
asokolsky/oddeven
44563d7efa07539335907dde9e17a9602b3e40fa
[ "BSD-2-Clause" ]
null
null
null
a12H.cpp
asokolsky/oddeven
44563d7efa07539335907dde9e17a9602b3e40fa
[ "BSD-2-Clause" ]
null
null
null
#include <iostream> #include <map> #include <string> #include <set> using namespace std; /** Напишите функцию BuildMapValuesSet, принимающую на вход словарь map<int, string> и возвращающую множество значений этого словаря: */ set <string> BuildMapValuesSet(const map<int, string>& m) { set <string> res; for(auto &elt: m) res.insert(elt.second); return res; }
18.8
129
0.715426
asokolsky
95e9041360dd5f89ac2c62dfce38d6eb5fbeea0b
12,094
cpp
C++
p3/src/org/cracs/stheno/core/p2p/p3/leaf/mesh/P3LeafMesh.cpp
rolandomar/stheno
6b41f56f25be1e7d56c8be4973203bf943e4f041
[ "Apache-2.0" ]
7
2015-08-17T16:24:22.000Z
2022-03-16T15:54:19.000Z
p3/src/org/cracs/stheno/core/p2p/p3/leaf/mesh/P3LeafMesh.cpp
rolandomar/stheno
6b41f56f25be1e7d56c8be4973203bf943e4f041
[ "Apache-2.0" ]
null
null
null
p3/src/org/cracs/stheno/core/p2p/p3/leaf/mesh/P3LeafMesh.cpp
rolandomar/stheno
6b41f56f25be1e7d56c8be4973203bf943e4f041
[ "Apache-2.0" ]
null
null
null
/* * Copyright 2012 Rolando Martins, CRACS & INESC-TEC, DCC/FCUP * * 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. * */ /* * File: P3LeafMesh.cpp * Author: rmartins * * Created on September 15, 2010, 11:44 AM */ #include "P3LeafMesh.h" #include <euryale/common/sleep/IncrementalSleep.h> //#include <stheno/core/p2p/p3/superpeer/cell/discovery/CellDiscovery.h> #include <stheno/core/p2p/p3/leaf/mesh/LeafMeshDiscovery.h> #include <stheno/core/p2p/p3/leaf/mesh/net/P3LeafMeshSap.h> #include <stheno/core/p2p/p3/leaf/mesh/net/LeafClientHandler.h> #include <ace/Sock_Connect.h> #include <ace/Connector.h> #include <stheno/core/p2p/p3/leaf/LeafPeer.h> #include <stheno/core/p2p/p3/mesh/net/P3MeshClientHandler.h> #include <stheno/common/TraceRuntime.h> P3LeafMesh::P3LeafMesh(Overlay* overlay) : Mesh(overlay), m_client(0) { } P3LeafMesh::~P3LeafMesh() { } void P3LeafMesh::open_i(ServiceParamsPtr& params, int fttype) throw (ServiceException&) { ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t|%T) INFO: P3LeafMesh::open_i(%d)\n"), m_status)); ACE_GUARD(ACE_SYNCH_RECURSIVE_MUTEX, ace_mon, m_lock); if (isStarting() /*|| isResuming()*/) { ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t|%T) INFO: P3LeafMesh::open_i starting(%d)\n"), m_status)); //Task::activate(); int maxBindTries = 10000; //IncrementalSleep sleeper(1,0); //IncrementalSleep sleeper(0,1000); IncrementalSleep sleeper(0, DEFAULT_BIND_TIME); m_start = ACE_OS::gettimeofday(); for (int i = 0; i < maxBindTries; i++) { try { bind(true); return; } catch (ServiceException& bindEx) { //discard bindEx sleeper.sleep(); } } ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t|%T) INFO: P3LeafMesh::open(): bind failed\n"))); throw ServiceException(ServiceException::REGISTRATION_ERROR); } else { ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t|%T) INFO: P3LeafMesh::open(): error\n"))); throw ServiceException(ServiceException::REGISTRATION_ERROR); } } void P3LeafMesh::close_i() throw (ServiceException&) { } void P3LeafMesh::bind(bool firstTime) throw (ServiceException&) { ACE_GUARD(ACE_SYNCH_RECURSIVE_MUTEX, ace_mon, m_lock); ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t|%T) INFO: P3LeafMesh::bind():open\n"))); UUIDPtr runtimeUUID; this->getUUID(runtimeUUID); LeafMeshDiscovery* discovery = new LeafMeshDiscovery(runtimeUUID); try { discovery->open(); } catch (CellException& ex) { delete discovery; throw ServiceException("Discovery failed to open!"); } CoordinatorInfo* coordInfo = discovery->requestCoordinator(); if (coordInfo == 0) { delete discovery; throw ServiceException("Error connecting to coordinator!"); } m_coordMeshSAP = coordInfo->getMeshSap(); m_fid = coordInfo->getCellID(); m_coordDiscoverySAP = coordInfo->getDiscoverySap(); m_coordinatorUUID = coordInfo->getPID(); ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t|%T) INFO: P3LeafMesh::bind() - DiscoverySAP=%@\n"), m_coordDiscoverySAP.get())); ACE_Connector<LeafClientHandler, ACE_SOCK_Connector> connector; CellID* cellID = new CellID(*coordInfo->getCellID().get()); CellIDPtr cellIDPtr(cellID); //LeafClientHandler* client = new LeafClientHandler(coordInfo->getPID(), cellIDPtr, this, false, false, 0, 0, 0, 0); ThreadPerConnection *tpc = new ThreadPerConnection(); /*ACE_Strong_Bound_Ptr<ThreadPerConnection, ACE_Recursive_Thread_Mutex>* tpcPrt*/ ExecutionModelPtr* tpcPrt = new ExecutionModelPtr (tpc); LeafClientHandler* client = new LeafClientHandler(coordInfo->getPID(), cellIDPtr, this, false, false, tpcPrt, 0, 0, 0); //tpc->open(); CPUQoS* cpuQoS = new CPUPriorityQoS(CPUQoS::SCHEDULE_RT_DEFAULT, CPUQoS::MAX_RT_PRIO); CPUReservation* reserve = 0; if (getQoSManager() != 0) { reserve = getQoSManager()->createCPUReservation("HRT", cpuQoS); } tpc->bind(client); tpc->open(reserve, cpuQoS); //tpc->bind(client); connector.reactor(tpc->getResources()->getReactor()); ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t|%T)INFO: P3LeafMesh - Connecting...(%s) client=%@!\n"), coordInfo->getPID()->toString().c_str(), client)); if (connector.connect(client, coordInfo->getCellCoordinatorEndpoint()->getAddr()) == -1) { ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t|%T)ERROR: P3LeafMesh - Error Connecting...(%s) client=%@!\n"), coordInfo->getPID()->toString().c_str(), client)); perror("P3LeafMesh="); /*ACE_ERROR((LM_ERROR, ACE_TEXT("(%T)%@\n"), ACE_TEXT("(%T)connect failed:")));*/ delete coordInfo; delete client; delete discovery; throw ServiceException("Error connecting to coordinator!"); } else { ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t|%T)INFO: P3LeafMesh:bind() - Connect OK!\n"))); delete discovery; delete coordInfo; m_client.reset(client); if (m_client->asynchronous(true,false) == -1) { //delete m_client; //m_client = 0; m_client.reset(0); throw ServiceException("Error connecting to coordinator (2)!"); } bool joinRet = client->joinMesh(getOverlay_i()->getType()); //m_client = client; if (m_client->setCloseListener(this) == -1) { //delete m_client; //m_client = 0; m_client.reset(0); throw ServiceException("Error connecting to coordinator (2)!"); } ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t|%T)INFO: P3LeafMesh:bind() - join(%d)\n"), joinRet)); } ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t|%T)INFO: P3LeafMesh:bind() - join end!\n"))); UUIDPtr fid; this->getFID(fid); TraceRuntimeSingleton::instance()->logBindToMesh(runtimeUUID,fid, m_coordinatorUUID, m_fid); if(firstTime){ ACE_Time_Value end = ACE_OS::gettimeofday(); end -= m_start; TraceRuntimeSingleton::instance()->logMembershipTime(end); }else{ ACE_Time_Value end = ACE_OS::gettimeofday(); end -= m_start; TraceRuntimeSingleton::instance()->logMembershipRebindTime(end); } //CellDiscovery* discovery = new CellDiscovery(this->getUUID()); //discovery->open(); //CellReply* info = discovery->requestCell(CellID::INVALID_CELL_ID_UUIDPTR); } void P3LeafMesh::getSAP(SAPInfoPtr& s) { ACE_GUARD(ACE_SYNCH_RECURSIVE_MUTEX, ace_mon, m_lock); s = m_sap->getSAPInfo(); } void P3LeafMesh::getCoordinatorDiscoverySAP(SAPInfoPtr& sapInfo) throw (ServiceException&){ ACE_GUARD(ACE_SYNCH_RECURSIVE_MUTEX, ace_mon, m_lock); sapInfo = m_coordDiscoverySAP; //return true; } void P3LeafMesh::getCoordinatorMeshSAP(SAPInfoPtr& coordSAP) throw (ServiceException&){ ACE_GUARD(ACE_SYNCH_RECURSIVE_MUTEX, ace_mon, m_lock); coordSAP = m_coordMeshSAP; } void P3LeafMesh::getCoordinatorUUID(UUIDPtr& uuid) throw (ServiceException&){ ACE_GUARD(ACE_SYNCH_RECURSIVE_MUTEX, ace_mon, m_lock); uuid = m_coordinatorUUID; } void P3LeafMesh::onClose(AbstractStreamChannel<ACE_SOCK_Stream, ACE_MT_SYNCH>* channel) { ACE_GUARD(ACE_SYNCH_RECURSIVE_MUTEX, ace_mon, m_lock); ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t|%T)INFO: P3LeafMesh:onClose() - (%@)\n"), channel)); /*if(m_client != channel){ ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t|%T)INFO: P3LeafMesh:onClose() - NOT m_client????????????(%@)\n"),channel)); }*/ channel->setCloseListener(0); m_client.reset(0); //delete channel; //m_client = 0; ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t|%T)INFO: P3LeafMesh:onClose() - after delete(%@)\n"), channel)); //m_client = 0; IncrementalSleep sleeper(0, DEFAULT_BIND_TIME); m_start = ACE_OS::gettimeofday(); while (true) { ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t|%T)INFO: P3LeafMesh:onClose() - loop with delete channel of (%@)\n"), channel)); try { bind(); break; } catch (ServiceException& ex) { //retry sleeper.sleep(); } } } LeafPeer* P3LeafMesh::getOverlay_i() { return static_cast<LeafPeer*> (m_overlay); } //opens a channel and tries to allocate a remote service void P3LeafMesh::createRemoteService(const SAPInfo* hint, const UUIDPtr& uuid, const UUIDPtr& sid, ServiceParamsPtr& params, UUIDPtr& iid) throw (ServiceException&) { ACE_GUARD(ACE_SYNCH_RECURSIVE_MUTEX, ace_mon, m_lock); if (hint == 0) { throw ServiceException(ServiceException::SERVICE_WITHOUT_IMPL); } Endpoint endpoint; ACE_Connector<P3MeshClientHandler, ACE_SOCK_Connector> connector; hint->getFirstEndpoint(endpoint); QoSEndpoint qosE = *(endpoint.getQoS()); UUIDPtr runtimeUUID; getUUID(runtimeUUID); UUIDPtr fid; getFID(fid); P3MeshClientHandler* clientHandler = new P3MeshClientHandler( runtimeUUID, fid, qosE, false, false, 0, 0, 0, 0); if (connector.connect(clientHandler, endpoint.getAddr()) == -1) { ACE_ERROR((LM_ERROR, ACE_TEXT("(%T)%@\n"), ACE_TEXT("(%T)ERROR: P3Mesh::createRemoteService - connect failed:"))); clientHandler->close(); clientHandler = 0; delete clientHandler; } else { ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t|%T)INFO: P3LeafMesh::createRemoteService - Connect OK!\n"))); } int ret = clientHandler->createService(params, iid); clientHandler->close(); delete clientHandler; if (ret == -1) { ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t|%T)INFO: P3LeafMesh::createRemoteService - failed to create, not enough resources\n"))); throw ServiceException(ServiceException::INSUFFICIENT_RESOURCES); } ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t|%T)INFO: P3LeafMesh::createRemoteService - service created!\n"))); } //close local & remote void P3LeafMesh::closeRemoteService(UUIDPtr& uuid, UUIDPtr& sid) throw (ServiceException&) { } QoSResources* P3LeafMesh::calculateQoSResources(ServiceParamsPtr& params) { return 0; } list<EndpointPtr>& P3LeafMesh::getEndpoints() throw (ServiceException&) { throw ServiceException(ServiceException::INVALID_ARGUMENT); } bool P3LeafMesh::updateInfo(InfoUpdatePtr& updateInfoPtr) { /*ACE_GUARD_RETURN(ACE_SYNCH_RECURSIVE_MUTEX, ace_mon, m_lock, false); if (m_client.null()) { return false; }*/ ACE_GUARD_RETURN(ACE_SYNCH_RECURSIVE_MUTEX, ace_mon, m_lock,false); LeafClientHandlerPtr clientHandler; getClientHandler(clientHandler); if (clientHandler.null()) { return false; } ace_mon.release(); return clientHandler->updateInfo(updateInfoPtr); } void P3LeafMesh::getUUID(UUIDPtr& uuid) { ACE_GUARD(ACE_SYNCH_RECURSIVE_MUTEX, ace_mon, m_lock); Mesh::getUUID(uuid); } void P3LeafMesh::getFID(UUIDPtr& fid) throw (ServiceException&) { ACE_GUARD(ACE_SYNCH_RECURSIVE_MUTEX, ace_mon, m_lock); fid = m_fid; } const char* P3LeafMesh::getName() { return "P3LeafMesh"; } PeerMapPtr& P3LeafMesh::getPeerMap() { return m_peerMap; } void P3LeafMesh::allocateQoS(QoSResources* qos) throw (ServiceException&) { } void P3LeafMesh::onAdd(AbstractStreamChannel<ACE_SOCK_Stream, ACE_MT_SYNCH>* channel) { } void P3LeafMesh::getClientHandler(LeafClientHandlerPtr& clientHandler) { ACE_GUARD(ACE_SYNCH_RECURSIVE_MUTEX, ace_mon, m_lock); clientHandler = m_client; }
37.559006
166
0.663966
rolandomar
95e986976ea930c1b1553927cad9a42a5c591183
28,297
cpp
C++
pass/bitwidth/pass_bitwidth.cpp
mfkiwl/livehd-fpga
a359adaab7cf2e54f0100a5bb6bf0431cfc8ae7e
[ "BSD-3-Clause" ]
1
2022-03-09T23:29:29.000Z
2022-03-09T23:29:29.000Z
pass/bitwidth/pass_bitwidth.cpp
mfkiwl/livehd-fpga
a359adaab7cf2e54f0100a5bb6bf0431cfc8ae7e
[ "BSD-3-Clause" ]
null
null
null
pass/bitwidth/pass_bitwidth.cpp
mfkiwl/livehd-fpga
a359adaab7cf2e54f0100a5bb6bf0431cfc8ae7e
[ "BSD-3-Clause" ]
null
null
null
// This file is distributed under the BSD 3-Clause License. See LICENSE for details. #include "pass_bitwidth.hpp" #include <algorithm> #include <cmath> #include <vector> #include "bitwidth_range.hpp" #include "lbench.hpp" #include "lgedgeiter.hpp" #include "lgraph.hpp" // Useful for debug //#define PRESERVE_ATTR_NODE static Pass_plugin sample("pass_bitwidth", Pass_bitwidth::setup); void Pass_bitwidth::setup() { Eprp_method m1("pass.bitwidth", "MIT algorithm for bitwidth optimization", &Pass_bitwidth::trans); m1.add_label_optional("max_iterations", "maximum number of iterations to try", "10"); m1.add_label_optional("hier", "hierarchical bitwidth", "false"); register_pass(m1); } Pass_bitwidth::Pass_bitwidth(const Eprp_var &var) : Pass("pass.bitwidth", var) { auto miters = var.get("max_iterations"); auto hier_txt = var.get("hier"); if (hier_txt != "false" && hier_txt != "0") hier = true; else hier = false; bool ok = absl::SimpleAtoi(miters, &max_iterations); if (!ok || max_iterations > 100 || max_iterations <= 0) { error("pass.bitwidth max_iterations:{} should be bigger than zero and less than 100", max_iterations); return; } } void Pass_bitwidth::trans(Eprp_var &var) { Pass_bitwidth p(var); std::vector<const LGraph *> lgs; for (const auto &l : var.lgs) { p.do_trans(l); } } void Pass_bitwidth::do_trans(LGraph *lg) { /* Lbench b("pass.bitwidth"); */ bw_pass(lg); } void Pass_bitwidth::process_const(Node &node) { auto dpin = node.get_driver_pin(); auto it = bwmap.emplace(dpin.get_compact(), Bitwidth_range(node.get_type_const())); forward_adjust_dpin(dpin, it.first->second); } void Pass_bitwidth::process_flop(Node &node) { I(node.has_sink_pin_connected(1)); auto d_dpin = node.get_sink_pin(1).get_driver_pin(); Lconst max_val; Lconst min_val; auto it3 = bwmap.find(d_dpin.get_compact()); if (it3 != bwmap.end()) { max_val = it3->second.get_max(); min_val = it3->second.get_min(); } else if (d_dpin.get_bits()) { Lconst b(1); max_val = b.lsh_op(d_dpin.get_bits()) - 1; } else if (node.get_driver_pin(0).get_bits()) { // At least propagate backward the width if (d_dpin.get_bits()==0 || d_dpin.get_bits() > node.get_driver_pin(0).get_bits()) d_dpin.set_bits(node.get_driver_pin(0).get_bits()); return; } else { if (d_dpin.has_name()) fmt::print("pass.bitwidth flop:{} has input pin:{} unconstrained\n", node.debug_name(), d_dpin.get_name()); else fmt::print("pass.bitwidth flop:{} has some inputs unconstrained\n", node.debug_name()); not_finished = true; return; } bwmap.emplace(node.get_driver_pin(0).get_compact(), Bitwidth_range(min_val, max_val)); } void Pass_bitwidth::process_not(Node &node, XEdge_iterator &inp_edges) { I(inp_edges.size()); // Dangling??? Lconst max_val; Lconst min_val; for (auto e : inp_edges) { auto it3 = bwmap.find(e.driver.get_compact()); if (it3 != bwmap.end()) { if (max_val < it3->second.get_max()) max_val = it3->second.get_max(); if (min_val == 0 || min_val > it3->second.get_min()) min_val = it3->second.get_min(); } else if (e.driver.get_bits()) { Lconst b(1); b = b.lsh_op(e.driver.get_bits()); if (b > max_val) max_val = b; min_val = Lconst(0) - max_val; } else { if (e.driver.has_name()) fmt::print("pass.bitwidth not:{} has input pin:{} unconstrained\n", node.debug_name(), e.driver.get_name()); else fmt::print("pass.bitwidth not:{} has some inputs unconstrained\n", node.debug_name()); not_finished = true; return; } } bwmap.emplace(node.get_driver_pin(0).get_compact(), Bitwidth_range(min_val, max_val)); } void Pass_bitwidth::process_mux(Node &node, XEdge_iterator &inp_edges) { I(inp_edges.size()); // Dangling??? Lconst max_val; Lconst min_val; for (auto e : inp_edges) { if (e.sink.get_pid() == 0) continue; // Skip select auto it = bwmap.find(e.driver.get_compact()); if (it != bwmap.end()) { if (max_val < it->second.get_max()) max_val = it->second.get_max(); if (min_val == 0 || min_val > it->second.get_min()) min_val = it->second.get_min(); } else if (e.driver.get_bits()) { Lconst b(1); b = b.lsh_op(e.driver.get_bits()) - 1; // TODO: sign handling if (b > max_val) max_val = b; min_val = Lconst(0); } else { if (e.driver.has_name()) fmt::print("pass.bitwidth mux:{} has input pin:{} unconstrained\n", node.debug_name(), e.driver.get_name()); else fmt::print("pass.bitwidth mux:{} has some inputs unconstrained\n", node.debug_name()); not_finished = true; return; } } Lconst n_options(inp_edges.size() - 1 - 1); // -1 for log and -1 for the select node.get_sink_pin(0).get_driver_pin().set_bits(n_options.get_bits()); Bitwidth_range bw(min_val, max_val); bwmap.emplace(node.get_driver_pin(0).get_compact(), bw); node.get_driver_pin(0).set_bits(bw.get_bits()); } void Pass_bitwidth::process_shr(Node &node, XEdge_iterator &inp_edges) { I(inp_edges.size() == 2); auto a_dpin = node.get_sink_pin(0).get_driver_pin(); auto n_dpin = node.get_sink_pin(1).get_driver_pin(); auto a_it = bwmap.find(a_dpin.get_compact()); auto n_it = bwmap.find(n_dpin.get_compact()); Bitwidth_range a_bw(0); if (a_it == bwmap.end()) { a_bw = Bitwidth_range(a_dpin.get_bits()); } else { a_bw = a_it->second; } Bitwidth_range n_bw(0); if (n_it == bwmap.end()) { n_bw = Bitwidth_range(n_dpin.get_bits()); } else { n_bw = n_it->second; } if (a_bw.get_bits() == 0 || n_bw.get_bits() == 0) { if (node.get_driver_pin().has_name()) fmt::print("pass.bitwidth shr:{} has input pin:{} unconstrained\n", node.debug_name(), node.get_driver_pin().get_name()); else fmt::print("pass.bitwidth shr:{} has some inputs unconstrained\n", node.debug_name()); return; } if (n_bw.get_min() > 0 && n_bw.get_min().is_i()) { auto max = a_bw.get_max(); auto min = a_bw.get_min(); auto amount = n_bw.get_min().to_i(); max = Lconst(max.get_raw_num() >> amount); min = Lconst(min.get_raw_num() >> amount); Bitwidth_range bw(min, max); bwmap.emplace(node.get_driver_pin().get_compact(), bw); node.get_driver_pin().set_bits(bw.get_bits()); } else { bwmap.emplace(node.get_driver_pin().get_compact(), a_bw); node.get_driver_pin().set_bits(a_bw.get_bits()); } } void Pass_bitwidth::process_sum(Node &node, XEdge_iterator &inp_edges) { I(inp_edges.size()); // Dangling sum??? (delete) Lconst max_val; Lconst min_val; for (auto e : inp_edges) { auto it = bwmap.find(e.driver.get_compact()); if (it != bwmap.end()) { if (e.sink.get_pid() == 0 || e.sink.get_pid() == 1) { max_val = max_val + it->second.get_max(); min_val = min_val + it->second.get_min(); } else { fmt::print("max_val:{}, pmax_val:{}\n", max_val.to_i(), it->second.get_max().to_i()); fmt::print("min_val:{}, pmin_val:{}\n", min_val.to_i(), it->second.get_min().to_i()); max_val = max_val - it->second.get_min(); min_val = min_val - it->second.get_max(); } } else if (e.driver.get_bits()) { Lconst b(1); b = b.lsh_op(e.driver.get_bits()) - 1; //FIXME->sh: Debug on Lconst(0) - Lconst(0xFFFF) = 0 ?? max_val = max_val + b; min_val = min_val + b; #if 0 if (e.sink.get_pid() == 0 || e.sink.get_pid() == 1) { max_val = max_val + b; min_val = min_val + b; } else { max_val = max_val - b; min_val = min_val - b; } #endif } else { if (e.driver.has_name()) fmt::print("pass.bitwidth sum:{} has input pin:{} unconstrained\n", node.debug_name(), e.driver.get_name()); else fmt::print("pass.bitwidth sum:{} has some inputs unconstrained\n", node.debug_name()); not_finished = true; return; } } bwmap.emplace(node.get_driver_pin(0).get_compact(), Bitwidth_range(min_val, max_val)); } void Pass_bitwidth::process_pick(Node &node) { auto data_dpin = node.get_sink_pin(0).get_driver_pin(); auto out_dpin = node.get_driver_pin(); auto it3 = bwmap.find(data_dpin.get_compact()); Bitwidth_range bw(out_dpin.get_bits()); if (it3 != bwmap.end()) { bw = it3->second; } else if (data_dpin.get_bits()) { bw = Bitwidth_range(data_dpin.get_bits()); } if (bw.get_bits() <= out_dpin.get_bits()) { bwmap.emplace(node.get_driver_pin(0).get_compact(), bw); } else { bwmap.emplace(node.get_driver_pin(0).get_compact(), Bitwidth_range(out_dpin.get_bits())); } } void Pass_bitwidth::process_comparator(Node &node) { bwmap.emplace(node.get_driver_pin(0).get_compact(), Bitwidth_range(1)); } void Pass_bitwidth::process_logic(Node &node, XEdge_iterator &inp_edges) { bool is_logic_op = node.has_driver_pin_connected(0); bool is_logic_reduction = node.has_driver_pin_connected(1); if (is_logic_reduction) { bwmap.emplace(node.get_driver_pin(1).get_compact(), Bitwidth_range(1)); } if (is_logic_op && inp_edges.size() >= 1) { Bits_t max_bits = 0; for (auto e : inp_edges) { auto it = bwmap.find(e.driver.get_compact()); Bits_t bits = 0; if (it == bwmap.end()) { bits = e.driver.get_bits(); } else { bits = it->second.get_bits(); } if (bits == 0) { if (e.driver.has_name()) { fmt::print("pass.bitwidth gate:{} has input pin:{} unconstrained\n", node.debug_name(), e.driver.get_name()); } else { fmt::print("pass.bitwidth gate:{} has some inputs unconstrained\n", node.debug_name()); } not_finished = true; return; } if (bits > max_bits) max_bits = bits; } bwmap.emplace(node.get_driver_pin(0).get_compact(), Bitwidth_range(max_bits)); } } void Pass_bitwidth::process_logic_and(Node &node, XEdge_iterator &inp_edges) { bool logic_op = node.has_driver_pin_connected(0); bool logic_reduction = node.has_driver_pin_connected(1); if (logic_reduction) { bwmap.emplace(node.get_driver_pin(1).get_compact(), Bitwidth_range(1)); } // determine the min_bits among all inp_edges if (logic_op && inp_edges.size() >= 1) { Bits_t min_bits = UINT16_MAX; for (auto e : inp_edges) { auto pit = bwmap.find(e.driver.get_compact()); Bits_t bits = 0; if (pit == bwmap.end()) { bits = e.driver.get_bits(); } else { bits = pit->second.get_bits(); } if (bits && bits < min_bits) min_bits = bits; } if (min_bits == UINT16_MAX) { fmt::print("pass.bitwidth and:{} does not have any constrained input\n", node.debug_name()); not_finished = true; return; } bwmap.emplace(node.get_driver_pin(0).get_compact(), Bitwidth_range(min_bits)); for (auto e : inp_edges) { auto bits = e.driver.get_bits(); if (bits) continue; // only handle unconstrained inputs if (e.driver.get_num_edges() > 1) { must_perform_backward = true; } else if (bits==0 || bits > min_bits) { // no other output, parent could follow the child e.driver.set_bits(min_bits); } } } } Pass_bitwidth::Attr Pass_bitwidth::get_key_attr(std::string_view key) { if (key.substr(0, 6) == "__bits") return Attr::Set_bits; if (key.substr(0, 5) == "__max") return Attr::Set_max; if (key.substr(0, 5) == "__min") return Attr::Set_min; if (key.substr(0, 11) == "__dp_assign") return Attr::Set_dp_assign; return Attr::Set_other; } void Pass_bitwidth::process_attr_get(Node &node) { I(node.has_sink_pin_connected(1)); auto dpin_key = node.get_sink_pin(1).get_driver_pin(); I(dpin_key.get_node().is_type(TupKey_Op)); auto key = dpin_key.get_name(); auto attr = get_key_attr(key); I(attr != Attr::Set_dp_assign); // Not get attr with __dp_assign if (attr == Attr::Set_other) { not_finished = true; return; } I(node.has_sink_pin_connected(0)); auto dpin_val = node.get_sink_pin(0).get_driver_pin(); auto it = bwmap.find(dpin_val.get_compact()); if (it == bwmap.end()) { not_finished = true; return; } auto &bw = it->second; Lconst result; if (attr == Attr::Set_bits) { result = Lconst(bw.get_bits()); } else if (attr == Attr::Set_max) { result = bw.get_max(); } else if (attr == Attr::Set_min) { result = bw.get_min(); } fmt::print("attr_get key:{} dpin0:{} const:{} node:{}\n", key, dpin_val.debug_name(), result.to_pyrope(), node.debug_name()); auto new_node = node.get_class_lgraph()->create_node_const(result); auto new_dpin = new_node.get_driver_pin(); for (auto &out : node.out_edges()) { new_dpin.connect_sink(out.sink); } //#ifndef PRESERVE_ATTR_NODE if (!hier) // FIXME: once hier del works node.del_node(); //#endif } void Pass_bitwidth::process_attr_set_dp_assign(Node &node) { auto dpin_variable = node.get_sink_pin(2).get_driver_pin(); auto dpin_value = node.get_sink_pin(0).get_driver_pin(); auto dpin_output = node.get_driver_pin(0); auto it = bwmap.find(dpin_variable.get_compact()); Bitwidth_range bw_variable(0); if (it != bwmap.end()) { bw_variable = it->second; } else if (dpin_variable.get_bits()) { bw_variable = Bitwidth_range(dpin_variable.get_bits()); } else { if (dpin_output.has_name()) fmt::print("pass.bitwidth {}:= is unconstrained\n", dpin_output.get_name()); else fmt::print("pass.bitwidth := is unconstrained (node:{})\n", node.debug_name()); return; } auto it2 = bwmap.find(dpin_value.get_compact()); Bitwidth_range bw_value(0); if (it2 != bwmap.end()) { bw_value = it2->second; } else if (dpin_variable.get_bits()) { bw_value = Bitwidth_range(dpin_value.get_bits()); } else { if (dpin_output.has_name()) fmt::print("pass.bitwidth {}:= node:{} is unconstrained\n", dpin_output.get_name(), dpin_variable.debug_name()); else fmt::print("pass.bitwidth := node:{} is unconstrained (node:{})\n", dpin_variable.debug_name(), node.debug_name()); return; } // fmt::print("attr_set_dp_assign name:{} variable_bits:{} bw_value:{} node:{}\n", dpin_variable.debug_name(), // bw_variable.get_bits(), bw_value.get_bits(), node.debug_name()); if (bw_value.get_bits() == 0 && bw_variable.get_bits() == 0) { // Can not solve now if (dpin_output.has_name()) fmt::print("pass.bitwidth {}:= is unconstrained\n", dpin_output.get_name()); else fmt::print("pass.bitwidth := is unconstrained (node:{})\n", node.debug_name()); return; } else { if (bw_value.get_bits() == 0) { fmt::print("pass.bitwidth := propagating bits:{} upwards to node:{}\n", bw_variable.get_bits(), dpin_value.debug_name()); dpin_value.set_bits(bw_variable.get_bits()); bwmap.emplace(dpin_value.get_compact(), bw_variable); return; } if (bw_variable.get_bits() == 0) { if (dpin_output.has_name()) fmt::print("pass.bitwidth {}:= is unconstrained\n", dpin_output.get_name()); else fmt::print("pass.bitwidth := is unconstrained (node:{})\n", node.debug_name()); return; } if (bw_value.get_bits() <= bw_variable.get_bits()) { // Already match for (auto e : node.out_edges()) { dpin_value.connect_sink(e.sink); } } else { // rhs.bits > lhs.bits --> drop rhs bits and reconnect auto new_node = node.get_class_lgraph()->create_node(Pick_Op); auto zero_node = node.get_class_lgraph()->create_node_const(Lconst(0)); auto zero_dpin = zero_node.setup_driver_pin(); auto new_dpin = new_node.get_driver_pin(); new_dpin.set_bits(bw_variable.get_bits()); dpin_value.connect_sink(new_node.setup_sink_pin(0)); zero_dpin.connect_sink(new_node.setup_sink_pin(1)); for (auto e : node.out_edges()) { new_dpin.connect_sink(e.sink); } } } if (!hier) // FIXME: once hier del works node.del_node(); fmt::print("DBG: delete dp_assign\n"); } void Pass_bitwidth::process_attr_set_new_attr(Node &node) { I(node.has_sink_pin_connected(1)); auto dpin_key = node.get_sink_pin(1).get_driver_pin(); auto key = dpin_key.get_name(); auto attr = get_key_attr(key); if (attr == Attr::Set_other) { not_finished = true; return; } if (attr == Attr::Set_dp_assign) { process_attr_set_dp_assign(node); return; } I(node.has_sink_pin_connected(2)); auto dpin_val = node.get_sink_pin(2).get_driver_pin(); if (!dpin_key.get_node().is_type(TupKey_Op)) { not_finished = true; return; // Can not handle now } I(dpin_key.has_name()); auto attr_dpin = node.get_driver_pin(0); std::string_view dpin_name; if (attr_dpin.has_name()) dpin_name = attr_dpin.get_name(); // copy parent's bw for some judgement and then update to attr_set value Bitwidth_range bw(0); bool parent_pending = false; if (node.has_sink_pin_connected(0)) { auto through_dpin = node.get_sink_pin(0).get_driver_pin(); auto it = bwmap.find(through_dpin.get_compact()); if (it != bwmap.end()) { bw = it->second; } else { parent_pending = true; } } // fmt::print("attr_set_new name:{} key:{} bw_bits:{} node:{}\n", dpin_name, key, bw.get_bits(), node.debug_name()); if (attr == Attr::Set_bits) { I(dpin_val.get_node().is_type_const()); auto val = dpin_val.get_node().get_type_const(); if (bw.get_bits() && bw.get_bits() > val.to_i()) { Pass::error("bitwidth missmatch. Variable {} needs {}bits, but constrained to {}bits\n", dpin_name, bw.get_bits(), val.to_i()); } else { if (bw.is_always_positive()) bw.set_ubits(val.to_i()); else bw.set_sbits(val.to_i()); } } else if (attr == Attr::Set_max) { I(false); // FIXME: todo } else if (attr == Attr::Set_min) { I(false); // FIXME: todo } else { I(false); // Attr::Set_dp_assign handled in another method } for (auto out_dpin : node.out_connected_pins()) { out_dpin.set_bits(bw.get_bits()); bwmap.emplace(out_dpin.get_compact(), bw); } // upwards propagate for one step node if (parent_pending) { auto through_dpin = node.get_sink_pin(0).get_driver_pin(); through_dpin.set_bits(bw.get_bits()); bwmap.emplace(through_dpin.get_compact(), bw); } // dpin_val.dump_all_prp_vname(); } void Pass_bitwidth::process_attr_set_propagate(Node &node) { auto attr_dpin = node.get_driver_pin(0); std::string_view dpin_name; if (attr_dpin.has_name()) dpin_name = attr_dpin.get_name(); I(node.has_sink_pin_connected(0)); bool parent_data_pending = false; auto data_dpin = node.get_sink_pin(0).get_driver_pin(); I(node.has_sink_pin_connected(3)); auto parent_attr_dpin = node.get_sink_pin(3).get_driver_pin(); Bitwidth_range data_bw(0); auto data_it = bwmap.find(data_dpin.get_compact()); if (data_it != bwmap.end()) { data_bw = data_it->second; } else { parent_data_pending = true; } /* if (data_it == bwmap.end()) { */ /* fmt::print("attr_set propagate bwmap to AttrSet name:{}\n", dpin_name); */ /* not_finished = true; */ /* return; */ /* } */ /* auto &data_bw = data_it->second; */ auto parent_attr_it = bwmap.find(parent_attr_dpin.get_compact()); if (parent_attr_it == bwmap.end()) { fmt::print("attr_set propagate bwmap to AttrSet name:{}\n", dpin_name); not_finished = true; return; } const auto parent_attr_bw = parent_attr_it->second; fmt::print("attr_set_prop name:{} parent_attr.bits:{} data_bw.bits:{}\n", dpin_name, parent_attr_bw.get_bits(), data_bw.get_bits()); if (parent_attr_bw.get_bits() && data_bw.get_bits()) { if (parent_attr_bw.get_bits() < data_bw.get_bits()) { Pass::error("bitwidth missmatch. Variable {} needs {}bits, but constrained to {}bits\n", dpin_name, data_bw.get_bits(), parent_attr_bw.get_bits()); } else if (parent_attr_bw.get_max() < data_bw.get_max()) { Pass::error("bitwidth missmatch. Variable {} needs {}max, but constrained to {}max\n", dpin_name, data_bw.get_max().to_pyrope(), parent_attr_bw.get_max().to_pyrope()); } else if (parent_attr_bw.get_min() > data_bw.get_min()) { Pass::error("bitwidth missmatch. Variable {} needs {}min, but constrained to {}min\n", dpin_name, data_bw.get_min().to_pyrope(), parent_attr_bw.get_min().to_pyrope()); } } for (auto out_dpin : node.out_connected_pins()) { out_dpin.set_bits(parent_attr_bw.get_bits()); bwmap.emplace(out_dpin.get_compact(), parent_attr_bw); } if (parent_data_pending) { data_dpin.set_bits(parent_attr_bw.get_bits()); fmt::print("data_dpin:{}\n", data_dpin.debug_name()); fmt::print("data_dpin bits:{}\n", data_dpin.get_bits()); bwmap.emplace(data_dpin.get_compact(), parent_attr_bw); } } void Pass_bitwidth::process_attr_set(Node &node) { if (node.has_sink_pin_connected(1)) { process_attr_set_new_attr(node); } else { process_attr_set_propagate(node); } } // focusing on judging the parent is garbage or not void Pass_bitwidth::garbage_collect_support_structures(XEdge_iterator &inp_edges) { for (auto e : inp_edges) { auto pit = outcountmap.find(e.driver.get_node().get_compact()); // pit = parent iterator if (pit == outcountmap.end()) { continue; // parent node not yet visited } auto n = pit->second; if (n <= 1) { // I'm the only child, the parent bw_range object could be recycled outcountmap.erase(pit); for (auto parent_dpin : e.driver.get_node().out_connected_pins()) { auto it2 = bwmap.find(parent_dpin.get_compact()); if (it2 != bwmap.end()) { // Not all the nodes create bwmap (impossible to infer do not) forward_adjust_dpin(parent_dpin, it2->second); bwmap.erase(it2); } } } else { pit->second = n - 1; } } } void Pass_bitwidth::forward_adjust_dpin(Node_pin &dpin, Bitwidth_range &bw) { auto bw_bits = bw.get_bits(); if (bw_bits && bw_bits < dpin.get_bits()) { // fmt::print("bitwidth: bits:{}->{} for dpin:{}\n", dpin.get_bits(), bw_bits, dpin.debug_name()); dpin.set_bits(bw_bits); } } void Pass_bitwidth::set_graph_boundary(Node_pin &dpin, Node_pin &spin) { I(hier); // do not call unless hierarchy is set if (dpin.get_class_lgraph() == spin.get_class_lgraph()) return; I(dpin.get_hidx() != spin.get_hidx()); auto same_level_spin = spin.get_non_hierarchical(); for (auto dpin_sub:same_level_spin.inp_driver()) { if (!dpin_sub.get_node().is_type(SubGraph_Op)) continue; if (dpin_sub.get_bits()==0 || dpin_sub.get_bits() > dpin.get_bits()) dpin_sub.set_bits(dpin.get_bits()); } } void Pass_bitwidth::bw_pass(LGraph *lg) { must_perform_backward = false; not_finished = false; for(auto dpin:lg->get_graph_input_node(hier).out_setup_pins()) { if (dpin.get_bits()) bwmap.emplace(dpin.get_compact(), Bitwidth_range(dpin.get_bits())); } outcountmap[lg->get_graph_input_node(hier).get_compact()] = lg->get_graph_input_node(hier).get_num_out_edges(); for (auto node : lg->forward(hier)) { auto inp_edges = node.inp_edges(); auto op = node.get_type_op(); //fmt::print("bitwidth node:{} lg:{}\n", node.debug_name(), node.get_class_lgraph()->get_name()); if (inp_edges.empty() && (op != Const_Op && op != SubGraph_Op && op != LUT_Op && op != TupKey_Op)) { fmt::print("pass.bitwidth: removing dangling node:{}\n", node.debug_name()); fmt::print("node:{}\n", node.debug_name()); if (!hier) // FIXME: once hier del works node.del_node(); continue; } outcountmap[node.get_compact()] = node.get_num_out_edges(); if (op == Const_Op) { process_const(node); } else if (op == TupKey_Op || op == TupGet_Op || op == TupAdd_Op) { // Nothing to do for this } else if (op == Or_Op || op == Xor_Op) { process_logic(node, inp_edges); } else if (op == And_Op) { process_logic_and(node, inp_edges); } else if (op == AttrSet_Op) { process_attr_set(node); if (node.is_invalid()) continue; } else if (op == AttrGet_Op) { process_attr_get(node); if (node.is_invalid()) continue; } else if (op == Sum_Op) { process_sum(node, inp_edges); } else if (op == ShiftRight_Op) { process_shr(node, inp_edges); } else if (op == Not_Op) { process_not(node, inp_edges); } else if (op == SFlop_Op || op == AFlop_Op || op == FFlop_Op) { process_flop(node); } else if (op == Mux_Op) { process_mux(node, inp_edges); } else if (op == GreaterThan_Op || op == LessThan_Op || op == LessEqualThan_Op || op == Equals_Op || op == GreaterEqualThan_Op) { process_comparator(node); } else if (op == Pick_Op) { process_pick(node); } else { fmt::print("FIXME: node:{} still not handled by bitwidth\n", node.debug_name()); } if (hier) { for (auto e:inp_edges) { set_graph_boundary(e.driver, e.sink); } } for (auto dpin : node.out_connected_pins()) { auto it = bwmap.find(dpin.get_compact()); if (it == bwmap.end()) continue; auto bw_bits = it->second.get_bits(); if (bw_bits == 0 && it->second.is_overflow()) { fmt::print("bitwidth: dpin:{} has over {}bits (simplify first!)\n", dpin.debug_name(), it->second.get_raw_max()); continue; } if (dpin.get_bits() && dpin.get_bits() >= bw_bits) continue; dpin.set_bits(bw_bits); } garbage_collect_support_structures(inp_edges); } for(auto dpin:lg->get_graph_output_node(hier).out_setup_pins()) { auto spin = dpin.get_sink_from_output(); if (!spin.has_inputs()) continue; auto out_driver = spin.get_driver_pin(); I(!out_driver.is_invalid()); auto it = bwmap.find(out_driver.get_compact()); if (it != bwmap.end()) { forward_adjust_dpin(out_driver, it->second); bwmap.erase(it); } if (out_driver.get_bits()) { dpin.set_bits(out_driver.get_bits()); if (hier) set_graph_boundary(out_driver, spin); } /* if (out_driver.get_bits()) { */ /* if (dpin.get_bits()) { // output has been attr set bits */ /* if (dpin.get_bits() > out_driver.get_bits()) { */ /* return; */ /* } */ /* } */ /* dpin.set_bits(out_driver.get_bits()); */ /* } */ } #ifndef PRESERVE_ATTR_NODE if (not_finished) { fmt::print("pass_bitwidth: could not converge\n"); } else { // FIXME: this code may need to move to cprop if we have several types of // attributes. Delete only if all the attributes are finished // // Delete all the attr_set/get for bitwidth for (auto node : lg->fast()) { auto op = node.get_type_op(); if (op == AttrSet_Op) { if (node.has_sink_pin_connected(1)) { auto key_dpin = node.get_sink_pin(1).get_driver_pin(); auto attr = get_key_attr(key_dpin.get_name()); if (attr == Attr::Set_other) continue; } if (node.has_sink_pin_connected(0)) { auto data_dpin = node.get_sink_pin(0).get_driver_pin(); for (auto e : node.out_edges()) { if (e.driver.get_pid() == 0) { e.sink.connect_driver(data_dpin); } } } if (!hier) // FIXME: once hier del works node.del_node(); } else if (op == AttrGet_Op) { I(false); // should be deleted by now if solved } } } #endif if (must_perform_backward) { fmt::print("pass_bitwidth: some nodes need to back propagate width\n"); } }
32.228929
127
0.627699
mfkiwl
95eb334cf721182b79ae1a9102b49ddcbb973767
10,292
cpp
C++
newton-4.00/applications/ndSandbox/demos/ndBasicStacks.cpp
Libertus-Lab/newton-dynamics
af6e6635c7f563c697b8e5b088d68ba24fa8fe9c
[ "Zlib" ]
null
null
null
newton-4.00/applications/ndSandbox/demos/ndBasicStacks.cpp
Libertus-Lab/newton-dynamics
af6e6635c7f563c697b8e5b088d68ba24fa8fe9c
[ "Zlib" ]
null
null
null
newton-4.00/applications/ndSandbox/demos/ndBasicStacks.cpp
Libertus-Lab/newton-dynamics
af6e6635c7f563c697b8e5b088d68ba24fa8fe9c
[ "Zlib" ]
null
null
null
/* Copyright (c) <2003-2021> <Newton Game Dynamics> * * This software is provided 'as-is', without any express or implied * warranty. In no event will the authors be held liable for any damages * arising from the use of this software. * * Permission is granted to anyone to use this software for any purpose, * including commercial applications, and to alter it and redistribute it * freely */ #include "ndSandboxStdafx.h" #include "ndSkyBox.h" #include "ndTargaToOpenGl.h" #include "ndDemoMesh.h" #include "ndDemoCamera.h" #include "ndPhysicsUtils.h" #include "ndPhysicsWorld.h" #include "ndMakeStaticMap.h" #include "ndDemoEntityManager.h" #include "ndDemoInstanceEntity.h" static ndBodyDynamic* AddRigidBody(ndDemoEntityManager* const scene, const ndMatrix& matrix, const ndShapeInstance& shape, ndDemoInstanceEntity* const rootEntity, ndFloat32 mass) { ndBodyDynamic* const body = new ndBodyDynamic(); ndDemoEntity* const entity = new ndDemoEntity(matrix, rootEntity); body->SetNotifyCallback(new ndDemoEntityNotify(scene, entity)); body->SetMatrix(matrix); body->SetCollisionShape(shape); body->SetMassMatrix(mass, shape); ndWorld* const world = scene->GetWorld(); world->AddBody(body); return body; } static void BuildSphereColumn(ndDemoEntityManager* const scene, ndFloat32 mass, const ndVector& origin, const ndVector& size, ndInt32 count) { // build a standard block stack of 20 * 3 boxes for a total of 60 ndWorld* const world = scene->GetWorld(); ndVector blockBoxSize(size); // create the stack ndMatrix baseMatrix(dGetIdentityMatrix()); // for the elevation of the floor at the stack position baseMatrix.m_posit.m_x = origin.m_x; baseMatrix.m_posit.m_z = origin.m_z; ndVector floor(FindFloor(*world, baseMatrix.m_posit + ndVector(0.0f, 100.0f, 0.0f, 0.0f), 200.0f)); baseMatrix.m_posit.m_y = floor.m_y + blockBoxSize.m_x; ndShapeInstance shape(new ndShapeSphere(blockBoxSize.m_x)); ndDemoMeshIntance* const geometry = new ndDemoMeshIntance("shape", scene->GetShaderCache(), &shape, "earthmap.tga", "earthmap.tga", "earthmap.tga", 1.0f, dRollMatrix (ndFloat32 (-90.0f) * ndDegreeToRad)); ndDemoInstanceEntity* const rootEntity = new ndDemoInstanceEntity(geometry); scene->AddEntity(rootEntity); for (ndInt32 i = 0; i < count; i++) { AddRigidBody(scene, baseMatrix, shape, rootEntity, mass); baseMatrix.m_posit += baseMatrix.m_up.Scale(blockBoxSize.m_x * 2.0f); } geometry->Release(); } static void BuildBoxColumn(ndDemoEntityManager* const scene, ndFloat32 mass, const ndVector& origin, const ndVector& size, ndInt32 count) { // build a standard block stack of 20 * 3 boxes for a total of 60 ndWorld* const world = scene->GetWorld(); ndVector blockBoxSize(size); blockBoxSize = blockBoxSize.Scale(2.0f); // create the stack ndMatrix baseMatrix(dGetIdentityMatrix()); // for the elevation of the floor at the stack position baseMatrix.m_posit.m_x = origin.m_x; baseMatrix.m_posit.m_z = origin.m_z; ndVector floor(FindFloor(*world, baseMatrix.m_posit + ndVector(0.0f, 100.0f, 0.0f, 0.0f), 200.0f)); baseMatrix.m_posit.m_y = floor.m_y + blockBoxSize.m_y * 0.5f; ndShapeInstance shape(new ndShapeBox(blockBoxSize.m_x, blockBoxSize.m_y, blockBoxSize.m_z)); ndDemoMeshIntance* const geometry = new ndDemoMeshIntance("shape", scene->GetShaderCache(), &shape, "wood_0.tga", "wood_0.tga", "wood_0.tga"); ndDemoInstanceEntity* const rootEntity = new ndDemoInstanceEntity(geometry); scene->AddEntity(rootEntity); //baseMatrix.m_posit.m_y -= 0.02f; ndMatrix rotation(dYawMatrix(20.0f * ndDegreeToRad)); for (ndInt32 i = 0; i < count; i++) { AddRigidBody(scene, baseMatrix, shape, rootEntity, mass); baseMatrix.m_posit += baseMatrix.m_up.Scale(blockBoxSize.m_x); baseMatrix = rotation * baseMatrix; } geometry->Release(); } static void BuildCylinderColumn(ndDemoEntityManager* const scene, ndFloat32 mass, const ndVector& origin, const ndVector& size, ndInt32 count) { // build a standard block stack of 20 * 3 boxes for a total of 60 ndWorld* const world = scene->GetWorld(); ndVector blockBoxSize(size); // create the stack ndMatrix baseMatrix(dGetIdentityMatrix()); // for the elevation of the floor at the stack position baseMatrix.m_posit.m_x = origin.m_x; baseMatrix.m_posit.m_z = origin.m_z; ndVector floor(FindFloor(*world, baseMatrix.m_posit + ndVector(0.0f, 100.0f, 0.0f, 0.0f), 200.0f)); baseMatrix.m_posit.m_y = floor.m_y + blockBoxSize.m_z * 0.5f; ndShapeInstance shape(new ndShapeCylinder(blockBoxSize.m_x, blockBoxSize.m_y, blockBoxSize.m_z)); shape.SetLocalMatrix(dRollMatrix(ndPi * 0.5f)); ndDemoMeshIntance* const geometry = new ndDemoMeshIntance("shape", scene->GetShaderCache(), &shape, "wood_0.tga", "wood_0.tga", "wood_0.tga"); ndDemoInstanceEntity* const rootEntity = new ndDemoInstanceEntity(geometry); scene->AddEntity(rootEntity); ndMatrix rotation(dYawMatrix(20.0f * ndDegreeToRad)); for (ndInt32 i = 0; i < count; i++) { AddRigidBody(scene, baseMatrix, shape, rootEntity, mass); baseMatrix.m_posit += baseMatrix.m_up.Scale(blockBoxSize.m_z); baseMatrix = rotation * baseMatrix; } geometry->Release(); } static void BuildPyramid(ndDemoEntityManager* const scene, ndDemoInstanceEntity* const rootEntity, const ndShapeInstance& shape, ndFloat32 mass, const ndVector& origin, const ndVector& boxSize, ndInt32 count) { ndMatrix matrix(dGetIdentityMatrix()); matrix.m_posit = origin; matrix.m_posit.m_w = 1.0f; // create the shape and visual mesh as a common data to be re used ndWorld* const world = scene->GetWorld(); ndVector floor(FindFloor(*world, origin + ndVector(0.0f, 100.0f, 0.0f, 0.0f), 200.0f)); matrix.m_posit.m_y = floor.m_y; ndFloat32 stepz = boxSize.m_z + 1.0e-2f; ndFloat32 stepy = boxSize.m_y + 1.0e-2f; stepy = boxSize.m_y; ndFloat32 y0 = matrix.m_posit.m_y + stepy / 2.0f; ndFloat32 z0 = matrix.m_posit.m_z - stepz * count / 2; matrix.m_posit.m_y = y0; matrix.m_posit.m_y -= 0.01f; for (ndInt32 j = 0; j < count; j++) { matrix.m_posit.m_z = z0; for (ndInt32 i = 0; i < (count - j); i++) { AddRigidBody(scene, matrix, shape, rootEntity, mass); matrix.m_posit.m_z += stepz; } z0 += stepz * 0.5f; matrix.m_posit.m_y += stepy; } } void BuildPyramidStacks(ndDemoEntityManager* const scene, ndFloat32 mass, const ndVector& origin, const ndVector& boxSize, ndInt32 stackHigh) { ndVector origin1(origin); ndVector size(boxSize.Scale(1.0f)); ndShapeInstance shape(new ndShapeBox(size.m_x, size.m_y, size.m_z)); ndDemoMeshIntance* const geometry = new ndDemoMeshIntance("shape", scene->GetShaderCache(), &shape, "wood_0.tga", "wood_0.tga", "wood_0.tga"); ndDemoInstanceEntity* const rootEntity = new ndDemoInstanceEntity(geometry); scene->AddEntity(rootEntity); origin1.m_z = 0.0f; origin1.m_x += 3.0f; BuildPyramid(scene, rootEntity, shape, mass, origin1, boxSize, stackHigh); geometry->Release(); } static void BuildCapsuleStack(ndDemoEntityManager* const scene, ndFloat32 mass, const ndVector& origin, const ndVector& size, ndInt32 stackHigh) { // build a standard block stack of 20 * 3 boxes for a total of 60 ndWorld* const world = scene->GetWorld(); ndVector blockBoxSize(size); // create the stack ndMatrix baseMatrix(dGetIdentityMatrix()); // for the elevation of the floor at the stack position baseMatrix.m_posit.m_x = origin.m_x; baseMatrix.m_posit.m_z = origin.m_z; ndFloat32 startElevation = 100.0f; ndVector floor(FindFloor(*world, ndVector(baseMatrix.m_posit.m_x, startElevation, baseMatrix.m_posit.m_z, 0.0f), 2.0f * startElevation)); baseMatrix.m_posit.m_y = floor.m_y + blockBoxSize.m_y; // create the shape and visual mesh as a common data to be re used ndShapeInstance collision(new ndShapeCapsule(blockBoxSize.m_x, blockBoxSize.m_x, blockBoxSize.m_z)); ndMatrix uvMatrix(dPitchMatrix(ndPi)); ndDemoMeshIntance* const geometry = new ndDemoMeshIntance("shape", scene->GetShaderCache(), &collision, "smilli.tga", "smilli.tga", "smilli.tga"); ndFloat32 vertialStep = blockBoxSize.m_x * 2.0f; ndFloat32 horizontalStep = blockBoxSize.m_z * 0.8f; ndMatrix matrix0(dGetIdentityMatrix()); matrix0.m_posit = origin; matrix0.m_posit.m_y += blockBoxSize.m_x; matrix0.m_posit.m_w = 1.0f; ndMatrix matrix1(matrix0); matrix1.m_posit.m_z += horizontalStep; ndMatrix matrix2(dYawMatrix(ndPi * 0.5f) * matrix0); matrix2.m_posit.m_x += horizontalStep * 0.5f; matrix2.m_posit.m_z += horizontalStep * 0.5f; matrix2.m_posit.m_y += vertialStep; ndMatrix matrix3(matrix2); matrix3.m_posit.m_x -= horizontalStep; ndDemoInstanceEntity* const rootEntity = new ndDemoInstanceEntity(geometry); scene->AddEntity(rootEntity); for (ndInt32 i = 0; i < stackHigh / 2; i++) { AddRigidBody(scene, matrix0, collision, rootEntity, mass); AddRigidBody(scene, matrix1, collision, rootEntity, mass); AddRigidBody(scene, matrix2, collision, rootEntity, mass); AddRigidBody(scene, matrix3, collision, rootEntity, mass); matrix0.m_posit.m_y += vertialStep * 2.0f; matrix1.m_posit.m_y += vertialStep * 2.0f; matrix2.m_posit.m_y += vertialStep * 2.0f; matrix3.m_posit.m_y += vertialStep * 2.0f; } // do not forget to release the assets geometry->Release(); } void ndBasicStacks (ndDemoEntityManager* const scene) { // build a floor BuildFlatPlane(scene, true); ndVector origin(ndVector::m_zero); //ndInt32 pyramidHigh = 20; ndInt32 pyramidHigh = 30; //ndInt32 pyramidHigh = 60; for (ndInt32 i = 0; i < 4; i++) { BuildPyramidStacks(scene, 1.0f, origin, ndVector(0.5f, 0.25f, 0.8f, 0.0f), pyramidHigh); origin.m_x += 4.0f; } origin = ndVector::m_zero; origin.m_x -= 2.0f; origin.m_z -= 3.0f; BuildSphereColumn(scene, 10.0f, origin, ndVector(0.5f, 0.5f, 0.5f, 0.0f), 20); origin.m_z += 6.0f; BuildBoxColumn(scene, 10.0f, origin, ndVector(0.5f, 0.5f, 0.5f, 0.0f), 20); origin.m_z += 6.0f; BuildCylinderColumn(scene, 10.0f, origin, ndVector(0.75f, 0.6f, 1.0f, 0.0f), 20); origin.m_x -= 6.0f; origin.m_z -= 6.0f; BuildCapsuleStack(scene, 10.0f, origin, ndVector(0.25f, 0.25f, 2.0f, 0.0f), 20); ndQuaternion rot(dYawMatrix (45.0f * ndDegreeToRad)); origin = ndVector::m_zero; origin.m_x -= 3.0f; origin.m_y += 5.0f; origin.m_x -= 15.0f; origin.m_z += 15.0f; scene->SetCameraMatrix(rot, origin); }
34.192691
205
0.735717
Libertus-Lab
95ebda8d3be8708b52ecab9bc614b240388f153f
944
cpp
C++
codeforces/1567B.cpp
sgrade/cpptest
84ade6ec03ea394d4a4489c7559d12b4799c0b62
[ "MIT" ]
null
null
null
codeforces/1567B.cpp
sgrade/cpptest
84ade6ec03ea394d4a4489c7559d12b4799c0b62
[ "MIT" ]
null
null
null
codeforces/1567B.cpp
sgrade/cpptest
84ade6ec03ea394d4a4489c7559d12b4799c0b62
[ "MIT" ]
null
null
null
// B. MEXor Mixup #include <iostream> using namespace std; // Method to calculate xor int computeXOR(int n) { // Source - https://www.geeksforgeeks.org/calculate-xor-1-n/ // If n is a multiple of 4 if (n % 4 == 0) { return n; } // If n%4 gives remainder 1 if (n % 4 == 1) { return 1; } // If n%4 gives remainder 2 if (n % 4 == 2) { return n + 1; } // If n%4 gives remainder 3 return 0; } int main() { int t; cin >> t; while (t--) { int a, b; cin >> a >> b; int ans; // Editorial - https://codeforces.com/blog/entry/94581 int x = computeXOR(a-1); if (x == b) { ans = a; } else { if ((x ^ b) != a) { ans = a + 1; } else { ans = a + 2; } } cout << ans << endl; } }
15.225806
64
0.400424
sgrade
95ec924801c63c19c0604cdbd92f81fcfb7c89c5
2,081
cpp
C++
lib/netdata/fragments_server.cpp
siilky/catomania
cb3a05cbef523d16b8929b390e190e0cd5924ee9
[ "MIT" ]
1
2021-02-05T23:20:07.000Z
2021-02-05T23:20:07.000Z
lib/netdata/fragments_server.cpp
siilky/catomania
cb3a05cbef523d16b8929b390e190e0cd5924ee9
[ "MIT" ]
null
null
null
lib/netdata/fragments_server.cpp
siilky/catomania
cb3a05cbef523d16b8929b390e190e0cd5924ee9
[ "MIT" ]
null
null
null
#include "stdafx.h" #include "netdata/fragments_server.h" namespace serverdata { static const fragmentCollection_t fragments[] = { COLLECTION_ELEMENT(Array), COLLECTION_ELEMENT(ArrayPacked), COLLECTION_ELEMENT(GameinfoSet), COLLECTION_ELEMENT(AccInfo), COLLECTION_ELEMENT(ErrorInfo), COLLECTION_ELEMENT(StatusAnnounce), COLLECTION_ELEMENT(PlayerLogout), COLLECTION_ELEMENT(SelectRoleRe), // 50 COLLECTION_ELEMENT(ChatMessage), COLLECTION_ELEMENT(CreateRoleRe), COLLECTION_ELEMENT(RoleListRe), COLLECTION_ELEMENT(Keepalive), COLLECTION_ELEMENT(PlayerBaseInfoRe), // 60 COLLECTION_ELEMENT(PrivateChat), COLLECTION_ELEMENT(BannedMessage), COLLECTION_ELEMENT(WorldChat), COLLECTION_ELEMENT(LoginIpInfo), COLLECTION_ELEMENT(GetFriendsRe), COLLECTION_ELEMENT(SetLockTimeRe), COLLECTION_ELEMENT(BattleGetMapRe), COLLECTION_ELEMENT(BattleChallengeMapRe), // COLLECTION_ELEMENT(ComissionShop), COLLECTION_ELEMENT(ComissionShopList), COLLECTION_ELEMENT(TradeStartRe), COLLECTION_ELEMENT(TradeRequest), COLLECTION_ELEMENT(TradeAddGoodsRe), COLLECTION_ELEMENT(TradeRemoveGoodsRe), COLLECTION_ELEMENT(TradeSubmitRe), COLLECTION_ELEMENT(TradeConfirmRe), COLLECTION_ELEMENT(TradeDiscardRe), COLLECTION_ELEMENT(TradeEnd), // 1200 COLLECTION_ELEMENT(FactionChat), COLLECTION_ELEMENT(GetFactionBaseInfoRe), COLLECTION_ELEMENT(ACWhoami), COLLECTION_ELEMENT(ACRemoteCode), COLLECTION_ELEMENT(ACProtoStat), COLLECTION_ELEMENT(ACStatusAnnounce), COLLECTION_ELEMENT(ACReportCheater), COLLECTION_ELEMENT(ACTriggerQuestion), COLLECTION_ELEMENT(ACQuestion), COLLECTION_ELEMENT(ACAnswer), COLLECTION_END }; FragmentFactory fragmentFactory(identifyFragment, fragments, fragment_static_ctor<Fragment>); } // namespace
32.515625
97
0.702547
siilky
95ee1c3d622ff6dcfa592566fe594b9f5361bf48
359
cpp
C++
example/shm_status.cpp
unhuman-io/motor-realtime
1aee682954096c28c9a3f01546261499052c4e0b
[ "Unlicense" ]
null
null
null
example/shm_status.cpp
unhuman-io/motor-realtime
1aee682954096c28c9a3f01546261499052c4e0b
[ "Unlicense" ]
null
null
null
example/shm_status.cpp
unhuman-io/motor-realtime
1aee682954096c28c9a3f01546261499052c4e0b
[ "Unlicense" ]
1
2021-04-05T18:14:51.000Z
2021-04-05T18:14:51.000Z
#include <motor_manager.h> #include <thread> #include <motor_subscriber.h> int main() { MotorSubscriber<MotorStatus> sub; while(1) { MotorStatus status = sub.read(); std::vector<MotorStatus> statuses(1, status); std::cout << statuses << std::endl; std::this_thread::sleep_for(std::chrono::milliseconds(100)); } }
23.933333
68
0.635097
unhuman-io
95eead97864fb897edd4dd8a2cbc86b300d5d66f
775
cpp
C++
graph-source-code/296-D/10047350.cpp
AmrARaouf/algorithm-detection
59f3028d2298804870b32729415d71eec6116557
[ "MIT" ]
null
null
null
graph-source-code/296-D/10047350.cpp
AmrARaouf/algorithm-detection
59f3028d2298804870b32729415d71eec6116557
[ "MIT" ]
null
null
null
graph-source-code/296-D/10047350.cpp
AmrARaouf/algorithm-detection
59f3028d2298804870b32729415d71eec6116557
[ "MIT" ]
null
null
null
//Language: GNU C++ //In the name of God #include <iostream> #include <algorithm> #include <vector> #include <cstdlib> #include <map> #include <cstdio> using namespace std; #define mp make_pair #define X first #define Y second #define lol long long const int MAXN=510; lol dis[MAXN][MAXN],a[MAXN],ans[MAXN]; int main() { int n; cin>>n; for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) cin>>dis[i][j]; for(int i=1;i<=n;i++) cin>>a[i]; for(int i=n;i>0;i--) { for(int j=1;j<=n;j++) for(int k=1;k<=n;k++) dis[a[j]][a[k]]=min(dis[a[j]][a[k]],dis[a[j]][a[i]]+dis[a[i]][a[k]]); for(int j=i;j<=n;j++) for(int k=i;k<=n;k++) ans[i]+=dis[a[j]][a[k]]; } for(int i=1;i<=n;i++) cout<<ans[i]<<" "; cout<<endl; return 0; }
17.613636
72
0.536774
AmrARaouf
95f2057d92060a6141b994aa38b25df57f1633d8
450
cpp
C++
Project/Zombienator/Layer.cpp
Jallah123/TheZombienator
efbcb93b0b2943cd9b38ac84fe8a6857e329b05b
[ "MIT" ]
null
null
null
Project/Zombienator/Layer.cpp
Jallah123/TheZombienator
efbcb93b0b2943cd9b38ac84fe8a6857e329b05b
[ "MIT" ]
null
null
null
Project/Zombienator/Layer.cpp
Jallah123/TheZombienator
efbcb93b0b2943cd9b38ac84fe8a6857e329b05b
[ "MIT" ]
null
null
null
#pragma once #include "Layer.h" #include "Map.h" #include "TileSet.h" Layer::Layer() { } Layer::Layer(Map * map) : map(map) { } Layer::~Layer() { } void Layer::DrawRect(SDL_Rect* srcRect, SDL_Texture* texture, SDL_Rect* destRect, SDL_Renderer& ren) { SDL_RenderCopy(&ren, texture, srcRect, destRect); } void Layer::DrawRect(SDL_Rect* rect, SDL_Renderer& ren) { SDL_SetRenderDrawColor(&ren, 255, 0, 0, 255); SDL_RenderDrawRect(&ren, rect); }
15.517241
100
0.695556
Jallah123
95f3259db3c8e78193d7b64e3381708b35a84a79
79,644
cpp
C++
src/model/UdmGridCoordinates.cpp
avr-aics-riken/UDMlib
1577b3caa74a7499037099dfbdd68d2f2c92fb43
[ "BSD-2-Clause" ]
3
2016-02-28T05:07:59.000Z
2019-01-31T15:15:31.000Z
src/model/UdmGridCoordinates.cpp
avr-aics-riken/UDMlib
1577b3caa74a7499037099dfbdd68d2f2c92fb43
[ "BSD-2-Clause" ]
4
2015-05-11T12:09:21.000Z
2015-11-24T06:23:38.000Z
src/model/UdmGridCoordinates.cpp
avr-aics-riken/UDMlib
1577b3caa74a7499037099dfbdd68d2f2c92fb43
[ "BSD-2-Clause" ]
5
2015-04-27T06:22:51.000Z
2021-05-10T07:36:57.000Z
// ################################################################################## // // UDMlib - Unstructured Data Management Library // // Copyright (C) 2012-2015 Institute of Industrial Science, The University of Tokyo. // All rights reserved. // // Copyright (c) 2015 Advanced Institute for Computational Science, RIKEN. // All rights reserved. // // ################################################################################### /** * @file UdmCoordinates.cpp * グリッド座標クラスのソースファイル */ #include "model/UdmGridCoordinates.h" #include "model/UdmModel.h" #include "model/UdmZone.h" #include "model/UdmFlowSolutions.h" #include "model/UdmNode.h" #include "model/UdmRankConnectivity.h" namespace udm { /** * コンストラクタ */ UdmGridCoordinates::UdmGridCoordinates() { this->initialize(); } /** * コンストラクタ * @param zone ゾーン */ UdmGridCoordinates::UdmGridCoordinates(UdmZone* zone) { this->initialize(); this->parent_zone = zone; } /** * デストラクタ */ UdmGridCoordinates::~UdmGridCoordinates() { this->finalize(); } /** * 初期化を行う. */ void UdmGridCoordinates::initialize() { this->setDataType(Udm_RealSingle); this->clearNodes(); this->parent_zone = NULL; this->max_nodeid = 0; } /** * 節点(ノード)の破棄処理を行う. */ void UdmGridCoordinates::finalize() { /********************************* std::vector<UdmNode*>::reverse_iterator ritr = this->node_list.rbegin(); while (ritr != this->node_list.rend()) { UdmNode* node = *(--(ritr.base())); if (node != NULL) { node->finalize(); delete node; } this->node_list.erase((++ritr).base()); ritr = this->node_list.rbegin(); } this->node_list.clear(); ritr = this->virtual_nodes.rbegin(); while (ritr != this->virtual_nodes.rend()) { UdmNode* node = *(--(ritr.base())); if (node != NULL) { node->finalize(); delete node; } this->virtual_nodes.erase((++ritr).base()); ritr = this->virtual_nodes.rbegin(); } this->virtual_nodes.clear(); ***************************/ std::vector<UdmNode*>::iterator itr = this->node_list.begin(); for (itr=this->node_list.begin(); itr!=this->node_list.end(); itr++) { UdmNode* node = (*itr); if (node != NULL) { node->finalize(); delete node; } } this->node_list.clear(); itr = this->virtual_nodes.begin(); for (itr=this->virtual_nodes.begin(); itr!=this->virtual_nodes.end(); itr++) { UdmNode* node = (*itr); if (node != NULL) { node->finalize(); delete node; } } this->virtual_nodes.clear(); return; } /** * グリッド構成ノード数を取得する. * @return グリッド構成ノード */ UdmSize_t UdmGridCoordinates::getNumNodes() const { return this->node_list.size(); } /** * ノードIDのグリッド構成ノードを取得する. * @param node_id ノードID(1~getNumNodes()) * @return グリッド構成ノード */ UdmNode* UdmGridCoordinates::getNodeById(UdmSize_t node_id) const { if (this->node_list.size() == 0) return NULL; if (node_id <= 0) return NULL; if (node_id > this->node_list.size()) return NULL; return (this->node_list[node_id - 1]); } /** * ローカルノードIDの節点(ノード)を取得する. * 構成節点(ノード)と仮想節点(ノード)から節点(ノード)を取得する. * @param node_id ノードID(1~getNumNodes()+getNumVirtualNodes()) * @return 節点(ノード) */ UdmNode* UdmGridCoordinates::getNodeByLocalId(UdmSize_t node_id) const { if (node_id <= 0) return NULL; if (node_id <= this->node_list.size()) { return this->getNodeById(node_id); } else if (node_id > this->node_list.size()) { return this->getVirtualNodeById(node_id - this->node_list.size()); } return NULL; } /** * グリッド構成ノードを追加する. * @param node グリッド構成ノード * @return ノードID(1~) : 0の場合は挿入エラー */ UdmSize_t UdmGridCoordinates::insertNode(UdmNode* node) { if (node == NULL) return 0; // グリッド構成ノードを追加する. this->node_list.push_back(node); /// NODE_ID = グリッド構成ノード(node_list)サイズ UdmSize_t node_id = 1; if (this->max_nodeid > 0) { node_id = this->max_nodeid + 1; } else if (this->node_list.size() > 0) { node_id = this->node_list[this->node_list.size()-1]->getId() + 1; } node->setId(node_id); this->max_nodeid = node_id; node->setParentGridcoordinates(this); // MPIランク番号 node->setMyRankno(this->getMpiRankno()); // 内部境界に追加する if (node->getNumMpiRankInfos() > 0) { if (this->getRankConnectivity() != NULL) { this->getRankConnectivity()->insertRankConnectivityNode(node); } } return node->getId(); } /** * グリッド構成ノードを追加する. * ID,ランク番号の設定は行わない. * @param node グリッド構成ノード */ void UdmGridCoordinates::pushbackNode(UdmNode* node) { if (node == NULL) return; // グリッド構成ノードを追加する. this->node_list.push_back(node); /// NODE_ID = グリッド構成ノード(node_list)サイズ UdmSize_t node_id = node->getId(); this->max_nodeid = node_id; node->setParentGridcoordinates(this); // ランク番号,IDを退避する. node->addPreviousRankInfo(node->getMyRankno(), node->getId()); // 内部境界に追加する if (node->getNumMpiRankInfos() > 0) { if (this->getRankConnectivity() != NULL) { this->getRankConnectivity()->insertRankConnectivityNode(node); } } return; } /** * 仮想ノードリスト数を取得する. * @return 仮想ノードリスト数 */ UdmSize_t UdmGridCoordinates::getNumVirtualNodes() const { return this->virtual_nodes.size(); } /** * 仮想ノードIDの仮想ノードリストを取得する. * @param node_id 仮想ノードID(1~getNumVirtualNodes()) * @return 仮想ノードリスト */ UdmNode* UdmGridCoordinates::getVirtualNodeById(UdmSize_t node_id) const { if (this->virtual_nodes.size() == 0) return NULL; if (node_id <= 0) return NULL; if (node_id > this->virtual_nodes.size()) return NULL; return (this->virtual_nodes[node_id - 1]); } /** * 仮想ノードを追加する. * 仮想節点(ノード)のID, 自ランク番号は、実体ランクのID,ランク番号とする. * 仮想節点(ノード)のID, 自ランク番号は上位で設定済みとする. * 仮想節点(ノード)の自ランク番号,IDで昇順に挿入する. * @param node 仮想ノード * @return 仮想ノード数 : 0の場合は挿入エラー */ UdmSize_t UdmGridCoordinates::insertVirtualNode(UdmNode* virtual_node) { if (virtual_node == NULL) return 0; std::vector<UdmNode*>::const_iterator itr; std::vector<UdmNode*>::iterator ins_itr; itr = this->searchUpperGlobalId(this->virtual_nodes, virtual_node); if (itr == this->virtual_nodes.end()) { this->virtual_nodes.push_back(virtual_node); } else { ins_itr = this->virtual_nodes.begin() + (itr - this->virtual_nodes.begin()); ins_itr = this->virtual_nodes.insert(ins_itr, virtual_node); } virtual_node->setParentGridcoordinates(this); virtual_node->setRealityType(Udm_Virtual); return this->virtual_nodes.size(); } /** * ノードをすべて削除する. * @return エラー番号 : UDM_OK | UDM_ERROR */ UdmError_t UdmGridCoordinates::clearNodes() { /************************ std::vector<UdmNode*>::reverse_iterator ritr = this->node_list.rbegin(); while (ritr != this->node_list.rend()) { UdmNode* node = *(--(ritr.base())); if (node != NULL) { delete node; } this->node_list.erase((++ritr).base()); ritr = this->node_list.rbegin(); } this->node_list.clear(); ritr = this->virtual_nodes.rbegin(); while (ritr != this->virtual_nodes.rend()) { UdmNode* node = *(--(ritr.base())); if (node != NULL) { delete node; } this->virtual_nodes.erase((++ritr).base()); ritr = this->virtual_nodes.rbegin(); } this->virtual_nodes.clear(); ******************/ std::vector<UdmNode*>::iterator itr = this->node_list.begin(); for (itr=this->node_list.begin(); itr!=this->node_list.end(); itr++) { UdmNode* node = (*itr); if (node != NULL) { node->finalize(); delete node; } } this->node_list.clear(); itr = this->virtual_nodes.begin(); for (itr=this->virtual_nodes.begin(); itr!=this->virtual_nodes.end(); itr++) { UdmNode* node = (*itr); if (node != NULL) { node->finalize(); delete node; } } this->virtual_nodes.clear(); return UDM_OK; } /** * 仮想節点(ノード)をすべて削除する. * @return エラー番号 : UDM_OK | UDM_ERROR */ UdmError_t UdmGridCoordinates::clearVirtualNodes() { /******************** std::vector<UdmNode*>::reverse_iterator ritr = this->node_list.rbegin(); ritr = this->virtual_nodes.rbegin(); while (ritr != this->virtual_nodes.rend()) { UdmNode* node = *(--(ritr.base())); if (node != NULL) { delete node; } this->virtual_nodes.erase((++ritr).base()); ritr = this->virtual_nodes.rbegin(); } this->virtual_nodes.clear(); *************/ std::vector<UdmNode*>::iterator itr = this->virtual_nodes.begin(); for (itr=this->virtual_nodes.begin(); itr!=this->virtual_nodes.end(); itr++) { UdmNode* node = (*itr); if (node != NULL) { delete node; } } this->virtual_nodes.clear(); return UDM_OK; } /** * 削除節点(ノード)を削除する. * @param node 削除節点(ノード) * @return エラー番号 : UDM_OK | UDM_ERROR */ UdmError_t UdmGridCoordinates::removeNode(const UdmEntity* node) { if (node == NULL) return UDM_ERROR; // 内部境界リストから削除する this->removeRankConnectivity(node); bool found_node = false; UdmSize_t node_id = node->getId(); std::vector<UdmNode*>::const_iterator itr; std::vector<UdmNode*>::iterator rm_itr; // 構成ノードから検索 itr = this->searchGlobalId(this->node_list, node); if (itr != this->node_list.end()) { if ((*itr) == node) { delete (*itr); rm_itr = this->node_list.begin() + (itr - this->node_list.begin()); this->node_list.erase(rm_itr); found_node = true;; } } // 仮想ノードから検索 if (found_node == false) { itr = this->searchGlobalId(this->virtual_nodes, node); if (itr != this->virtual_nodes.end()) { if ((*itr) == node) { delete (*itr); rm_itr = this->virtual_nodes.begin() + (itr - this->virtual_nodes.begin()); this->virtual_nodes.erase(rm_itr); found_node = true;; } } } if (found_node == false) { // node_idが存在しない UDM_WARNING_HANDLER(UDM_WARNING_INVALID_NODE, "not found node[node_id=%ld]", node_id); return UDM_ERROR; } return UDM_OK; } /** * 削除節点(ノード)を削除する. * ゾーン内の一意節点(ノード)IDにてグリッド構成ノード、仮想ノードから節点(ノード)を削除する. * @param node_id ゾーン内節点(ノード)ID(1~) * @return エラー番号 : UDM_OK | UDM_ERROR */ UdmError_t UdmGridCoordinates::removeNode(UdmSize_t node_id) { if (node_id <= 0) return UDM_ERROR; std::vector<UdmNode*>::const_iterator itr; std::vector<UdmNode*>::iterator rm_itr; // 構成ノードから検索 itr = this->searchEntityId(this->node_list, node_id); if (itr != this->node_list.end()) { // 内部境界リストから削除する this->removeRankConnectivity(*itr); delete (*itr); rm_itr = this->node_list.begin() + (itr - this->node_list.begin()); this->node_list.erase(rm_itr); return UDM_OK; } // 仮想ノードから検索 itr = this->searchEntityId(this->virtual_nodes, node_id); if (itr != this->virtual_nodes.end()) { delete (*itr); rm_itr = this->virtual_nodes.begin() + (itr - this->virtual_nodes.begin()); this->virtual_nodes.erase(rm_itr); return UDM_OK; } // node_idが存在しない UDM_WARNING_HANDLER(UDM_WARNING_INVALID_NODE, "not found node_id=%ld", node_id); return UDM_ERROR; } /** * 親ゾーンを取得する. * @return 親ゾーン */ UdmZone* UdmGridCoordinates::getParentZone() const { return this->parent_zone; } /** * 親ゾーンを設定する. * @param zone 親ゾーン * @return エラー番号 : UDM_OK | UDM_ERROR */ UdmError_t UdmGridCoordinates::setParentZone(UdmZone* zone) { this->parent_zone = zone; return UDM_OK; } /** * CGNSファイルからGridCoordinates(ノード座標データ)の読込みを行う. * @param index_file CGNSファイルインデックス * @param index_base CGNSベースインデックス * @param index_zone CGNSゾーンインデックス * @param timeslice_step CGNS読込ステップ回数 (default=-1) * @return エラー番号 : UDM_OK | UDM_ERROR */ UdmError_t UdmGridCoordinates::readCgns(int index_file, int index_base, int index_zone, int timeslice_step) { char zonename[33] = {0x00}, gridname[33] = {0x00}, arrayname[33] = {0x00}; cgsize_t sizes[9] = {0x00}; int num_coords = 0; DataType_t cgns_datatype; UdmDataType_t datatype = Udm_RealSingle; void *x_coords = NULL, *y_coords = NULL, *z_coords = NULL; int datasize; int dimension; cgsize_t vectors[3]; UdmError_t error = UDM_OK; int n; // ゾーンからノードサイズの取得 if (cg_zone_read(index_file, index_base, index_zone, zonename, sizes) != CG_OK) { return UDM_ERROR_HANDLER(UDM_ERROR_CGNS_INVALID_ZONE, "failure:cg_zone_read"); } // GridCoordinates名称の取得 error = this->getCgnsIterativeGridCoordinatesName(gridname, index_file, index_base, index_zone, timeslice_step); if (error != UDM_OK) { if (error == UDM_WARNING_CGNS_NOTEXISTS_ITERATIVEDATA) { // 警告メッセージ:CGNS:BaseIterativeData, ZoneIterativeDataが存在しない。 UDM_WARNINGNO_HANDLER(UDM_WARNING_CGNS_NOTEXISTS_ITERATIVEDATA); } int num_grids = 0; cg_ngrids(index_file, index_base, index_zone, &num_grids); if (num_grids > 1 && timeslice_step > 0) { // 複数のGridCoordinatesが存在し、ステップ番号が1以上であるので、GridCoordinates_%010dとする sprintf(gridname, UDM_CGNS_FORMAT_GRIDCOORDINATES, timeslice_step); } else { // timeslice_step=0の場合は必ずGridCoordinates strcpy(gridname, UDM_CGNS_NAME_GRIDCOORDINATES); } } if (cg_goto(index_file, index_base, zonename, 0, gridname, 0, "end") != CG_OK) { return UDM_ERROR_HANDLER(UDM_ERROR_CGNS_INVALID_GOTO, "zonename=%s,gridname=%s", zonename, gridname); } error = UDM_OK; // GridCoordinatesデータ数 cg_narrays(&num_coords); if (num_coords <= 0) { return UDM_ERROR_HANDLER(UDM_ERROR_CGNS_INVALID_GRIDCOORDINATES, "num_coords=%d", num_coords); } for (n=1; n<=num_coords; n++) { // CGNS:CoordinateX,CoordinateY,CoordinateZの読込 dimension = 0; vectors[0] = 0; cg_array_info(n, arrayname, &cgns_datatype,&dimension, vectors); if (dimension != 1 && vectors[0] <= 0) { return UDM_ERROR_HANDLER(UDM_ERROR_CGNS_INVALID_GRIDCOORDINATES, "coords[%d]:dimension=%d,vectors[0]=%d", n, dimension, vectors[0]); } if (vectors[0] != sizes[0]) { return UDM_ERROR_HANDLER(UDM_ERROR_CGNS_INVALID_GRIDCOORDINATES, "invalid coordinates size:vectors[0]=%d, sizes[0]=%d", vectors[0], sizes[0]); } if (n==1) { datatype = this->setCoordsDatatype(cgns_datatype); if (datatype == Udm_RealSingle) { x_coords = new float[sizes[0]]; y_coords = new float[sizes[0]]; z_coords = new float[sizes[0]]; datasize = sizeof(float); } else if (datatype == Udm_RealDouble) { x_coords = new double[sizes[0]]; y_coords = new double[sizes[0]]; z_coords = new double[sizes[0]]; datasize = sizeof(double); } else { return UDM_ERROR_HANDLER(UDM_ERROR_CGNS_INVALID_GRIDCOORDINATES, "invalid coordinates datatype"); } memset(x_coords, 0x00, datasize*sizes[0]); memset(y_coords, 0x00, datasize*sizes[0]); memset(z_coords, 0x00, datasize*sizes[0]); } datatype = this->getDataType(); cgns_datatype = this->toCgnsDataType(datatype); // 座標データの読込 if (strcmp(arrayname, "CoordinateX") == 0) { if (cg_array_read_as(n,cgns_datatype,x_coords) != CG_OK) { error = UDM_ERROR_HANDLER(UDM_ERROR_CGNS_INVALID_GRIDCOORDINATES, "failure : CoordinateX"); } } else if (strcmp(arrayname, "CoordinateY") == 0) { if (cg_array_read_as(n,cgns_datatype,y_coords) != CG_OK) { error = UDM_ERROR_HANDLER(UDM_ERROR_CGNS_INVALID_GRIDCOORDINATES, "failure : CoordinateY"); } } else if (strcmp(arrayname, "CoordinateZ") == 0) { if (cg_array_read_as(n,cgns_datatype,z_coords) != CG_OK) { error = UDM_ERROR_HANDLER(UDM_ERROR_CGNS_INVALID_GRIDCOORDINATES, "failure : CoordinateZ"); } } } if (error != UDM_OK) { this->deleteDataArray(x_coords, datatype); this->deleteDataArray(y_coords, datatype); this->deleteDataArray(z_coords, datatype); return UDM_ERRORNO_HANDLER(error); } // ノードデータの作成 UdmSize_t insert_size = 0; if (datatype == Udm_RealSingle) { insert_size = this->setGridCoordinatesArray(sizes[0], (float*)x_coords, (float*)y_coords, (float*)z_coords); } else if (datatype == Udm_RealDouble) { insert_size = this->setGridCoordinatesArray(sizes[0], (double*)x_coords, (double*)y_coords, (double*)z_coords); } this->deleteDataArray(x_coords, datatype); this->deleteDataArray(y_coords, datatype); this->deleteDataArray(z_coords, datatype); if (insert_size <= 0) { return UDM_ERROR_HANDLER(UDM_ERROR_CGNS_INVALID_GRIDCOORDINATES, "invalid coordinates datatype"); } // CGNS:UdmRankConnectivityを読み込む if (this->getRankConnectivity() != NULL) { if (this->getRankConnectivity()->readCgns(index_file, index_base, index_zone) != UDM_OK) { return UDM_ERROR_HANDLER(UDM_ERROR_CGNS_INVALID_USERDEFINEDDATA, "failure : UdmRankConnectivity::readCgns(index_file=%d, index_base=%d, index_zone=%d)", index_file, index_base, index_zone); } } return error; } /** * CGNSデータ型から座標値のデータ型を設定する. * @param cgns_datatype CGNSデータ型 * @return UDMlib:座標値データ型 */ UdmDataType_t UdmGridCoordinates::setCoordsDatatype(DataType_t cgns_datatype) { UdmDataType_t datatype = this->toUdmDataType(cgns_datatype); this->setDataType(datatype); return datatype; } /** * FlowSolutionクラスを取得する. * @return FlowSolutionクラス */ UdmFlowSolutions* UdmGridCoordinates::getFlowSolutions() const { if (this->parent_zone == NULL) return NULL; return this->parent_zone->getFlowSolutions(); } /** * ステップ数に設定されている時系列CGNS:GridCoordinates名を取得する * @param grid_name ゾーン名 * @param index_file CGNSファイルインデックス * @param index_base CGNSベースインデックス * @param index_zone CGNSゾーンインデックス * @param timeslice_step ステップ数 (default = -1) * @return エラー番号 : UDM_OK | UDM_ERROR */ UdmError_t UdmGridCoordinates::getCgnsIterativeGridCoordinatesName(char *grid_name, int index_file, int index_base, int index_zone, int timeslice_step) { char arrayname[33], zitername[33]; int narrays; int dimension, num_iterative; cgsize_t n, vectors[3], iterative_index; DataType_t idatatype; if (timeslice_step < 0) { strcpy(grid_name, UDM_CGNS_NAME_GRIDCOORDINATES); return UDM_OK; } // CGNS:BaseIterativeData,ZoneIterativeDataが存在するかチェックする. if (!this->existsCgnsIterativeData(index_file, index_base, index_zone)) { return UDM_WARNING_CGNS_NOTEXISTS_ITERATIVEDATA; } // CGNS:BaseIterativeDataからステップ数と一致するIterativeIDを取得する. std::vector<UdmSize_t> iterative_ids; num_iterative = this->getCgnsBaseIterativeDataIds(iterative_ids, index_file, index_base, timeslice_step); if (num_iterative <= 0) { // GridCoordinatesPointersが存在しない。グリッド座標の時系列座標はない。 return UDM_ERROR; } // 時系列CGNS:GridCoordinatesは1つのみ iterative_index = iterative_ids[0]; // CGNS:ZoneIterativeDataの読込 cg_ziter_read(index_file,index_base,index_zone,zitername); cg_goto(index_file,index_base,"Zone_t",index_zone,"ZoneIterativeData_t",1,"end"); // CGNS:ZoneIterativeData/DataArray_tの数の取得 : cg_narrays narrays = 0; cg_narrays(&narrays); for (n=1; n<=narrays; n++) { // CGNS:ZoneIterativeData/DataArray_tの名前,データ数の取得 : cg_array_info cg_array_info(n, arrayname, &idatatype,&dimension,vectors); if (dimension != 2) { return UDM_ERROR_HANDLER(UDM_ERROR_CGNS_INVALID_ITERATIVEDATA, "invalid ZoneIterativeData[dataDimension=%d].", dimension); } if (vectors[1] < iterative_index) { return UDM_ERROR_HANDLER(UDM_ERROR_CGNS_INVALID_ITERATIVEDATA, "invalid ZoneIterativeData[dimensionVector[1]=%d,iterative_index=%d].", vectors[1], iterative_index); } if (strcmp(arrayname, "GridCoordinatesPointers")==0) { // char grid_names[vectors[1]][vectors[0]]; char *grid_names = new char[vectors[1]*vectors[0]]; // (時系列GridCoordinates名リストの取得 : GridCoordinatesPointers cg_array_read_as(n,Character,grid_names); // 時系列インデックスの名前の取得(1つのみ) strncpy(grid_name, grid_names+(iterative_index-1)*vectors[0], vectors[0]); this->trim(grid_name); delete []grid_names; return UDM_OK; } } // GridCoordinatesPointersが存在しない。グリッド座標の時系列座標はない。 return UDM_ERROR; } /** * クラス情報を文字列出力する:デバッグ用. * @param buf 出力文字列 */ void UdmGridCoordinates::toString(std::string& buf) const { #ifdef _DEBUG_TRACE std::stringstream stream; UdmSize_t count = 0; // XYZ座標 std::vector<UdmNode*>::const_iterator itr; for (itr=this->node_list.begin(); itr!= this->node_list.end(); itr++) { std::string node_buf; (*itr)->toString(node_buf); stream << "GridCoordinates[" << (*itr)->getId() << "] : " << node_buf; stream << std::endl; } buf += stream.str(); #endif return; } /** * グリッド構成ノード数を取得する. * @return グリッド構成ノード */ UdmSize_t UdmGridCoordinates::getNumEntities() const { return this->getNumNodes(); } /** * ノードIDのグリッド構成ノードを取得する. * @param node_id ノードID(1~) * @return グリッド構成ノード */ UdmEntity* UdmGridCoordinates::getEntityById(UdmSize_t entity_id) { return this->getNodeById(entity_id); } /** * ノードIDのグリッド構成ノードを取得する:const. * @param node_id ノードID(1~) * @return グリッド構成ノード */ const UdmEntity* UdmGridCoordinates::getEntityById(UdmSize_t entity_id) const { return this->getNodeById(entity_id); } /** * CGNS:GridCoordinatesを出力する. * @param index_file CGNSファイルインデックス * @param index_base CGNSベースインデックス * @param index_zone CGNSゾーンインデックス * @param timeslice_step CGNS出力ステップ回数 * @param grid_timeslice CGNS:GridCoordinatesの時系列出力の有無:true=GridCoordinates時系列出力する * @return エラー番号 : UDM_OK | UDM_ERROR */ UdmError_t UdmGridCoordinates::writeCgns(int index_file, int index_base, int index_zone, int timeslice_step, bool grid_timeslice) { char gridname[33] = {0x00}; int index_grid, index_coord; UdmDataType_t datatype; DataType_t cgns_datatype; cgsize_t coords_size; int cg_error; UdmError_t udm_error = UDM_OK; // 出力CGNS:GridCoordinates名のクリア this->clearCgnsWriteGridCoordnates(); // GridCoordinatesが存在するか sprintf(gridname, "GridCoordinates"); if (cg_goto(index_file, index_base, "Zone_t", index_zone, gridname, 0, "end") == CG_OK) { if (!grid_timeslice) { // 時系列出力の無であるので、CGNS:GridCoordinatesの時系列出力しない。 // GridCoordinatesが存在するので、CGNS:GridCoordinatesは出力しない。 // 出力CGNS:GridCoordinates名を設定する. this->setCgnsWriteGridCoordnates(std::string(gridname)); return UDM_OK; } char itr_name[33] = {0x00}; if (this->getCgnsIterativeGridCoordinatesName(itr_name, index_file, index_base, index_zone, timeslice_step) == UDM_OK) { // 既存出力のGridCoordinates名を使用する. strcpy(gridname, itr_name); } else { // 時系列ステップ番号付きのGridCoordinates名を使用する. // GridCoordinates_%010d sprintf(gridname, UDM_CGNS_FORMAT_GRIDCOORDINATES, timeslice_step); } } // CGNS:GridCoordinatesの出力 index_grid = this->findCgnsGridCoordinates(index_file, index_base, index_zone, gridname); if (index_grid <= 0) { if (cg_grid_write(index_file,index_base,index_zone, gridname, &index_grid) != CG_OK) { return UDM_ERROR_HANDLER(UDM_ERROR_CGNS_INVALID_GRIDCOORDINATES, "failure : cg_grid_write(gridname=%s)", gridname); } } if (cg_goto(index_file,index_base, "Zone_t", index_zone, "GridCoordinates_t",index_grid, "end") != CG_OK) { return UDM_ERROR_HANDLER(UDM_ERROR_CGNS_INVALID_GRIDCOORDINATES, "failure : cg_goto(index_grid=%d)", index_grid); } udm_error = UDM_OK; cg_error = 0; datatype = this->getDataType(); cgns_datatype = this->toCgnsDataType(datatype); coords_size = this->getNumNodes(); if (datatype == Udm_RealSingle) { float *coords = new float[coords_size]; // CoordinateX出力 this->getGridCoordinatesX(1, coords_size, (float*)coords); if ((cg_error = cg_array_write("CoordinateX", cgns_datatype, 1, &coords_size, coords)) != CG_OK) { udm_error = UDM_ERROR_HANDLER(UDM_ERROR_CGNS_INVALID_GRIDCOORDINATES, "failure : cg_array_write(CoordinateX)"); } if (udm_error != UDM_OK) { delete []coords; return udm_error; } // CoordinateY出力 this->getGridCoordinatesY(1, coords_size, (float*)coords); if ((cg_error = cg_array_write("CoordinateY", cgns_datatype, 1, &coords_size, coords)) != CG_OK) { udm_error = UDM_ERROR_HANDLER(UDM_ERROR_CGNS_INVALID_GRIDCOORDINATES, "failure : cg_array_write(CoordinateY)"); } if (udm_error != UDM_OK) { delete []coords; return udm_error; } // CoordinateZ出力 this->getGridCoordinatesZ(1, coords_size, (float*)coords); if ((cg_error = cg_array_write("CoordinateZ", cgns_datatype, 1, &coords_size, coords)) != CG_OK) { udm_error = UDM_ERROR_HANDLER(UDM_ERROR_CGNS_INVALID_GRIDCOORDINATES, "failure : cg_array_write(CoordinateZ)"); } if (udm_error != UDM_OK) { delete []coords; return udm_error; } delete []coords; } else if (datatype == Udm_RealDouble) { double *coords = new double[coords_size]; // CoordinateX出力 this->getGridCoordinatesX(1, coords_size, (double*)coords); if ((cg_error = cg_array_write("CoordinateX", cgns_datatype, 1, &coords_size, coords)) != CG_OK) { udm_error = UDM_ERROR_HANDLER(UDM_ERROR_CGNS_INVALID_GRIDCOORDINATES, "failure : cg_array_write(CoordinateX)"); } if (udm_error != UDM_OK) { delete []coords; return udm_error; } // CoordinateY出力 this->getGridCoordinatesY(1, coords_size, (double*)coords); if ((cg_error = cg_array_write("CoordinateY", cgns_datatype, 1, &coords_size, coords)) != CG_OK) { udm_error = UDM_ERROR_HANDLER(UDM_ERROR_CGNS_INVALID_GRIDCOORDINATES, "failure : cg_array_write(CoordinateY)"); } if (udm_error != UDM_OK) { delete []coords; return udm_error; } // CoordinateZ出力 this->getGridCoordinatesZ(1, coords_size, (double*)coords); if ((cg_error = cg_array_write("CoordinateZ", cgns_datatype, 1, &coords_size, coords)) != CG_OK) { udm_error = UDM_ERROR_HANDLER(UDM_ERROR_CGNS_INVALID_GRIDCOORDINATES, "failure : cg_array_write(CoordinateZ)"); } if (udm_error != UDM_OK) { delete []coords; return udm_error; } delete []coords; } else { return UDM_ERROR_HANDLER(UDM_ERROR_CGNS_INVALID_GRIDCOORDINATES, "invalid coordinates datatype"); } // 出力CGNS:GridCoordinates名を設定する. this->setCgnsWriteGridCoordnates(std::string(gridname)); // CGNS:UdmRankConenctivityを書き込む. if (this->getRankConnectivity() != NULL) { if (this->getRankConnectivity()->writeCgns(index_file, index_base, index_zone) != UDM_OK) { return UDM_ERROR_HANDLER(UDM_ERROR_CGNS_INVALID_USERDEFINEDDATA, "failure : UdmRankConnectivity::writeCgns(index_file=%d, index_base=%d, index_zone=%d)", index_file, index_base, index_zone); } } return UDM_OK; } /** * CGNS:GridCoordinatesのリンクを出力する. * @param index_file CGNSファイルインデックス * @param index_base CGNSベースインデックス * @param index_zone CGNSゾーンインデックス * @param link_output_path リンク出力ファイル * @param linked_files リンクファイルリスト * @param timeslice_step CGNS出力ステップ回数 * @return エラー番号 : UDM_OK | UDM_ERROR */ UdmError_t UdmGridCoordinates::writeCgnsLinkFile( int index_file, int index_base, int index_zone, const std::string &link_output_path, const std::vector<std::string> &linked_files, int timeslice_step) { UdmError_t error = UDM_OK; char basename[33] = {0x00}; char zonename[33] = {0x00}; char gridname[33] = {0x00}; char linked_gridname[33] = {0x00}; int index_linkfile; std::vector<std::string>::const_iterator itr; char path[256] = {0x00}; std::string filename; int cell_dim, phys_dim; cgsize_t sizes[9] = {0x00}; int cg_ret = 0; // 出力CGNS:GridCoordinates名のクリア this->clearCgnsWriteGridCoordnates(); // リンクファイルにGridCoordinatesが存在するかチェックする. filename.clear(); for (itr=linked_files.begin(); itr!= linked_files.end(); itr++) { filename = (*itr); // リンクファイルオープン if (cg_open(filename.c_str(), CG_MODE_READ, &index_linkfile) != CG_OK) { return UDM_ERROR_HANDLER(UDM_ERROR_CGNS_OPENERROR, "filename=%s, cgns_error=%s", filename.c_str(), cg_get_error()); } // 出力リンクファイルと同じCGNSベースインデックス, CGNSゾーンインデックスとする. cg_ret = cg_base_read(index_linkfile, index_base, basename, &cell_dim, &phys_dim); cg_ret = cg_zone_read(index_linkfile, index_base, index_zone, zonename, sizes); // GridCoordinates名称の取得 if ((error = this->getCgnsIterativeGridCoordinatesName(gridname, index_linkfile, index_base, index_zone, timeslice_step)) != UDM_OK) { strcpy(gridname, UDM_CGNS_NAME_GRIDCOORDINATES); } if (cg_goto(index_linkfile, index_base, "Zone_t", index_zone, gridname, 0, "end") != CG_OK) { continue; // CGNS:GridCoordinatesが存在しない. } // リンク元GridCoordinates名 strcpy(linked_gridname, gridname); cg_close(index_linkfile); break; } // linked_gridname:リンク元名, gridname:リンク先名 if (strlen(linked_gridname) <= 0) { // GridCoordinatesはリンクしない。 return UDM_OK; } if (filename.empty()) { return UDM_OK; } // リンク元GridCoordinates名が"GridCoordinates"であるので別名とする。 if (strcmp(linked_gridname, UDM_CGNS_NAME_GRIDCOORDINATES) == 0) { // 出力リンクファイルにGridCoordinatesが存在するか if (cg_goto(index_file, index_base, "Zone_t", index_zone, UDM_CGNS_NAME_GRIDCOORDINATES, 0, "end") == CG_OK) { // 出力リンクファイルにGridCoordinatesが存在し、リンク元GridCoordinatesと同名であるので、別名とする. // GridCoordinates_%010d sprintf(gridname, UDM_CGNS_FORMAT_GRIDCOORDINATES, timeslice_step); } } // 出力リンクファイルにリンク別名と同じGridCoordinatesが存在することはない。 if (cg_goto(index_file, index_base, "Zone_t", index_zone, gridname, 0, "end") == CG_OK) { return UDM_ERROR_HANDLER(UDM_ERROR_CGNS_INVALID_GRIDCOORDINATES, "exists linked GridCoordinates name[gridname=%s].", gridname); } // GridCoordinatesリンクの作成 if (cg_goto(index_file, index_base, "Zone_t", index_zone, "end") != CG_OK) { return UDM_ERROR_HANDLER(UDM_ERROR_CGNS_INVALID_GOTO, "index_file=%d,index_base=%d,index_zone=%d", index_file, index_base, index_zone); } sprintf(path, "/%s/%s/%s", basename, zonename, linked_gridname); // リンクファイルをリンク出力ファイルからの相対パスに変換する. std::string linked_relativepath; this->getLinkedRelativePath(link_output_path, filename, linked_relativepath); // CGNSリンク出力 if (cg_link_write(gridname, linked_relativepath.c_str(), path) != CG_OK) { return UDM_ERROR_HANDLER(UDM_ERROR_CGNS_INVALID_ELEMENTS, "failure:cg_link_write(%s,%s,%s)",gridname, filename.c_str(), path); } // 出力CGNS:GridCoordinates名を設定する. this->setCgnsWriteGridCoordnates(std::string(gridname)); // CGNS:UdmRankConenctivityを書き込む.:実際に書き込む(リンク先が削除されることを考慮して、リンクとしない) if (this->getRankConnectivity() != NULL) { if (this->getRankConnectivity()->writeCgns(index_file, index_base, index_zone) != UDM_OK) { return UDM_ERROR_HANDLER(UDM_ERROR_CGNS_INVALID_USERDEFINEDDATA, "failure : UdmRankConnectivity::writeCgns(index_file=%d, index_base=%d, index_zone=%d)", index_file, index_base, index_zone); } } return UDM_OK; } /** * 節点(ノード)グリッド座標を設定する. * 構成節点(ノード)はクリアして設定節点(ノード)数,グリッド座標に置き換える. * グリッド座標から節点(ノード)クラスを生成する. * @param num_nodes 節点(ノード)数 * @param coords_x グリッド座標X * @param coords_y グリッド座標Y * @param coords_z グリッド座標Z * @return 生成節点(ノード)数 */ template<class DATA_TYPE> UdmSize_t UdmGridCoordinates::setGridCoordinatesArray( UdmSize_t num_nodes, DATA_TYPE* coords_x, DATA_TYPE* coords_y, DATA_TYPE* coords_z) { UdmSize_t n; // 節点(ノード)をクリアする. this->clearNodes(); // ノードデータの作成 for (n=0; n<num_nodes; n++) { UdmNode *node = NULL; node = new UdmNode(coords_x[n], coords_y[n], coords_z[n]); // ノードID、ランク番号を設定する node->addPreviousRankInfo(this->getCgnsRankno(), n+1); node->setId(n+1); node->setMyRankno(this->getCgnsRankno()); // 節点(ノード)の挿入 this->pushbackNode(node); } return num_nodes; } template UdmSize_t UdmGridCoordinates::setGridCoordinatesArray(UdmSize_t num_nodes, float* coords_x, float* coords_y, float* coords_z); template UdmSize_t UdmGridCoordinates::setGridCoordinatesArray(UdmSize_t num_nodes, double* coords_x, double* coords_y, double* coords_z); /** * 節点(ノード)グリッド座標を取得する. * @param [in] node_id 節点(ノード)ID:1~ * @param [out] x X座標 * @param [out] y Y座標 * @param [out] z Z座標 * @return エラー番号 : UDM_OK | UDM_ERROR */ template<class DATA_TYPE> UdmError_t UdmGridCoordinates::getGridCoordinates( UdmSize_t node_id, DATA_TYPE &x, DATA_TYPE &y, DATA_TYPE &z) const { const UdmNode *node = this->getNodeById(node_id); if (node == NULL) { return UDM_ERROR; } // グリッド座標を取得する. node->getCoords(x, y, z); return UDM_OK; } template UdmError_t UdmGridCoordinates::getGridCoordinates(UdmSize_t node_id, float &x, float &y, float &z) const; template UdmError_t UdmGridCoordinates::getGridCoordinates(UdmSize_t node_id, double &x, double &y, double &z) const; /** * 節点(ノード)グリッド座標を設定する. * @param node_id 節点(ノード)ID:1~ * @param x X座標 * @param y Y座標 * @param z Z座標 * @return エラー番号 : UDM_OK | UDM_ERROR */ template<class DATA_TYPE> UdmError_t UdmGridCoordinates::setGridCoordinates( UdmSize_t node_id, DATA_TYPE x, DATA_TYPE y, DATA_TYPE z) { UdmNode *node = this->getNodeById(node_id); if (node == NULL) { return UDM_ERROR; } // グリッド座標を設定する. node->setCoords(x, y, z); return UDM_OK; } template UdmError_t UdmGridCoordinates::setGridCoordinates(UdmSize_t node_id, float x, float y, float z); template UdmError_t UdmGridCoordinates::setGridCoordinates(UdmSize_t node_id, double x, double y, double z); /** * 節点(ノード)グリッド座標を追加する. * @param x グリッド座標X * @param y グリッド座標Y * @param z グリッド座標Z * @return 節点(ノード)ID */ template<class DATA_TYPE> UdmSize_t UdmGridCoordinates::insertGridCoordinates( DATA_TYPE x, DATA_TYPE y, DATA_TYPE z) { UdmSize_t n; // ノードデータの作成 UdmNode *node = new UdmNode(x, y, z); return this->insertNode(node);; } template UdmSize_t UdmGridCoordinates::insertGridCoordinates(float x, float y, float z); template UdmSize_t UdmGridCoordinates::insertGridCoordinates(double x, double y, double z); /** * 構成節点(ノード)のグリッド座標を取得する. * @param start_id 取得開始ID * @param end_id 取得終了ID * @param coords_x グリッド座標X * @param coords_y グリッド座標Y * @param coords_z グリッド座標Z * @return 取得節点(ノード)数 */ template<class DATA_TYPE> UdmSize_t UdmGridCoordinates::getGridCoordinatesArray( UdmSize_t start_id, UdmSize_t end_id, DATA_TYPE* coords_x, DATA_TYPE* coords_y, DATA_TYPE* coords_z) { if (start_id <= 0) return 0; if (start_id > end_id) return 0; if (this->node_list.size() <= 0) return 0; if (end_id > this->node_list.size()) return 0; UdmSize_t n; UdmSize_t id = 0; for (n=start_id-1; n<=end_id-1; n++) { this->node_list[n]->getCoords(coords_x[id], coords_y[id], coords_z[id]); ++id; } return id; } template UdmSize_t UdmGridCoordinates::getGridCoordinatesArray(UdmSize_t start_id, UdmSize_t end_id, float* coords_x, float* coords_y, float* coords_z); template UdmSize_t UdmGridCoordinates::getGridCoordinatesArray(UdmSize_t start_id, UdmSize_t end_id, double* coords_x, double* coords_y, double* coords_z); /** * 構成節点(ノード)のグリッド座標Xを取得する. * @param start_id 取得開始ID * @param end_id 取得終了ID * @param coords グリッド座標X * @return 取得節点(ノード)数 */ template<class DATA_TYPE> UdmSize_t UdmGridCoordinates::getGridCoordinatesX( UdmSize_t start_id, UdmSize_t end_id, DATA_TYPE* coords) { if (start_id <= 0) return 0; if (start_id > end_id) return 0; if (this->node_list.size() <= 0) return 0; if (end_id > this->node_list.size()) return 0; UdmSize_t n; UdmSize_t id = 0; DATA_TYPE coords_x, coords_y, coords_z; for (n=start_id-1; n<=end_id-1; n++) { this->node_list[n]->getCoords(coords_x, coords_y, coords_z); coords[id++] = coords_x; } return id; } template UdmSize_t UdmGridCoordinates::getGridCoordinatesX(UdmSize_t start_id, UdmSize_t end_id, float* coords); template UdmSize_t UdmGridCoordinates::getGridCoordinatesX(UdmSize_t start_id, UdmSize_t end_id, double* coords); /** * 構成節点(ノード)のグリッド座標Yを取得する. * @param start_id 取得開始ID * @param end_id 取得終了ID * @param coords グリッド座標Y * @return 取得節点(ノード)数 */ template<class DATA_TYPE> UdmSize_t UdmGridCoordinates::getGridCoordinatesY( UdmSize_t start_id, UdmSize_t end_id, DATA_TYPE* coords) { if (start_id <= 0) return 0; if (start_id > end_id) return 0; if (this->node_list.size() <= 0) return 0; if (end_id > this->node_list.size()) return 0; UdmSize_t n; UdmSize_t id = 0; DATA_TYPE coords_x, coords_y, coords_z; for (n=start_id-1; n<=end_id-1; n++) { this->node_list[n]->getCoords(coords_x, coords_y, coords_z); coords[id++] = coords_y; } return id; } template UdmSize_t UdmGridCoordinates::getGridCoordinatesY(UdmSize_t start_id, UdmSize_t end_id, float* coords); template UdmSize_t UdmGridCoordinates::getGridCoordinatesY(UdmSize_t start_id, UdmSize_t end_id, double* coords); /** * 構成節点(ノード)のグリッド座標Zを取得する. * @param start_id 取得開始ID * @param end_id 取得終了ID * @param coords グリッド座標Z * @return 取得節点(ノード)数 */ template<class DATA_TYPE> UdmSize_t UdmGridCoordinates::getGridCoordinatesZ( UdmSize_t start_id, UdmSize_t end_id, DATA_TYPE* coords) { if (start_id <= 0) return 0; if (start_id > end_id) return 0; if (this->node_list.size() <= 0) return 0; if (end_id > this->node_list.size()) return 0; UdmSize_t n; UdmSize_t id = 0; DATA_TYPE coords_x, coords_y, coords_z; for (n=start_id-1; n<=end_id-1; n++) { this->node_list[n]->getCoords(coords_x, coords_y, coords_z); coords[id++] = coords_z; } return id; } template UdmSize_t UdmGridCoordinates::getGridCoordinatesZ(UdmSize_t start_id, UdmSize_t end_id, float* coords); template UdmSize_t UdmGridCoordinates::getGridCoordinatesZ(UdmSize_t start_id, UdmSize_t end_id, double* coords); /** * 仮想節点(ノード)のグリッド座標を取得する. * @param start_id 取得開始ID * @param end_id 取得終了ID * @param coords_x グリッド座標X * @param coords_y グリッド座標Y * @param coords_z グリッド座標Z * @return 取得節点(ノード)数 */ template<class DATA_TYPE> UdmSize_t UdmGridCoordinates::getGridCoordinatesArrayOfVirtual( UdmSize_t start_id, UdmSize_t end_id, DATA_TYPE* coords_x, DATA_TYPE* coords_y, DATA_TYPE* coords_z) { if (start_id <= 0) return 0; if (start_id > end_id) return 0; if (this->virtual_nodes.size() <= 0) return 0; if (end_id > this->virtual_nodes.size()) return 0; UdmSize_t n; UdmSize_t id = 0; for (n=start_id-1; n<=end_id-1; n++) { this->virtual_nodes[n]->getCoords(coords_x[id], coords_y[id], coords_z[id]); ++id; } return id; } template UdmSize_t UdmGridCoordinates::getGridCoordinatesArrayOfVirtual(UdmSize_t start_id, UdmSize_t end_id, float* coords_x, float* coords_y, float* coords_z); template UdmSize_t UdmGridCoordinates::getGridCoordinatesArrayOfVirtual(UdmSize_t start_id, UdmSize_t end_id, double* coords_x, double* coords_y, double* coords_z); /** * 仮想節点(ノード)のグリッド座標Xを取得する. * @param start_id 取得開始ID * @param end_id 取得終了ID * @param coords グリッド座標X * @return 取得節点(ノード)数 */ template<class DATA_TYPE> UdmSize_t UdmGridCoordinates::getGridCoordinatesXOfVirtual( UdmSize_t start_id, UdmSize_t end_id, DATA_TYPE* coords) { if (start_id <= 0) return 0; if (start_id > end_id) return 0; if (this->virtual_nodes.size() <= 0) return 0; if (end_id > this->virtual_nodes.size()) return 0; UdmSize_t n; UdmSize_t id = 0; DATA_TYPE coords_x, coords_y, coords_z; for (n=start_id-1; n<=end_id-1; n++) { this->virtual_nodes[n]->getCoords(coords_x, coords_y, coords_z); coords[id++] = coords_x; } return id; } template UdmSize_t UdmGridCoordinates::getGridCoordinatesXOfVirtual(UdmSize_t start_id, UdmSize_t end_id, float* coords); template UdmSize_t UdmGridCoordinates::getGridCoordinatesXOfVirtual(UdmSize_t start_id, UdmSize_t end_id, double* coords); /** * 仮想節点(ノード)のグリッド座標Yを取得する. * @param start_id 取得開始ID * @param end_id 取得終了ID * @param coords グリッド座標Y * @return 取得節点(ノード)数 */ template<class DATA_TYPE> UdmSize_t UdmGridCoordinates::getGridCoordinatesYOfVirtual( UdmSize_t start_id, UdmSize_t end_id, DATA_TYPE* coords) { if (start_id <= 0) return 0; if (start_id > end_id) return 0; if (this->virtual_nodes.size() <= 0) return 0; if (end_id > this->virtual_nodes.size()) return 0; UdmSize_t n; UdmSize_t id = 0; DATA_TYPE coords_x, coords_y, coords_z; for (n=start_id-1; n<=end_id-1; n++) { this->virtual_nodes[n]->getCoords(coords_x, coords_y, coords_z); coords[id++] = coords_y; } return id; } template UdmSize_t UdmGridCoordinates::getGridCoordinatesYOfVirtual(UdmSize_t start_id, UdmSize_t end_id, float* coords); template UdmSize_t UdmGridCoordinates::getGridCoordinatesYOfVirtual(UdmSize_t start_id, UdmSize_t end_id, double* coords); /** * 仮想節点(ノード)のグリッド座標Zを取得する. * @param start_id 取得開始ID * @param end_id 取得終了ID * @param coords グリッド座標Z * @return 取得節点(ノード)数 */ template<class DATA_TYPE> UdmSize_t UdmGridCoordinates::getGridCoordinatesZOfVirtual( UdmSize_t start_id, UdmSize_t end_id, DATA_TYPE* coords) { if (start_id <= 0) return 0; if (start_id > end_id) return 0; if (this->virtual_nodes.size() <= 0) return 0; if (end_id > this->virtual_nodes.size()) return 0; UdmSize_t n; UdmSize_t id = 0; DATA_TYPE coords_x, coords_y, coords_z; for (n=start_id-1; n<=end_id-1; n++) { this->virtual_nodes[n]->getCoords(coords_x, coords_y, coords_z); coords[id++] = coords_z; } return id; } template UdmSize_t UdmGridCoordinates::getGridCoordinatesZOfVirtual(UdmSize_t start_id, UdmSize_t end_id, float* coords); template UdmSize_t UdmGridCoordinates::getGridCoordinatesZOfVirtual(UdmSize_t start_id, UdmSize_t end_id, double* coords); /** * 物理量フィールド情報を取得する. * @param solution_name 物理量データ名称 * @return 物理量フィールド情報 */ const UdmSolutionFieldConfig* UdmGridCoordinates::getSolutionFieldConfig(const std::string& solution_name) const { const UdmZone* zone = this->getParentZone(); if (zone == NULL) return NULL; const UdmFlowSolutions* solutions = zone->getFlowSolutions(); if (solutions == NULL) return NULL; return solutions->getSolutionField(solution_name); } /** * 出力CGNS:GrdiCoordinates名を取得する. * @return 出力CGNS:GrdiCoordinates名 */ const std::string& UdmGridCoordinates::getCgnsWriteGridCoordnates() const { return this->cgns_writegridcoordnates; } /** * 出力CGNS:GrdiCoordinates名を設定する. * @param gridcoordnates_name 出力CGNS:GrdiCoordinates名 */ void UdmGridCoordinates::setCgnsWriteGridCoordnates(const std::string& gridcoordnates_name) { this->cgns_writegridcoordnates = gridcoordnates_name; } /** * 出力CGNS:GrdiCoordinates名をクリアする. */ void UdmGridCoordinates::clearCgnsWriteGridCoordnates() { this->cgns_writegridcoordnates.clear(); } /** * 出力結果CGNS:GridCoordnates名があるかチェックする. * 出力結果CGNS:GridCoordnates名がある場合は1と返す。 * @return 1=出力結果CGNS:GridCoordnates名がある, 0=出力結果CGNS:GridCoordnates名がない。 */ int UdmGridCoordinates::getNumCgnsWriteGridCoordnates() const { return (this->cgns_writegridcoordnates.empty()?0:1); } /** * CGNS出力前の初期化を行う. * @return エラー番号 : UDM_OK | UDM_ERROR */ UdmError_t UdmGridCoordinates::initializeWriteCgns() { this->clearCgnsWriteGridCoordnates(); return UDM_OK; } /** * 物理量データの初期化を行う. * @param solution_name 物理量名称 * @param value 初期設定値 * @return エラー番号 : UDM_OK | UDM_ERROR */ template<class VALUE_TYPE> UdmError_t UdmGridCoordinates::initializeValueEntities(const std::string& solution_name, VALUE_TYPE value) { // 物理量名称が存在するか?ノード(頂点)定義物理量であるかチェックする. const UdmZone* zone = this->getParentZone(); if (zone == NULL) return UDM_ERROR; const UdmFlowSolutions* solutions = zone->getFlowSolutions(); if (solutions == NULL) return UDM_ERROR; const UdmSolutionFieldConfig* config = solutions->getSolutionField(solution_name); if (config == NULL) { return UDM_ERROR_HANDLER(UDM_ERROR_INVALID_PARAMETERS, "not found solution_name=%s", solution_name.c_str()); } if (config->getGridLocation() != Udm_Vertex) { return UDM_ERROR_HANDLER(UDM_ERROR_INVALID_PARAMETERS, "solution_name[%s] is not Vertex.", solution_name.c_str()); } std::vector<UdmNode*>::iterator itr; for (itr=this->node_list.begin(); itr!=this->node_list.end(); itr++) { UdmNode* node = (*itr); node->initializeValue(solution_name, value); } return UDM_OK; } template UdmError_t UdmGridCoordinates::initializeValueEntities<int>(const std::string& solution_name, int value); template UdmError_t UdmGridCoordinates::initializeValueEntities<long long>(const std::string& solution_name, long long value); template UdmError_t UdmGridCoordinates::initializeValueEntities<float>(const std::string& solution_name, float value); template UdmError_t UdmGridCoordinates::initializeValueEntities<double>(const std::string& solution_name, double value); /** * MPIランク番号を取得する. * @return MPIランク番号 */ int UdmGridCoordinates::getMpiRankno() const { if (this->getParentZone() == NULL) return -1; if (this->getParentZone()->getParentModel() == NULL) return -1; return this->getParentZone()->getParentModel()->getMpiRankno(); } /** * MPIプロセス数を取得する. * @return MPIプロセス数 */ int UdmGridCoordinates::getMpiProcessSize() const { if (this->getParentZone() == NULL) return -1; if (this->getParentZone()->getParentModel() == NULL) return -1; return this->getParentZone()->getParentModel()->getMpiProcessSize(); } /** * CGNS:UdmInfoのランク番号を取得する. * @return CGNS:UdmInfoランク番号 */ int UdmGridCoordinates::getCgnsRankno() const { if (this->getParentZone() == NULL) return -1; if (this->getParentZone()->getParentModel() == NULL) return -1; return this->getParentZone()->getParentModel()->getCgnsRankno(); } /** * ランク番号とIDが一致している節点(ノード)を検索する. * 節点(ノード)の現在のランク番号とIDから検索する. * 存在しなければ、以前のランク番号とIDから検索する. * @param src_rankno ランク番号 * @param src_nodeid 節点(ノード)ID * @return 節点(ノード) */ UdmNode* UdmGridCoordinates::findNodeByGlobalId(int src_rankno, UdmSize_t src_nodeid) const { if (src_rankno < 0) return NULL; if (src_nodeid <= 0) return NULL; UdmNode *find_node = NULL; // グリッド構成ノードリストの配列添字として検索 find_node = this->getNodeById(src_nodeid); if (find_node != NULL) { if (find_node->getMyRankno() == src_rankno) { return find_node; } find_node = NULL; } // 2分探索でグローバルIDを検索する std::vector<UdmNode*>::const_iterator find_itr; find_itr = this->searchCurrentGlobalId(this->node_list, src_rankno, src_nodeid); if (find_itr != this->node_list.end()) { find_node = (*find_itr); return find_node; } // 以前のグローバルIDを検索する find_itr = this->searchPreviousGlobalId(this->node_list, src_rankno, src_nodeid); if (find_itr != this->node_list.end()) { find_node = (*find_itr); return find_node; } return NULL; } /** * Zoltan分割によるインポート節点(ノード)を追加する. * @param import_nodes インポート節点(ノード)リスト * @return エラー番号 : UDM_OK | UDM_ERROR */ UdmError_t UdmGridCoordinates::importNodes(const std::vector<UdmNode*>& import_nodes) { UdmRankConnectivity* inner = this->getRankConnectivity(); if (inner == NULL) { return UDM_ERROR_HANDLER(UDM_ERROR_NULL_VARIABLE, "UdmRankConnectivity is null"); } std::vector<UdmNode*>::const_iterator itr; std::vector<UdmNode*>::const_iterator find_itr; std::vector<UdmNode*> insert_nodes; // 内部境界節点(ノード)のランク番号、ID検索テーブルを作成する。 inner->createSearchTable(); for (itr=import_nodes.begin(); itr!=import_nodes.end(); itr++) { UdmNode *find_node = inner->findMpiRankInfo(*itr); // 既存節点(ノード)であるかチェックする. if (find_node != NULL) continue; // 追加ノードの格納 insert_nodes.push_back(*itr); } // 格納した追加ノードを追加する for (itr=insert_nodes.begin(); itr!=insert_nodes.end(); itr++) { // インポート節点(ノード)を追加する. this->insertNode((*itr)); // 無効MPIランク情報を削除する (*itr)->removeMpiRankInfo((*itr)->getMyRankno(), 0); } return UDM_OK; } /** * 仮想節点(ノード)を追加する. * @param virtual_nodes 仮想節点(ノード)リスト * @return エラー番号 : UDM_OK | UDM_ERROR */ UdmError_t UdmGridCoordinates::importVirtualNodes(const std::vector<UdmNode*>& virtual_nodes) { std::vector<UdmNode*>::const_iterator itr; std::vector<UdmNode*>::const_iterator found_itr; for (itr=virtual_nodes.begin(); itr!=virtual_nodes.end(); itr++) { UdmNode* node = (*itr); if (node->getRealityType() != Udm_Virtual) continue; // 既存仮想節点(ノード)が存在するかチェックする. found_itr = this->searchGlobalId(this->virtual_nodes, node); if (found_itr != this->virtual_nodes.end()) { continue; } // インポート節点(ノード)を追加する. this->insertVirtualNode(node); } // 仮想要素(セル)ローカルIDの再構築 this->rebuildVirtualNodes(); return UDM_OK; } /** * 内部境界管理クラスを取得する. * @return 内部境界管理クラス */ UdmRankConnectivity* UdmGridCoordinates::getRankConnectivity() const { if (this->parent_zone == NULL) return NULL; return this->parent_zone->getRankConnectivity(); } /** * 内部境界リストから節点(ノード)を削除する. * @param node 削除節点(ノード) * @return エラー番号 : UDM_OK | UDM_ERROR */ UdmError_t UdmGridCoordinates::removeRankConnectivity(const UdmEntity* node) const { if (node == NULL) return UDM_ERROR; UdmRankConnectivity* inner = this->getRankConnectivity(); if (inner == NULL) { return UDM_ERROR; } // 内部境界リストから削除する. inner->removeBoundaryNode(node); return UDM_OK; } /** * 節点(ノード)のIDの再構築を行う。 * @return エラー番号 : UDM_OK | UDM_ERROR */ UdmError_t UdmGridCoordinates::rebuildNodes() { UdmSize_t node_id = 0; std::vector<UdmNode*>::iterator itr; for (itr=this->node_list.begin(); itr!= this->node_list.end(); itr++) { UdmNode *node = (*itr); // 現在のIDを以前のIDに設定する. node_id = ++node_id; //if (node->getMyRankno() != this->getMpiRankno() || node->getId() != node_id) { node->addPreviousRankInfo(node->getMyRankno(), node->getId()); //} node->setId(node_id); // IDをインクリメントして設定する node->setLocalId(node_id); // ローカルIDを設定する node->setMyRankno(this->getMpiRankno()); } // 設定済み最大節点(ノード)ID this->max_nodeid = node_id; return UDM_OK; } /** * グリッド座標の基本情報を全プロセスに送信する. * すべてのプロセスにて同一グリッド座標情報が存在するかチェックする. * @return エラー番号 : UDM_OK | UDM_ERROR */ UdmError_t UdmGridCoordinates::brodcastGridCoordinates() { int mpi_flag; int mpi_rankno; UdmError_t error = UDM_OK; // MPI初期化済みであるかチェックする. udm_mpi_initialized(&mpi_flag); if (!mpi_flag) { return UDM_ERROR_HANDLER(UDM_ERROR_INVALID_MPI, "Please execute MPI_Init beforehand."); } if (!(this->getMpiRankno() >= 0 && this->getMpiProcessSize() >= 1)) { return UDM_ERROR_HANDLER(UDM_ERROR_INVALID_MPI, "invalid mpi process [mpi_rankno=%d,mpi_num_process=%d].", this->getMpiRankno(), this->getMpiProcessSize()); } mpi_rankno = this->getMpiRankno(); UdmSerializeBuffer streamBuffer; UdmSerializeArchive archive(&streamBuffer); int buf_size = 0; char* buf = NULL; if (mpi_rankno == 0) { // シリアライズを行う:バッファーサイズ取得 archive << *this; buf_size = archive.getOverflowSize(); if (buf_size > 0) { // バッファー作成 buf = new char[buf_size]; streamBuffer.initialize(buf, buf_size); // シリアライズを行う archive << *this; } } // バッファーサイズ送信 udm_mpi_bcast(&buf_size, 1, MPI_INT, 0, this->getMpiComm()); if (buf_size <= 0) { return UDM_ERROR_HANDLER(UDM_ERROR_SERIALIZE, "buffer size is zero."); } if (buf == NULL) { // バッファー作成 buf = new char[buf_size]; } // UdmModelシリアライズバッファー送信 udm_mpi_bcast(buf, buf_size, MPI_CHAR, 0, this->getMpiComm()); // デシリアライズ UdmGridCoordinates mpi_grid; streamBuffer.initialize(buf, buf_size); archive >> mpi_grid; if (buf != NULL) { delete []buf; buf = NULL; } // グリッド座標情報が作成済みであるかチェックする. if (this->getNumNodes() == 0) { // グリッド座標情報未作成であるので、グリッド座標情報をコピーする. error = this->cloneGridCoordinates(mpi_grid); if (error != UDM_OK) { UDM_ERRORNO_HANDLER(error); } } // グリッド座標情報が存在するので、グリッド座標情報が同一であるかチェックする. else if (!this->equalsGridCoordinates(mpi_grid)) { error = UDM_ERROR_HANDLER(UDM_ERROR_CGNS_INVALID_GRIDCOORDINATES, "not equals GridCoordinates."); } // ACK if (udm_mpi_ack(&error, this->getMpiComm()) != UDM_OK) { return UDM_ERRORNO_HANDLER(UDM_ERROR_MPI_ACK); } return UDM_OK; } /** * グリッド座標の基本情報のシリアライズを行う. * @param archive シリアライズ・デシリアライズクラス */ UdmSerializeArchive& UdmGridCoordinates::serialize(UdmSerializeArchive& archive) const { // Genaral基本情報 // ID : CGNSノードID、要素ローカルID, ノードローカルID // CGNSノードのデータ型 UdmGeneral::serializeGeneralBase(archive, this->getId(), this->getDataType(), this->getName()); return archive; } /** * グリッド座標の基本情報のデシリアライズを行う. * @param archive シリアライズ・デシリアライズクラス */ UdmSerializeArchive& UdmGridCoordinates::deserialize(UdmSerializeArchive& archive) { UdmSize_t grid_id; UdmDataType_t grid_datatype; std::string grid_name; // Genaral基本情報 UdmGeneral::deserializeGeneralBase(archive, grid_id, grid_datatype, grid_name); this->setId(grid_id); this->setDataType(grid_datatype); this->setName(grid_name); return archive; } /** * グリッド座標の基本情報をコピーする. * @param src コピー元グリッド座標 * @return エラー番号 : UDM_OK | UDM_ERROR */ UdmError_t UdmGridCoordinates::cloneGridCoordinates(const UdmGridCoordinates& src) { // ID this->setId(src.getId()); // データ型 this->setDataType(src.getDataType()); // 名前 this->setName(src.getName()); return UDM_OK; } /** * 同一グリッド座標情報であるかチェックする. * グリッド座標情報の基本情報が同じであるかチェックする. * @param model チェック対象グリッド座標情報 * @return true=同一 */ bool UdmGridCoordinates::equalsGridCoordinates(const UdmGridCoordinates& grid) const { if (this->getId() != grid.getId()) return false; if (this->getDataType() != grid.getDataType()) return false; if (this->getName() != grid.getName()) return false; return true; } /** * 仮想節点(ノード)リストを取得する. * @return 仮想節点(ノード)リスト */ const std::vector<UdmNode*>& UdmGridCoordinates::getVirtualNodes() const { return this->virtual_nodes; } /** * CGNS:GridCoordinatesが出力済みであるかチェックする. * @param filename CGNSファイル名 * @param index_base CGNSベースインデックス:デフォルト=1 * @param index_zone CGNSゾーンインデックス:デフォルト=1 * @return true=CGNS:GridCoordinatesが出力済み */ bool UdmGridCoordinates::existsCgnsGridCoordnates( const std::string& filename, int index_base, int index_zone) { int index_file; // CGNSファイルオープン if (cg_open(filename.c_str(), CG_MODE_READ, &index_file) != CG_OK) { // UDM_ERROR_HANDLER(UDM_ERROR_CGNS_OPENERROR, "filename=%s, cgns_error=%s", filename.c_str(), cg_get_error()); return false; } if (cg_goto(index_file, index_base, "Zone_t", index_zone, UDM_CGNS_NAME_GRIDCOORDINATES, 0, "end") != CG_OK) { return false; // CGNS:GridCoordinatesが存在しない. } return true; } /** * 自ランク番号以下と接続している節点(ノード)を除いた節点(ノード)数を取得する。 * 節点(ノード)数ー(接続節点数ー自ランク番号以上の接続節点数) * @return 自ランク番号以上の接続る節点数 */ UdmSize_t UdmGridCoordinates::getNumNodesWithoutLessRankno() const { UdmSize_t num_nodes = this->getNumNodes(); UdmRankConnectivity* rank_conn = this->getRankConnectivity(); if (rank_conn == NULL) { return UDM_ERROR_HANDLER(UDM_ERROR_NULL_VARIABLE, "UdmRankConnectivity is null"); } // 接続節点数 UdmSize_t num_conns = rank_conn->getNumBoundaryNodes(); if (num_conns <= 0) return num_nodes; if (num_conns > num_nodes) return num_nodes; // 自ランク番号以上の接続節点数 UdmSize_t num_conn_ranks = rank_conn->getNumNodesWithoutLessRankno(); if (num_conns < num_conn_ranks) return num_nodes; return num_nodes - (num_conns - num_conn_ranks); } /** * GridCoordinates名称のGridCoordinatesインデックスを取得する. * @param index_file CGNSファイルインデックス * @param index_base CGNSベースインデックス * @param index_zone CGNSゾーンインデックス * @param gridname GridCoordinates名称 * @return GridCoordinatesインデックス(GridCoordinates名称が存在しない場合は、0を返す) */ int UdmGridCoordinates::findCgnsGridCoordinates( int index_file, int index_base, int index_zone, const char* gridname) const { int num_grids = 0; int n; char cgns_name[33] = {0x00}; cg_ngrids(index_file, index_base, index_zone, &num_grids); if (num_grids <= 0) { return 0; } for (n=1; n<num_grids; n++) { cg_grid_read(index_file, index_base, index_zone, n, cgns_name); if (strcmp(cgns_name, gridname) == 0) { return n; } } return 0; } /** * 節点(ノード)の物理量データ値を取得する:スカラデータ. * @param [in] node_id 節点(ノード)ID(=1~) * @param [in] solution_name 物理量名 * @param [out] value 物理量データ値 * @return エラー番号 : UDM_OK | UDM_ERROR */ template<class VALUE_TYPE> UdmError_t UdmGridCoordinates::getSolutionScalar( UdmSize_t node_id, const std::string& solution_name, VALUE_TYPE& value) const { UdmEntity *entity = this->getNodeById(node_id); if (entity == NULL) return UDM_ERROR; return entity->getSolutionScalar<VALUE_TYPE>(solution_name, value); } /** * 節点(ノード)の物理量データ値を取得する:ベクトルデータ. * @param [in] node_id 節点(ノード)ID(=1~) * @param [in] solution_name 物理量名 * @param [out] values 物理量データ値リスト * @return ベクトルデータ数 */ template<class VALUE_TYPE> unsigned int UdmGridCoordinates::getSolutionVector( UdmSize_t node_id, const std::string& solution_name, VALUE_TYPE* values) const { UdmEntity *entity = this->getNodeById(node_id); if (entity == NULL) return 0; return entity->getSolutionVector<VALUE_TYPE>(solution_name, values); } /** * 節点(ノード)の物理量データ値を設定する:スカラデータ * @param node_id 節点(ノード)ID(=1~) * @param solution_name 物理量名 * @param value 物理量データ値 * @return エラー番号 : UDM_OK | UDM_ERROR */ template<class VALUE_TYPE> UdmError_t UdmGridCoordinates::setSolutionScalar( UdmSize_t node_id, const std::string& solution_name, VALUE_TYPE value) { UdmEntity *entity = this->getNodeById(node_id); if (entity == NULL) return UDM_ERROR; return entity->setSolutionScalar<VALUE_TYPE>(solution_name, value); } /** * 節点(ノード)の物理量データ値を設定する:ベクトルデータ * @param node_id 節点(ノード)ID(=1~) * @param solution_name 物理量名 * @param values 物理量データリスト * @param size 物理量データ数 * @return エラー番号 : UDM_OK | UDM_ERROR */ template<class VALUE_TYPE> UdmError_t UdmGridCoordinates::setSolutionVector( UdmSize_t node_id, const std::string& solution_name, const VALUE_TYPE* values, unsigned int size) { UdmEntity *entity = this->getNodeById(node_id); if (entity == NULL) return UDM_ERROR; return entity->setSolutionVector<VALUE_TYPE>(solution_name, values, size); } template UdmError_t UdmGridCoordinates::getSolutionScalar<int>(UdmSize_t node_id, const std::string& solution_name, int& value) const; template UdmError_t UdmGridCoordinates::getSolutionScalar<long long>(UdmSize_t node_id, const std::string& solution_name, long long& value) const; template UdmError_t UdmGridCoordinates::getSolutionScalar<float>(UdmSize_t node_id, const std::string& solution_name, float& value) const; template UdmError_t UdmGridCoordinates::getSolutionScalar<double>(UdmSize_t node_id, const std::string& solution_name, double& value) const; template unsigned int UdmGridCoordinates::getSolutionVector<int>(UdmSize_t node_id, const std::string& solution_name, int* values) const; template unsigned int UdmGridCoordinates::getSolutionVector<long long>(UdmSize_t node_id, const std::string& solution_name, long long* values) const; template unsigned int UdmGridCoordinates::getSolutionVector<float>(UdmSize_t node_id, const std::string& solution_name, float* values) const; template unsigned int UdmGridCoordinates::getSolutionVector<double>(UdmSize_t node_id, const std::string& solution_name, double* values) const; template UdmError_t UdmGridCoordinates::setSolutionScalar<int>(UdmSize_t node_id, const std::string& solution_name, int value); template UdmError_t UdmGridCoordinates::setSolutionScalar<long long>(UdmSize_t node_id, const std::string& solution_name, long long value); template UdmError_t UdmGridCoordinates::setSolutionScalar<float>(UdmSize_t node_id, const std::string& solution_name, float value); template UdmError_t UdmGridCoordinates::setSolutionScalar<double>(UdmSize_t node_id, const std::string& solution_name, double value); template UdmError_t UdmGridCoordinates::setSolutionVector<int>(UdmSize_t node_id, const std::string& solution_name, const int* values, unsigned int size); template UdmError_t UdmGridCoordinates::setSolutionVector<long long>(UdmSize_t node_id, const std::string& solution_name, const long long* values, unsigned int size); template UdmError_t UdmGridCoordinates::setSolutionVector<float>(UdmSize_t node_id, const std::string& solution_name, const float* values, unsigned int size); template UdmError_t UdmGridCoordinates::setSolutionVector<double>(UdmSize_t node_id, const std::string& solution_name, const double* values, unsigned int size); /** * CGNS:GridCoordinatesを出力する. * @param index_file CGNSファイルインデックス * @param index_base CGNSベースインデックス * @param index_zone CGNSゾーンインデックス * @return エラー番号 : UDM_OK | UDM_ERROR */ UdmError_t UdmGridCoordinates::writeVirtualNodes(int index_file, int index_base, int index_zone) { char gridname[33] = {0x00}; int index_grid; UdmDataType_t datatype = Udm_RealSingle; DataType_t cgns_datatype; cgsize_t coords_size; cgsize_t virtual_size; cgsize_t actual_size; int cg_error = 0; UdmError_t udm_error = UDM_OK; // 出力CGNS:GridCoordinates名のクリア this->clearCgnsWriteGridCoordnates(); // ローカルIDを設定する. this->rebuildVirtualNodes(); // GridCoordinatesが存在するか sprintf(gridname, "GridCoordinates"); cg_error = 0; udm_error = UDM_OK; // CGNS:GridCoordinatesの出力先 index_grid = this->findCgnsGridCoordinates(index_file, index_base, index_zone, gridname); if (index_grid <= 0) { if (cg_grid_write(index_file,index_base,index_zone, gridname, &index_grid) != CG_OK) { return UDM_ERROR_HANDLER(UDM_ERROR_CGNS_INVALID_GRIDCOORDINATES, "failure : cg_grid_write(gridname=%s)", gridname); } } if (cg_goto(index_file,index_base, "Zone_t", index_zone, "GridCoordinates_t",index_grid, "end") != CG_OK) { return UDM_ERROR_HANDLER(UDM_ERROR_CGNS_INVALID_GRIDCOORDINATES, "failure : cg_goto(index_grid=%d)", index_grid); } datatype = this->getDataType(); cgns_datatype = this->toCgnsDataType(datatype); actual_size = this->getNumNodes(); virtual_size = this->getNumVirtualNodes(); coords_size = actual_size + virtual_size; if (datatype == Udm_RealSingle) { float *coords = new float[coords_size]; // CoordinateX出力 this->getGridCoordinatesX(1, actual_size, (float*)coords); this->getGridCoordinatesXOfVirtual(1, virtual_size, (float*)coords + actual_size); if ((cg_error = cg_array_write("CoordinateX", cgns_datatype, 1, &coords_size, coords)) != CG_OK) { udm_error = UDM_ERROR_HANDLER(UDM_ERROR_CGNS_INVALID_GRIDCOORDINATES, "failure : cg_array_write(CoordinateX)"); } if (udm_error != UDM_OK) { delete []coords; return udm_error; } // CoordinateY出力 this->getGridCoordinatesY(1, actual_size, (float*)coords); this->getGridCoordinatesYOfVirtual(1, virtual_size, (float*)coords + actual_size); if ((cg_error = cg_array_write("CoordinateY", cgns_datatype, 1, &coords_size, coords)) != CG_OK) { udm_error = UDM_ERROR_HANDLER(UDM_ERROR_CGNS_INVALID_GRIDCOORDINATES, "failure : cg_array_write(CoordinateY)"); } if (udm_error != UDM_OK) { delete []coords; return udm_error; } // CoordinateZ出力 this->getGridCoordinatesY(1, actual_size, (float*)coords); this->getGridCoordinatesYOfVirtual(1, virtual_size, (float*)coords + actual_size); if ((cg_error = cg_array_write("CoordinateZ", cgns_datatype, 1, &coords_size, coords)) != CG_OK) { udm_error = UDM_ERROR_HANDLER(UDM_ERROR_CGNS_INVALID_GRIDCOORDINATES, "failure : cg_array_write(CoordinateZ)"); } if (udm_error != UDM_OK) { delete []coords; return udm_error; } delete []coords; } else if (datatype == Udm_RealDouble) { double *coords = new double[coords_size]; // CoordinateX出力 this->getGridCoordinatesX(1, actual_size, (double*)coords); this->getGridCoordinatesXOfVirtual(1, virtual_size, (double*)coords + actual_size); if ((cg_error = cg_array_write("CoordinateX", cgns_datatype, 1, &coords_size, coords)) != CG_OK) { udm_error = UDM_ERROR_HANDLER(UDM_ERROR_CGNS_INVALID_GRIDCOORDINATES, "failure : cg_array_write(CoordinateX)"); } if (udm_error != UDM_OK) { delete []coords; return udm_error; } // CoordinateY出力 this->getGridCoordinatesY(1, actual_size, (double*)coords); this->getGridCoordinatesYOfVirtual(1, virtual_size, (double*)coords + actual_size); if ((cg_error = cg_array_write("CoordinateY", cgns_datatype, 1, &coords_size, coords)) != CG_OK) { udm_error = UDM_ERROR_HANDLER(UDM_ERROR_CGNS_INVALID_GRIDCOORDINATES, "failure : cg_array_write(CoordinateY)"); } if (udm_error != UDM_OK) { delete []coords; return udm_error; } // CoordinateZ出力 this->getGridCoordinatesY(1, actual_size, (double*)coords); this->getGridCoordinatesYOfVirtual(1, virtual_size, (double*)coords + actual_size); if ((cg_error = cg_array_write("CoordinateZ", cgns_datatype, 1, &coords_size, coords)) != CG_OK) { udm_error = UDM_ERROR_HANDLER(UDM_ERROR_CGNS_INVALID_GRIDCOORDINATES, "failure : cg_array_write(CoordinateZ)"); } if (udm_error != UDM_OK) { delete []coords; return udm_error; } delete []coords; } else { return UDM_ERROR_HANDLER(UDM_ERROR_CGNS_INVALID_GRIDCOORDINATES, "invalid coordinates datatype"); } if (udm_error != UDM_OK) return udm_error; // 出力CGNS:GridCoordinates名を設定する. this->setCgnsWriteGridCoordnates(std::string(gridname)); // CGNS:UdmRankConenctivityを書き込む. if (this->getRankConnectivity() != NULL) { if (this->getRankConnectivity()->writeCgns(index_file, index_base, index_zone) != UDM_OK) { udm_error = UDM_ERROR_HANDLER(UDM_ERROR_CGNS_INVALID_USERDEFINEDDATA, "failure : UdmRankConnectivity::writeCgns(index_file=%d, index_base=%d, index_zone=%d)", index_file, index_base, index_zone); } } return udm_error; } /** * 仮想節点(ノード)のIDの再構築を行う。 * ローカルIDに構成節点(ノード)+連番を設定する * @return エラー番号 : UDM_OK | UDM_ERROR */ UdmError_t UdmGridCoordinates::rebuildVirtualNodes() { UdmSize_t node_id = this->node_list.size(); std::vector<UdmNode*>::iterator itr; for (itr=this->virtual_nodes.begin(); itr!= this->virtual_nodes.end(); itr++) { UdmNode *node = (*itr); node->setLocalId(++node_id); // IDをインクリメントして設定する } return UDM_OK; } /** * CGNS:GrdiCoordinatesを結合する. * @param dest_grid 結合GridCoordinates * @return エラー番号 : UDM_OK | UDM_ERROR */ UdmError_t UdmGridCoordinates::joinCgnsGridCoordinates(UdmGridCoordinates* dest_grid) { UdmSize_t n; if (dest_grid == NULL) { return UDM_ERROR_HANDLER(UDM_ERROR_INVALID_PARAMETERS, "dest_grid is null."); } UdmRankConnectivity *inner_boundary = this->getRankConnectivity(); if (inner_boundary == NULL) { return UDM_ERROR_HANDLER(UDM_ERROR_NULL_VARIABLE, "UdmRankConnectivity is null."); } // MPI接続ランク番号, IDの検索テーブルを作成する. inner_boundary->createSearchMpiRankidTable(); UdmSize_t num_nodes = dest_grid->getNumNodes(); for (n=1; n<=num_nodes; n++) { UdmNode *dest_node = dest_grid->getNodeById(n); int dest_rankno = dest_node->getMyRankno(); UdmSize_t node_id = dest_node->getId(); UdmNode *src_node = NULL; if (dest_node->getNumMpiRankInfos() > 0) { // 内部境界から同一節点(ノード)を検索する src_node = inner_boundary->findMpiRankInfo(dest_rankno, node_id); } if (src_node != NULL) { UdmSize_t src_nodeid = src_node->getId(); int src_rankno = src_node->getMyRankno(); // 追加済み節点(ノード)である。 // 接続ランク番号,IDを削除する. src_node->removeMpiRankInfo(dest_rankno, node_id); // ランク番号,IDを退避する. src_node->addPreviousRankInfo(dest_rankno, node_id); // 共通節点を設定する. dest_node->setCommonNode(src_node); continue; } // ランク番号,IDを退避する. dest_node->addPreviousRankInfo(dest_rankno, node_id); // 節点(ノード)を挿入する. this->insertNode(dest_node); // 共通節点はなし。 dest_node->setCommonNode(NULL); } // UdmZoneのdeleteにてUdmNodeがdeleteされない様に挿入節点(ノード)をeraseする // 残りの節点(ノード)は同一節点(ノード)が存在するので、UdmZoneの削除にて削除する。 /******************** std::vector<UdmNode*>::reverse_iterator rev_itr; for (rev_itr=dest_grid->node_list.rbegin(); rev_itr!=dest_grid->node_list.rend(); rev_itr++) { UdmNode *node = (*rev_itr); if (node->getCommonNode() == NULL) { // 構成節点(ノード)リストから削除 dest_grid->node_list.erase( --(rev_itr.base()) ); } } ******************/ std::vector<UdmNode*>::iterator itr; for (itr=dest_grid->node_list.begin(); itr!=dest_grid->node_list.end(); ) { UdmNode *node = (*itr); if (node->getCommonNode() == NULL) { // 構成節点(ノード)リストから削除 itr = dest_grid->node_list.erase( itr ); continue; } itr++; } return UDM_OK; } /** * 以前のID、ランク番号をクリアする. */ void UdmGridCoordinates::clearPreviousInfos() { std::vector<UdmNode*>::iterator itr; for (itr=this->node_list.begin(); itr!= this->node_list.end(); itr++) { UdmNode *node = (*itr); node->clearPreviousInfos(); } return; } /** * 削除節点(ノード)リストを削除する. * @param remove_nodes 削除節点(ノード)リスト * @return エラー番号 : UDM_OK | UDM_ERROR */ UdmError_t UdmGridCoordinates::removeNodes(const std::vector<UdmNode*>& remove_nodes) { std::vector<UdmNode*>::const_iterator itr; for (itr=remove_nodes.begin(); itr!=remove_nodes.end(); itr++) { UdmNode* node = (*itr); if (node != NULL) { node->setRemoveEntity(true); } } // 構成ノードから削除 UdmSize_t erase_size = this->node_list.size(); this->node_list.erase( std::remove_if( this->node_list.begin(), this->node_list.end(), std::mem_fun(&UdmEntity::isRemoveEntity)), this->node_list.end()); erase_size -= this->node_list.size(); if (erase_size < remove_nodes.size()) { // 仮想ノードから削除 erase_size += this->virtual_nodes.size(); this->virtual_nodes.erase( std::remove_if( this->virtual_nodes.begin(), this->virtual_nodes.end(), std::mem_fun(&UdmEntity::isRemoveEntity)), this->virtual_nodes.end()); erase_size -= this->virtual_nodes.size(); } // 内部境界リストから削除する UdmRankConnectivity* inner = this->getRankConnectivity(); if (inner != NULL) { // 内部境界リストから削除する. inner->removeBoundaryNodes(remove_nodes); } // 節点(ノード)の削除 for (itr=remove_nodes.begin(); itr!=remove_nodes.end(); itr++) { UdmNode* node = (*itr); if (node != NULL) { delete node; } } return UDM_OK; } /** * 内部境界情報を節点(ノード)に追加する. * @param node_id 節点(ノード)ID(1~) * @param rankno 接続先MPIランク番号(0~) * @param localid 接続先節点(ノード)ID(1~) * @return エラー番号 : UDM_OK | UDM_ERROR */ UdmError_t UdmGridCoordinates::insertRankConnectivity( UdmSize_t node_id, int rankno, UdmSize_t localid) { if (rankno < 0) return UDM_ERROR; if (localid <= 0) return UDM_ERROR; UdmNode *node = this->getNodeById(node_id); // 内部境界情報を追加する. node->addMpiRankInfo(rankno, localid); // 内部境界に追加する if (node->getNumMpiRankInfos() > 0) { if (this->getRankConnectivity() != NULL) { this->getRankConnectivity()->insertRankConnectivityNode(node); } } return UDM_OK; } /** * ランク番号とIDが一致している仮想節点(ノード)を検索する. * @param src_rankno ランク番号 * @param src_nodeid 節点(ノード)ID * @return 節点(ノード) */ UdmNode* UdmGridCoordinates::findVirtualNodeByGlobalId(int src_rankno, UdmSize_t src_nodeid) const { if (src_rankno < 0) return NULL; if (src_nodeid <= 0) return NULL; UdmNode *find_node = NULL; // グリッド構成ノードリストの配列添字として検索 find_node = this->getVirtualNodeById(src_nodeid); if (find_node != NULL) { if (find_node->getMyRankno() == src_rankno) { return find_node; } find_node = NULL; } // 2分探索でグローバルIDを検索する std::vector<UdmNode*>::const_iterator find_itr; find_itr = this->searchCurrentGlobalId(this->virtual_nodes, src_rankno, src_nodeid); if (find_itr != this->virtual_nodes.end()) { find_node = (*find_itr); return find_node; } return NULL; } /** * メモリサイズを取得する. * @return メモリサイズ */ size_t UdmGridCoordinates::getMemSize() const { UdmSize_t size = sizeof(*this); #ifdef _DEBUG printf("this size=%ld\n", sizeof(*this)); printf("node_list size=%ld [count=%ld] [offset=%ld]\n", sizeof(this->node_list), this->node_list.size(), offsetof(UdmGridCoordinates, node_list)); printf("virtual_nodes size=%ld [count=%ld] [offset=%ld]\n", sizeof(this->virtual_nodes), this->virtual_nodes.size(), offsetof(UdmGridCoordinates, virtual_nodes)); printf("parent_zone pointer size=%ld [offset=%ld]\n", sizeof(this->parent_zone), offsetof(UdmGridCoordinates, parent_zone)); printf("cgns_writegridcoordnates size=%ld [offset=%ld]\n", sizeof(this->cgns_writegridcoordnates), offsetof(UdmGridCoordinates, cgns_writegridcoordnates)); printf("max_nodeid size=%ld [offset=%ld]\n", sizeof(this->max_nodeid), offsetof(UdmGridCoordinates, max_nodeid)); size += this->node_list.size()*sizeof(UdmNode*); size += this->virtual_nodes.size()*sizeof(UdmNode*); #endif return size; } } /* namespace udm */
32.829349
207
0.637776
avr-aics-riken
95f51e6d68125e62b3c13fd5ffbb14983da5ee3f
2,567
cpp
C++
yotta_modules/core-util/test/PoolAllocator/main.cpp
lbk003/mbed-cortexm
a4fcb5de906a49a7fa737d6a89fcf5590aa68d31
[ "Apache-2.0" ]
null
null
null
yotta_modules/core-util/test/PoolAllocator/main.cpp
lbk003/mbed-cortexm
a4fcb5de906a49a7fa737d6a89fcf5590aa68d31
[ "Apache-2.0" ]
null
null
null
yotta_modules/core-util/test/PoolAllocator/main.cpp
lbk003/mbed-cortexm
a4fcb5de906a49a7fa737d6a89fcf5590aa68d31
[ "Apache-2.0" ]
null
null
null
/* * PackageLicenseDeclared: Apache-2.0 * Copyright (c) 2015 ARM Limited * * 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 "core-util/PoolAllocator.h" #include "mbed-drivers/test_env.h" #include <stdio.h> #include <stdlib.h> using namespace mbed::util; void app_start(int, char**) { MBED_HOSTTEST_TIMEOUT(5); MBED_HOSTTEST_SELECT(default); MBED_HOSTTEST_DESCRIPTION(mbed-util pool allocator test); MBED_HOSTTEST_START("MBED_UTIL_POOL_ALLOCATOR_TEST"); // Allocate initial space for the pool const size_t elements = 10, element_size = 6; const size_t aligned_size = (element_size + MBED_UTIL_POOL_ALLOC_DEFAULT_ALIGN - 1) & ~(MBED_UTIL_POOL_ALLOC_DEFAULT_ALIGN - 1); size_t pool_size = PoolAllocator::get_pool_size(elements, element_size); MBED_HOSTTEST_ASSERT(pool_size == elements * aligned_size); void *start = malloc(pool_size); MBED_HOSTTEST_ASSERT(start != NULL); PoolAllocator allocator(start, elements, element_size); // Allocate all elements, checking for proper alignment and spacing void *p, *prev, *first; for (size_t i = 0; i < elements; i ++) { p = allocator.alloc(); MBED_HOSTTEST_ASSERT(p != NULL); // Check alignment MBED_HOSTTEST_ASSERT(((uint32_t)p & (MBED_UTIL_POOL_ALLOC_DEFAULT_ALIGN - 1)) == 0); // Check spacing if (i > 0) { MBED_HOSTTEST_ASSERT(((uint32_t)p - (uint32_t)prev) == aligned_size); } else { first = p; MBED_HOSTTEST_ASSERT(p == start); } prev = p; } // No more space in the pool, we should get NULL now MBED_HOSTTEST_ASSERT(allocator.alloc() == NULL); // Free the first element we allocated allocator.free(first); // Verify that we can allocate a single element now, and it has the same address // as the first element we allocated above p = allocator.alloc(); MBED_HOSTTEST_ASSERT(p == first); p = allocator.alloc(); MBED_HOSTTEST_ASSERT(p == NULL); MBED_HOSTTEST_RESULT(true); }
34.689189
132
0.687183
lbk003
95f63141ee8879d95b09b6d158efeaadc1b9224a
981
cpp
C++
topic_wise/binarysearch/russianDollEnvelopes.cpp
archit-1997/LeetCode
7c0f74da0836d3b0855f09bae8960f81a384f3f3
[ "MIT" ]
1
2021-01-27T16:37:36.000Z
2021-01-27T16:37:36.000Z
topic_wise/binarysearch/russianDollEnvelopes.cpp
archit-1997/LeetCode
7c0f74da0836d3b0855f09bae8960f81a384f3f3
[ "MIT" ]
null
null
null
topic_wise/binarysearch/russianDollEnvelopes.cpp
archit-1997/LeetCode
7c0f74da0836d3b0855f09bae8960f81a384f3f3
[ "MIT" ]
null
null
null
/** * @author : archit * @GitHub : archit-1997 * @Email : architsingh456@gmail.com * @file : russianDollEnvelopes.cpp * @created : Friday Aug 20, 2021 19:49:02 IST */ #include <bits/stdc++.h> using namespace std; bool compare(const vector<int> &a,const vector<int> &b){ if(a[0]==b[0]) return a[1]>b[1]; return a[0]<b[0]; } class Solution { public: int maxEnvelopes(vector<vector<int>>& envelopes) { int n=envelopes.size(); //we will sort on the basis of the first param and in descending on the basis of the second param vector<int> ans; sort(envelopes.begin(),envelopes.end(),compare); for(int i=0;i<n;i++){ int index=lower_bound(ans.begin(),ans.end(),envelopes[i][1])-ans.begin(); if(index==ans.size()) ans.push_back(envelopes[i][1]); else ans[index]=envelopes[i][1]; } return ans.size(); } };
27.25
105
0.559633
archit-1997
95f76b3ce45e04a7abf750e2e3d9b2f6d346a253
6,160
cpp
C++
1.Race Condition/RaceCondition/main.cpp
Cabrra/Multithreading
0259f6cb48534e583818b10274698df130fd222e
[ "MIT" ]
null
null
null
1.Race Condition/RaceCondition/main.cpp
Cabrra/Multithreading
0259f6cb48534e583818b10274698df130fd222e
[ "MIT" ]
null
null
null
1.Race Condition/RaceCondition/main.cpp
Cabrra/Multithreading
0259f6cb48534e583818b10274698df130fd222e
[ "MIT" ]
null
null
null
// Include file and line numbers for memory leak detection for visual studio in debug mode // NOTE: The current implementation of C++11 shipped with Visual Studio 2012 will leak a single // 44-byte mutex (at_thread_exit_mutex) internally if any threads have been created. This // will show up in the output window without a filename or line number. #if defined _MSC_VER && defined _DEBUG #include <crtdbg.h> #define new new(_NORMAL_BLOCK, __FILE__, __LINE__) #define ENABLE_LEAK_DETECTION() _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF) #else #define ENABLE_LEAK_DETECTION() #endif #define WAIT_FOR_THREAD(r) if ((r)->joinable()) (r)->join(); #include <iostream> #include <thread> #include <vector> #include <mutex> #include <condition_variable> using namespace std; struct ThreadStruct { // ID of the thread int id; // Length of the shared string int sharedStringLength; // Number of strings a single thread will generate int numberOfStringsToGenerate; // Amount of time to sleep before generating strings int waitTime; // Shared string that will be generate in each thread. This memory is shared among all threads. char *sharedString; //my data int runType; std::mutex* Mutex; std::condition_variable* cv; int* currID; }; /////////////////////////////////////////////////////////////////////////////////////////// // Prompts the user to press enter and waits for user input /////////////////////////////////////////////////////////////////////////////////////////// void Pause() { printf("Press enter to continue\n"); getchar(); } /////////////////////////////////////////////////////////////////////////////////// // Entry point for worker threads. // // Arguments: // threadData - Pointer to per-thread data for this thread. /////////////////////////////////////////////////////////////////////////////////// void ThreadEntryPoint(ThreadStruct *threadData) { if (threadData->runType == 2) threadData->Mutex->lock(); if (threadData->runType == 3) { std::unique_lock<std::mutex> locked(*threadData->Mutex); threadData->cv->wait(locked, [threadData](){return *threadData->currID == threadData->id; }); } for(int i = 0; i < threadData->numberOfStringsToGenerate; i++) { if (threadData->waitTime != 0) { // Blocks the current thread for a given amount of time. std::this_thread::sleep_for(std::chrono::milliseconds(threadData->waitTime)); } if (threadData->runType == 1) //type 1 threadData->Mutex->lock(); for (int j = 0; j < threadData->sharedStringLength; j++) { std::this_thread::sleep_for(std::chrono::milliseconds(1)); threadData->sharedString[j] = 'A' + threadData->id; } printf("Thread %d: %s\n", threadData->id, threadData->sharedString); if (threadData->runType == 1) //type 1 threadData->Mutex->unlock(); } if (threadData->runType == 2) threadData->Mutex->unlock(); if (threadData->runType == 3) { (*threadData->currID)++; threadData->cv->notify_all(); } } int main(int argc, char** argv) { ENABLE_LEAK_DETECTION(); int threadCount = 0; int sharedStringLength = 0; int numberOfStringsToGenerate = 0; int waitTime = 0; char *sharedString = nullptr; int runType = 0; ThreadStruct *perThreadData = nullptr; if (argc - 1 != 5) { fprintf(stderr, "Error: missing or incorrect command line arguments\n\n"); fprintf(stderr, "Usage: RaceCondition threadCount sharedStringLength numberOfStringsToGenerate waitTime runType\n\n"); fprintf(stderr, "Arguments:\n"); fprintf(stderr, " threadCount Number of threads to create.\n"); fprintf(stderr, " sharedStringLength Length of string to generate.\n"); fprintf(stderr, " numberOfStringsToGenerate Number of strings to generate per thread.\n"); fprintf(stderr, " waitTime Time to wait before generating the string.\n"); fprintf(stderr, " runType The run type.\n\n"); Pause(); return 1; } threadCount = atoi(argv[1]); sharedStringLength = atoi(argv[2]); numberOfStringsToGenerate = atoi(argv[3]); waitTime = atoi(argv[4]); runType = atoi(argv[5]); if(threadCount < 0 || sharedStringLength < 0 || numberOfStringsToGenerate < 0 || waitTime < 0 || runType < 0) { fprintf(stderr, "Error: All arguments must be positive integer values.\n"); Pause(); return 1; } printf("%d thread(s), string sharedStringLength %d, %d iterations, %d ms pause\n", threadCount, sharedStringLength, numberOfStringsToGenerate, waitTime); sharedString = new char[sharedStringLength + 1]; memset(sharedString, 0, sharedStringLength + 1); perThreadData = new ThreadStruct[threadCount]; //container to store the thread classes std::vector<std::thread*> myThreads; std::mutex myMutex = std::mutex(); std::condition_variable myCV = std::condition_variable(); int currentID = 0; for (int i = threadCount - 1; i >= 0; i--) { perThreadData[i].id = i; perThreadData[i].sharedStringLength = sharedStringLength; perThreadData[i].numberOfStringsToGenerate = numberOfStringsToGenerate; perThreadData[i].waitTime = waitTime; perThreadData[i].sharedString = sharedString; //my variables perThreadData[i].runType = runType; perThreadData[i].Mutex = &myMutex; perThreadData[i].cv = &myCV; perThreadData[i].currID = &currentID; //Setup any additional variables in perThreadData and start the threads. std::thread* thre = new std::thread(ThreadEntryPoint, &perThreadData[i]); myThreads.push_back(thre); } /////////////////////////////////////////////////////////////////////////////////// // Wait for all of the threads to finish. Since we are using // Joinable threads we must Join each one. Joining a thread will cause // the calling thread (main in this case) to block until the thread being // joined has completed executing. /////////////////////////////////////////////////////////////////////////////////// for (int i = 0; i < threadCount; i++) WAIT_FOR_THREAD(myThreads[i]); for (int i = 0; i < threadCount; i++) { delete myThreads[i]; } delete[] sharedString; delete[] perThreadData; Pause(); return 0; }
32.083333
120
0.641396
Cabrra
95f98cdeb21f069a00008843f3f93c41ab1c6da8
310
cpp
C++
aql/benchmark/lib_18/class_6.cpp
menify/sandbox
32166c71044f0d5b414335b2b6559adc571f568c
[ "MIT" ]
null
null
null
aql/benchmark/lib_18/class_6.cpp
menify/sandbox
32166c71044f0d5b414335b2b6559adc571f568c
[ "MIT" ]
null
null
null
aql/benchmark/lib_18/class_6.cpp
menify/sandbox
32166c71044f0d5b414335b2b6559adc571f568c
[ "MIT" ]
null
null
null
#include "class_6.h" #include "class_0.h" #include "class_8.h" #include "class_5.h" #include "class_7.h" #include "class_4.h" #include <lib_8/class_9.h> #include <lib_13/class_3.h> #include <lib_13/class_2.h> #include <lib_0/class_0.h> #include <lib_11/class_6.h> class_6::class_6() {} class_6::~class_6() {}
20.666667
27
0.712903
menify
2503e048a00ec653a7ee4ad553e908b8545f859c
8,922
cpp
C++
ds/security/services/scerpc/xml-jet/secman/securitydatabase.cpp
npocmaka/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
17
2020-11-13T13:42:52.000Z
2021-09-16T09:13:13.000Z
ds/security/services/scerpc/xml-jet/secman/securitydatabase.cpp
sancho1952007/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
2
2020-10-19T08:02:06.000Z
2020-10-19T08:23:18.000Z
ds/security/services/scerpc/xml-jet/secman/securitydatabase.cpp
sancho1952007/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
14
2020-11-14T09:43:20.000Z
2021-08-28T08:59:57.000Z
/*++ Copyright (c) 2002 Microsoft Corporation Module Name: SecurityDatabase.cpp Abstract: Implementation of CSecurityDatabase interface SecurityDatabase is a COM interface that allows users to perform basic operations on SCE security databases such as analysis, import and export. This is a bare implementation just to expose export functionality of SCE analysis databases. Still needs work. Author: Steven Chan (t-schan) July 2002 --*/ #include <nt.h> #include <ntrtl.h> #include <nturtl.h> #include <windows.h> #include <string.h> #include <shlwapi.h> #include <winnlsp.h> #include <iostream.h> #include "stdafx.h" #include "SecMan.h" #include "SecurityDatabase.h" #include "SceXMLLogWriter.h" #include "SceAnalysisReader.h" #include "SceLogException.h" #include "secedit.h" //REMOVE ONCE DEMO IS DONE! CSecurityDatabase::CSecurityDatabase() { bstrFileName=L""; myModuleHandle=GetModuleHandle(L"SecMan.dll"); } STDMETHODIMP CSecurityDatabase::get_FileName(BSTR *pVal) { return bstrFileName.CopyTo(pVal); } STDMETHODIMP CSecurityDatabase::put_FileName(BSTR newVal) { bstrFileName = newVal; return S_OK; } STDMETHODIMP CSecurityDatabase::get_MachineName(BSTR *pVal) { return E_NOTIMPL; } STDMETHODIMP CSecurityDatabase::put_MachineName(BSTR newVal) { return E_NOTIMPL; } STDMETHODIMP CSecurityDatabase::ImportTemplateFile(BSTR FileName) { // IMPLEMENTED ONLY FOR DEMO!!! // Still needs work to convert SCESTATUS result code to HRESULT SceConfigureSystem(NULL, FileName, bstrFileName, NULL, SCE_OVERWRITE_DB | SCE_NO_CONFIG, AREA_ALL, NULL, NULL, NULL ); return S_OK; } STDMETHODIMP CSecurityDatabase::ImportTemplateString(BSTR TemplateString) { return E_NOTIMPL; } STDMETHODIMP CSecurityDatabase::Analyze() { // IMPLEMENTED ONLY FOR DEMO!!! // Still needs work to convert SCESTATUS result code to HRESULT SceAnalyzeSystem(NULL, NULL, bstrFileName, NULL, SCE_UPDATE_DB, AREA_ALL, NULL, NULL, NULL); return S_OK; } STDMETHODIMP CSecurityDatabase::ExportAnalysisToXML(BSTR FileName, BSTR ErrorLogFileName) /*++ Routine Description: exports the analysis information from this SecurityDatabase to FileName Arguments: FileName: XML file to export to ErrorLogFileName: Error log Return Value: none --*/ { HANDLE hLogFile=NULL; HRESULT result=S_OK; SceXMLLogWriter *LogWriter=NULL; SceAnalysisReader *AnalysisReader=NULL; // // initialize logfile if necessary // if log file fails to be created, we just go about not logging // (a parameter of NULL for log file handle to SceAnalysisReader::ExportAnalysis // indicates no logging // if (ErrorLogFileName!=NULL) { hLogFile = CreateFile(ErrorLogFileName, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); } try { trace(IDS_LOG_START_EXPORT, hLogFile); LogWriter = new SceXMLLogWriter(); AnalysisReader = new SceAnalysisReader(myModuleHandle, bstrFileName); AnalysisReader->ExportAnalysis(LogWriter, hLogFile); trace(IDS_LOG_SAVING, hLogFile); trace(FileName, hLogFile); trace(L"\n\r\n\r", hLogFile); LogWriter->SaveAs(FileName); trace(IDS_LOG_SUCCESS, hLogFile); } catch(SceLogException *e) { switch (e->ErrorType) { case SceLogException::SXERROR_INTERNAL: trace(IDS_LOG_ERROR_INTERNAL, hLogFile); result=E_UNEXPECTED; break; case SceLogException::SXERROR_OS_NOT_SUPPORTED: trace(IDS_LOG_ERROR_OS_NOT_SUPPORTED, hLogFile); result=ERROR_OLD_WIN_VERSION; break; case SceLogException::SXERROR_INIT: trace(IDS_LOG_ERROR_INTERNAL, hLogFile); result=ERROR_MOD_NOT_FOUND; break; case SceLogException::SXERROR_INIT_MSXML: trace(IDS_LOG_ERROR_INIT_MSXML, hLogFile); result=ERROR_MOD_NOT_FOUND; break; case SceLogException::SXERROR_SAVE: trace(IDS_LOG_ERROR_SAVE, hLogFile); result=ERROR_WRITE_FAULT; break; case SceLogException::SXERROR_SAVE_INVALID_FILENAME: trace(IDS_LOG_ERROR_SAVE_INVALID_FILENAME, hLogFile); result=ERROR_INVALID_NAME; break; case SceLogException::SXERROR_SAVE_ACCESS_DENIED: trace(IDS_LOG_ERROR_SAVE_ACCESS_DENIED, hLogFile); result=E_ACCESSDENIED; break; case SceLogException::SXERROR_OPEN: trace(IDS_LOG_ERROR_OPEN, hLogFile); result=ERROR_OPEN_FAILED; break; case SceLogException::SXERROR_OPEN_FILE_NOT_FOUND: trace(IDS_LOG_ERROR_OPEN_FILE_NOT_FOUND, hLogFile); result=ERROR_FILE_NOT_FOUND; break; case SceLogException::SXERROR_READ: trace(IDS_LOG_ERROR_READ, hLogFile); result=ERROR_READ_FAULT; break; case SceLogException::SXERROR_READ_NO_ANALYSIS_TABLE: trace(IDS_LOG_ERROR_READ_NO_ANALYSIS_TABLE, hLogFile); result=ERROR_READ_FAULT; break; case SceLogException::SXERROR_READ_NO_CONFIGURATION_TABLE: trace(IDS_LOG_ERROR_READ_NO_CONFIGURATION_TABLE, hLogFile); result=ERROR_READ_FAULT; break; case SceLogException::SXERROR_READ_ANALYSIS_SUGGESTED: trace(IDS_LOG_ERROR_READ_ANALYSIS_SUGGESTED, hLogFile); result=ERROR_READ_FAULT; break; case SceLogException::SXERROR_INSUFFICIENT_MEMORY: trace(IDS_LOG_ERROR_INSUFFICIENT_MEMORY, hLogFile); result=E_OUTOFMEMORY; break; default: trace(IDS_LOG_ERROR_UNEXPECTED, hLogFile); result=E_UNEXPECTED; break; } trace (IDS_LOG_ERROR_DEBUGINFO, hLogFile); trace (e->szDebugInfo, hLogFile); trace (L"\n\r",hLogFile); trace (IDS_LOG_ERROR_AREA, hLogFile); trace (e->szArea, hLogFile); trace (L"\n\r",hLogFile); trace (IDS_LOG_ERROR_SETTING, hLogFile); trace (e->szSettingName, hLogFile); delete e; } catch(...){ trace(IDS_LOG_ERROR_UNEXPECTED, hLogFile); result = E_UNEXPECTED; } if (NULL!=LogWriter) { delete LogWriter; LogWriter=NULL; } if (NULL!=AnalysisReader) { delete AnalysisReader; AnalysisReader=NULL; } if (NULL!=hLogFile) { CloseHandle(hLogFile); } return result; } void CSecurityDatabase::trace( PCWSTR szBuffer, HANDLE hLogFile ) /*++ Routine Description: Internal method to trace info to an error log. Arguments: szBuffer: string to be added to log hLogFile: handle of error log file Return Value: none --*/ { DWORD dwNumWritten; if ((NULL!=hLogFile) && (NULL!=szBuffer)) { WriteFile(hLogFile, szBuffer, wcslen(szBuffer)*sizeof(WCHAR), &dwNumWritten, NULL); } } void CSecurityDatabase::trace( UINT uID, HANDLE hLogFile ) /*++ Routine Description: Internal method to trace info to an error log. Arguments: uID: ID of string to be added to log hLogFile: handle of error log file Return Value: none --*/ { DWORD dwNumWritten; WCHAR szTmpStringBuffer[512]; if (NULL!=hLogFile) { LoadString(myModuleHandle, uID, szTmpStringBuffer, sizeof(szTmpStringBuffer)/sizeof(WCHAR)); WriteFile(hLogFile, szTmpStringBuffer, wcslen(szTmpStringBuffer)*sizeof(WCHAR), &dwNumWritten, NULL); } }
27.20122
90
0.580924
npocmaka
2503e7a6e385bccb094db584c03c8399d1f98eab
1,538
cc
C++
ChiTech/ChiMesh/SurfaceMesher/Predefined/surfmesher_predefined_02_execute.cc
Jrgriss2/chi-tech
db75df761d5f25ca4b79ee19d36f886ef240c2b5
[ "MIT" ]
7
2019-09-10T12:16:08.000Z
2021-05-06T16:01:59.000Z
ChiTech/ChiMesh/SurfaceMesher/Predefined/surfmesher_predefined_02_execute.cc
Jrgriss2/chi-tech
db75df761d5f25ca4b79ee19d36f886ef240c2b5
[ "MIT" ]
72
2019-09-04T15:00:25.000Z
2021-12-02T20:47:29.000Z
ChiTech/ChiMesh/SurfaceMesher/Predefined/surfmesher_predefined_02_execute.cc
Jrgriss2/chi-tech
db75df761d5f25ca4b79ee19d36f886ef240c2b5
[ "MIT" ]
41
2019-09-02T15:33:31.000Z
2022-02-10T13:26:49.000Z
#include "surfmesher_predefined.h" #include "../../MeshHandler/chi_meshhandler.h" #include "../../Region/chi_region.h" #include "../../Boundary/chi_boundary.h" #include<iostream> #include <chi_log.h> extern ChiLog& chi_log; void chi_mesh::SurfaceMesherPredefined::Execute() { chi_log.Log(LOG_0VERBOSE_1) << "SurfaceMesherPredefined executed"; //================================================== Get the current handler chi_mesh::MeshHandler* mesh_handler = chi_mesh::GetCurrentHandler(); //================================================== Check empty region list if (mesh_handler->region_stack.empty()) { chi_log.Log(LOG_ALLERROR) << "SurfaceMesherPredefined: No region added."; exit(EXIT_FAILURE); } //================================================== Loop over all regions // std::vector<chi_mesh::Region*>::iterator region_iter; // for (region_iter = mesh_handler->region_stack.begin(); // region_iter != mesh_handler->region_stack.end(); // region_iter++) for (auto region : mesh_handler->region_stack) { // chi_mesh::Region* region = *region_iter; //=========================================== Check for interfaces //=========================================== Clear non-initial continuums // region->volume_mesh_continua.clear(); //=========================================== Create new continuum // chi_mesh::MeshContinuumPtr remeshed_surfcont = chi_mesh::MeshContinuum::New(); // region->volume_mesh_continua.push_back(remeshed_surfcont); } }
34.177778
84
0.579324
Jrgriss2
2507f8068640fc6f36eb0b4121359f400f7b1814
1,034
cpp
C++
C++/problem0125.cpp
1050669722/LeetCode-Answers
c8f4d1ccaac09cda63b60d75144335347b06dc81
[ "MIT" ]
null
null
null
C++/problem0125.cpp
1050669722/LeetCode-Answers
c8f4d1ccaac09cda63b60d75144335347b06dc81
[ "MIT" ]
null
null
null
C++/problem0125.cpp
1050669722/LeetCode-Answers
c8f4d1ccaac09cda63b60d75144335347b06dc81
[ "MIT" ]
null
null
null
class Solution { public: bool isPalindrome(string s) { if (s.size() == 0) { return true; } vector<char> v; for (int i = 0; i < s.size(); ++i) { if (isalnum(s[i])) { v.push_back(s[i]); // cout << s[i] << ' '; } } int i = 0, j = v.size() - 1; while (i < j) { // cout << v[i] << ' ' << v[j] << endl; if (toupper(v[i]) != toupper(v[j])) // if (strupr(v[i]) != strupr(v[j])) { return false; } i++, j--; } // vector<char>::iterator it_i = v.begin(), it_j = v.end() - 1; // cout << *it_i << ' ' << *it_j << endl; // while (it_i < it_j) // { // if (toupper(*it_i) != toupper(*it_j)) // { // return false; // } // it_i++, it_j--; // } return true; } };
22
71
0.305609
1050669722
2508bfcdb6b42e2a10b88a833dd0167bfe49dda3
476
hpp
C++
king/include/king/Math/VectorType.hpp
tobiasbu/king
7a6892a93d5d4c5f14e2618104f2955281f0bada
[ "MIT" ]
3
2017-03-10T13:57:25.000Z
2017-05-31T19:05:35.000Z
king/include/king/Math/VectorType.hpp
tobiasbu/king
7a6892a93d5d4c5f14e2618104f2955281f0bada
[ "MIT" ]
null
null
null
king/include/king/Math/VectorType.hpp
tobiasbu/king
7a6892a93d5d4c5f14e2618104f2955281f0bada
[ "MIT" ]
null
null
null
#ifndef KING_VECTORTYPE_HPP #define KING_VECTORTYPE_HPP namespace king { // Vectors Types Predefinition template <typename T> class Vector2; template <typename T> class Vector3; template <typename T> class Vector4; // Most Commom Vectors Types typedef Vector2<float> Vector2f; typedef Vector2<int> Vector2i; typedef Vector2<unsigned int> Vector2ui; typedef Vector3<float> Vector3f; typedef Vector3<int> Vector3i; typedef Vector4<float> Vector4f; } #endif
18.307692
41
0.771008
tobiasbu
250c942de9921b043307f0332d526be930225d62
1,961
cpp
C++
src/PrintHelper.cpp
TB989/Game
9cf6e1267f1bc08b2e7f5f9a8278914f930c7c51
[ "MIT" ]
null
null
null
src/PrintHelper.cpp
TB989/Game
9cf6e1267f1bc08b2e7f5f9a8278914f930c7c51
[ "MIT" ]
null
null
null
src/PrintHelper.cpp
TB989/Game
9cf6e1267f1bc08b2e7f5f9a8278914f930c7c51
[ "MIT" ]
null
null
null
#include <string> #include <iostream> void startHeader(std::string locationName){ std::cout << "**********" << locationName << "**********\n"; } void finishHeader(std::string locationName){ std::cout << "**********"; for(unsigned int i=0;i<locationName.length();i++){ std::cout << "*"; } std::cout<< "**********\n"; } void printChoices(std::string option1){ std::cout << "What do you want to do?\n"; std::cout << "1: " << option1 << "\n"; } void printChoices(std::string option1,std::string option2){ std::cout << "What do you want to do?\n"; std::cout << "1: " << option1 << "\n"; std::cout << "2: " << option2 << "\n"; } void printChoices(std::string option1,std::string option2,std::string option3){ std::cout << "What do you want to do?\n"; std::cout << "1: " << option1 << "\n"; std::cout << "2: " << option2 << "\n"; std::cout << "3: " << option3 << "\n"; } void printChoices(std::string option1,std::string option2,std::string option3,std::string option4){ std::cout << "What do you want to do?\n"; std::cout << "1: " << option1 << "\n"; std::cout << "2: " << option2 << "\n"; std::cout << "3: " << option3 << "\n"; std::cout << "4: " << option4 << "\n"; } int getChoice(int maxChoices){ int choice; while(true){ std::cout << "Your choice: "; std::cin >> choice; std::cin.ignore(32767, '\n'); if(!std::cin.fail()){ if(choice==0){ exit(0); } else if(0<choice&&choice<=maxChoices){ return choice; } else{ std::cin.clear(); std::cin.ignore(32767, '\n'); std::cout << "Invalid choice, try again!\n"; } } else{ std::cin.clear(); std::cin.ignore(32767, '\n'); std::cout << "Invalid choice, try again!\n"; } } }
28.42029
99
0.481387
TB989
2519cdd014be2f8ae012d413d418b32188482693
123
cpp
C++
bookcode/cproject/namespace/one.cpp
zhangymPerson/Think-in-java-note
b89ca3b90ad3d43d010e4764d06ee5ffff8e118d
[ "Apache-2.0" ]
null
null
null
bookcode/cproject/namespace/one.cpp
zhangymPerson/Think-in-java-note
b89ca3b90ad3d43d010e4764d06ee5ffff8e118d
[ "Apache-2.0" ]
3
2021-12-14T20:50:59.000Z
2021-12-18T18:26:01.000Z
bookcode/cproject/namespace/one.cpp
zhangymPerson/Think-in-java-note
b89ca3b90ad3d43d010e4764d06ee5ffff8e118d
[ "Apache-2.0" ]
null
null
null
#include "iostream" using namespace std; namespace one { void fun() { cout << "echo one func()\n"; } }
12.3
36
0.544715
zhangymPerson
251c715ca5539cd71d9f6f3f4f3adbaef47d7759
2,550
cc
C++
chromeos/dbus/shill/fake_modem_messaging_client.cc
zealoussnow/chromium
fd8a8914ca0183f0add65ae55f04e287543c7d4a
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
14,668
2015-01-01T01:57:10.000Z
2022-03-31T23:33:32.000Z
chromeos/dbus/shill/fake_modem_messaging_client.cc
zealoussnow/chromium
fd8a8914ca0183f0add65ae55f04e287543c7d4a
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
86
2015-10-21T13:02:42.000Z
2022-03-14T07:50:50.000Z
chromeos/dbus/shill/fake_modem_messaging_client.cc
zealoussnow/chromium
fd8a8914ca0183f0add65ae55f04e287543c7d4a
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
5,941
2015-01-02T11:32:21.000Z
2022-03-31T16:35:46.000Z
// Copyright 2013 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chromeos/dbus/shill/fake_modem_messaging_client.h" #include <algorithm> #include <string> #include <vector> #include "base/callback.h" #include "dbus/object_path.h" namespace chromeos { FakeModemMessagingClient::FakeModemMessagingClient() = default; FakeModemMessagingClient::~FakeModemMessagingClient() = default; void FakeModemMessagingClient::SetSmsReceivedHandler( const std::string& service_name, const dbus::ObjectPath& object_path, const SmsReceivedHandler& handler) { sms_received_handlers_.insert( std::pair<dbus::ObjectPath, SmsReceivedHandler>(object_path, handler)); message_paths_map_.insert( std::pair<dbus::ObjectPath, std::vector<dbus::ObjectPath>>(object_path, {})); } void FakeModemMessagingClient::ResetSmsReceivedHandler( const std::string& service_name, const dbus::ObjectPath& object_path) { sms_received_handlers_[object_path].Reset(); } void FakeModemMessagingClient::Delete(const std::string& service_name, const dbus::ObjectPath& object_path, const dbus::ObjectPath& sms_path, VoidDBusMethodCallback callback) { std::vector<dbus::ObjectPath> message_paths = message_paths_map_[object_path]; auto iter = find(message_paths.begin(), message_paths.end(), sms_path); if (iter != message_paths.end()) message_paths.erase(iter); std::move(callback).Run(true); } void FakeModemMessagingClient::List(const std::string& service_name, const dbus::ObjectPath& object_path, ListCallback callback) { std::move(callback).Run(message_paths_map_[object_path]); } ModemMessagingClient::TestInterface* FakeModemMessagingClient::GetTestInterface() { return this; } // ModemMessagingClient::TestInterface overrides. void FakeModemMessagingClient::ReceiveSms(const dbus::ObjectPath& object_path, const dbus::ObjectPath& sms_path) { if (message_paths_map_.find(object_path) == message_paths_map_.end()) { NOTREACHED() << "object_path not found!"; return; } message_paths_map_[object_path].push_back(sms_path); sms_received_handlers_[object_path].Run(sms_path, true); } } // namespace chromeos
35.416667
80
0.683137
zealoussnow
251e742f8655e82fa15cf61f177b17e665922ff0
4,157
cpp
C++
src/types/Criteria.cpp
Mostah/parallel-pymcda
d5f5bb0de95dec90b88be9d00a3860e52eed4003
[ "MIT" ]
2
2020-12-12T22:48:57.000Z
2021-02-24T09:37:40.000Z
src/types/Criteria.cpp
Mostah/parallel-pymcda
d5f5bb0de95dec90b88be9d00a3860e52eed4003
[ "MIT" ]
5
2021-01-07T19:34:24.000Z
2021-03-17T13:52:22.000Z
src/types/Criteria.cpp
Mostah/parallel-pymcda
d5f5bb0de95dec90b88be9d00a3860e52eed4003
[ "MIT" ]
3
2020-12-12T22:49:56.000Z
2021-09-08T05:26:38.000Z
#include "../../include/types/Criteria.h" #include "../../include/types/Criterion.h" #include "../../include/utils.h" #include <algorithm> #include <iostream> #include <numeric> #include <string> #include <vector> Criteria::Criteria(std::vector<Criterion> &criterion_vect) { std::vector<std::string> crit_id_vect; for (Criterion crit : criterion_vect) { // ensure there is no criterion with duplicated name if (std::find(crit_id_vect.begin(), crit_id_vect.end(), crit.getId()) != crit_id_vect.end()) { throw std::invalid_argument("Each criterion must have different ids."); } crit_id_vect.push_back(crit.getId()); criterion_vect_.push_back(Criterion(crit)); } } Criteria::Criteria(int nb_of_criteria, std::string prefix) { for (int i = 0; i < nb_of_criteria; i++) { criterion_vect_.push_back(Criterion(prefix + std::to_string(i))); } } Criteria::Criteria(const Criteria &crits) { // deep copy for (int i = 0; i < crits.criterion_vect_.size(); i++) { criterion_vect_.push_back(Criterion(crits.criterion_vect_[i])); } } Criteria::~Criteria() {} std::ostream &operator<<(std::ostream &out, const Criteria &crits) { out << "Criteria("; for (Criterion crit : crits.criterion_vect_) { out << crit << ", "; } out << ")"; return out; } void Criteria::setCriterionVect(std::vector<Criterion> &criterion_vect) { criterion_vect_.clear(); // deep copy for (int i = 0; i < criterion_vect.size(); i++) { criterion_vect_.push_back(Criterion(criterion_vect[i])); } } std::vector<Criterion> Criteria::getCriterionVect() const { return criterion_vect_; }; float Criteria::getMinWeight() { if (criterion_vect_.size() == 0) { return 0; } float min = criterion_vect_[0].getWeight(); for (Criterion crit : criterion_vect_) { if (crit.getWeight() < min) { min = crit.getWeight(); } } return min; } float Criteria::getMaxWeight() { if (criterion_vect_.size() == 0) { return 0; } float max = criterion_vect_[0].getWeight(); for (Criterion crit : criterion_vect_) { if (crit.getWeight() > max) { max = crit.getWeight(); } } return max; } float Criteria::getSumWeight() { float sum = 0; for (Criterion crit : criterion_vect_) { sum += crit.getWeight(); } return sum; } std::vector<float> Criteria::getWeights() const { std::vector<float> weights; for (Criterion c : criterion_vect_) { weights.push_back(c.getWeight()); } return weights; } void Criteria::setWeights(std::vector<float> newWeigths) { if (newWeigths.size() != criterion_vect_.size()) { throw std::invalid_argument( "New weight vector must have same length as Criteria ie have the same " "value as the number of criteria"); } for (int i = 0; i < criterion_vect_.size(); i++) { criterion_vect_[i].setWeight(newWeigths[i]); } } void Criteria::normalizeWeights() { float sum = Criteria::getSumWeight(); std::vector<float> weights = Criteria::getWeights(); std::transform(weights.begin(), weights.end(), weights.begin(), [&sum](float &c) { return c / sum; }); for (int i = 0; i < weights.size(); i++) { criterion_vect_[i].setWeight(weights[i]); } } // TODO Generation is not completely uniform here, might need to find an other // method void Criteria::generateRandomCriteriaWeights(unsigned long int seed) { std::vector<float> weights; for (int i = 0; i < criterion_vect_.size(); i++) { weights.push_back(getRandomUniformFloat(seed)); } float totSum = std::accumulate(weights.begin(), weights.end(), 0.00f); std::transform(weights.begin(), weights.end(), weights.begin(), [totSum](float &c) { return c / totSum; }); Criteria::setWeights(weights); } Criterion Criteria::operator[](std::string name) const { for (Criterion c : criterion_vect_) { if (c.getId() == name) { return c; } } throw std::invalid_argument("Criterion not found in this Criteria vector"); } Criterion Criteria::operator[](int index) { return criterion_vect_[index]; } Criterion Criteria::operator[](int index) const { return criterion_vect_[index]; }
28.087838
79
0.660573
Mostah
2520af0b6c32847350b4e715a9d45c750e9af6c2
15,144
hpp
C++
libmesh/include/sirikata/mesh/Meshdata.hpp
pathorn/sirikata
5d366a822ef2fb57cd9f64cc4f6085c0a635fdfa
[ "BSD-3-Clause" ]
1
2016-05-09T03:34:51.000Z
2016-05-09T03:34:51.000Z
libmesh/include/sirikata/mesh/Meshdata.hpp
pathorn/sirikata
5d366a822ef2fb57cd9f64cc4f6085c0a635fdfa
[ "BSD-3-Clause" ]
null
null
null
libmesh/include/sirikata/mesh/Meshdata.hpp
pathorn/sirikata
5d366a822ef2fb57cd9f64cc4f6085c0a635fdfa
[ "BSD-3-Clause" ]
null
null
null
/* Sirikata * Meshdata.hpp * * Copyright (c) 2010, Daniel B. Miller * 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 Sirikata 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. */ #ifndef _SIRIKATA_MESH_MESHDATA_HPP_ #define _SIRIKATA_MESH_MESHDATA_HPP_ #include <sirikata/mesh/Platform.hpp> #include <sirikata/mesh/Visual.hpp> #include "LightInfo.hpp" #include <stack> namespace Sirikata { namespace Mesh { // Typedefs for NodeIndices, which refer to scene graph nodes in the model typedef int32 NodeIndex; extern SIRIKATA_MESH_EXPORT NodeIndex NullNodeIndex; typedef std::vector<NodeIndex> NodeIndexList; typedef std::vector<LightInfo> LightInfoList; typedef std::vector<std::string> TextureList; struct Meshdata; typedef std::tr1::shared_ptr<Meshdata> MeshdataPtr; typedef std::tr1::weak_ptr<Meshdata> MeshdataWPtr; /** Represents a skinned animation. A skinned animation is directly associated * with a SubMeshGeometry. */ struct SIRIKATA_MESH_EXPORT SkinController { // Joints for this controls Indexes into the Meshdata.joints array // (which indexes into Meshdata.nodes). std::vector<uint32> joints; Matrix4x4f bindShapeMatrix; ///n+1 elements where n is the number of vertices, so that we can do simple ///subtraction to find out how many joints influence each vertex std::vector<unsigned int> weightStartIndices; // weights and jointIndices are the same size and are a sparse // representation of the (vertex,bone) = weight matrix: the // weightStartIndices let you figure out the range in these arrays that // correspond to a single vertex. In that range, each pair represents the // weight for one joint for the current vertex, with the rest of the joints // having weight 0. std::vector<float> weights; std::vector<unsigned int>jointIndices; // One inverse bind matrix per joint. std::vector<Matrix4x4f> inverseBindMatrices; }; typedef std::vector<SkinController> SkinControllerList; struct SIRIKATA_MESH_EXPORT SubMeshGeometry { std::string name; std::vector<Sirikata::Vector3f> positions; std::vector<Sirikata::Vector3f> normals; std::vector<Sirikata::Vector3f> tangents; std::vector<Sirikata::Vector4f> colors; struct TextureSet { unsigned int stride; std::vector<float> uvs; }; std::vector<TextureSet>texUVs; struct Primitive { std::vector<unsigned short> indices; enum PrimitiveType { TRIANGLES, LINES, POINTS, LINESTRIPS, TRISTRIPS, TRIFANS }primitiveType; typedef size_t MaterialId; MaterialId materialId; }; std::vector<Primitive> primitives; BoundingBox3f3f aabb; double radius; void recomputeBounds(); SkinControllerList skinControllers; /** Append the given SubMeshGeometry to the end of this one. Use the given * transformation to transform the geometry before adding it. This is a * useful primitive when trying to merge/simplify geometry. */ void append(const SubMeshGeometry& rhs, const Matrix4x4f& xform); }; typedef std::vector<SubMeshGeometry> SubMeshGeometryList; struct SIRIKATA_MESH_EXPORT GeometryInstance { typedef std::map<SubMeshGeometry::Primitive::MaterialId,size_t> MaterialBindingMap; MaterialBindingMap materialBindingMap;//maps materialIndex to offset in Meshdata's materials unsigned int geometryIndex; // Index in SubMeshGeometryList NodeIndex parentNode; // Index of node holding this instance /** Compute the bounds of this instance with the given transform. This is * more precise, and much more expensive, than transforming the * SubMeshGeometry's bounds. */ BoundingBox3f3f computeTransformedBounds(MeshdataPtr parent, const Matrix4x4f& xform) const; BoundingBox3f3f computeTransformedBounds(const Meshdata& parent, const Matrix4x4f& xform) const; void computeTransformedBounds(MeshdataPtr parent, const Matrix4x4f& xform, BoundingBox3f3f* bounds_out, double* radius_out) const; void computeTransformedBounds(const Meshdata& parent, const Matrix4x4f& xform, BoundingBox3f3f* bounds_out, double* radius_out) const; }; typedef std::vector<GeometryInstance> GeometryInstanceList; struct SIRIKATA_MESH_EXPORT LightInstance { int lightIndex; // Index in LightInfoList NodeIndex parentNode; // Index of node holding this instance }; typedef std::vector<LightInstance> LightInstanceList; struct SIRIKATA_MESH_EXPORT MaterialEffectInfo { struct Texture { std::string uri; Vector4f color;//color while the texture is pulled in, or if the texture is 404'd size_t texCoord; enum Affecting { DIFFUSE, SPECULAR, EMISSION, AMBIENT, REFLECTIVE, OPACITY, }affecting; enum SamplerType { SAMPLER_TYPE_UNSPECIFIED, SAMPLER_TYPE_1D, SAMPLER_TYPE_2D, SAMPLER_TYPE_3D, SAMPLER_TYPE_CUBE, SAMPLER_TYPE_RECT, SAMPLER_TYPE_DEPTH, SAMPLER_TYPE_STATE } samplerType; enum SamplerFilter { SAMPLER_FILTER_UNSPECIFIED, SAMPLER_FILTER_NONE, SAMPLER_FILTER_NEAREST, SAMPLER_FILTER_LINEAR, SAMPLER_FILTER_NEAREST_MIPMAP_NEAREST, SAMPLER_FILTER_LINEAR_MIPMAP_NEAREST, SAMPLER_FILTER_NEAREST_MIPMAP_LINEAR, SAMPLER_FILTER_LINEAR_MIPMAP_LINEAR }; SamplerFilter minFilter; SamplerFilter magFilter; enum WrapMode { WRAP_MODE_UNSPECIFIED=0, // NONE == GL_CLAMP_TO BORDER The defined behavior for NONE is // consistent with decal texturing where the border is black. // Mapping this calculation to GL_CLAMP_TO_BORDER is the best // approximation of this. WRAP_MODE_NONE, // WRAP == GL_REPEAT Ignores the integer part of texture coordinates, // using only the fractional part. WRAP_MODE_WRAP, // MIRROR == GL_MIRRORED_REPEAT First mirrors the texture coordinate. // The mirrored coordinate is then clamped as described for CLAMP_TO_EDGE. WRAP_MODE_MIRROR, // CLAMP == GL_CLAMP_TO_EDGE Clamps texture coordinates at all // mipmap levels such that the texture filter never samples a // border texel. Note: GL_CLAMP takes any texels beyond the // sampling border and substitutes those texels with the border // color. So CLAMP_TO_EDGE is more appropriate. This also works // much better with OpenGL ES where the GL_CLAMP symbol was removed // from the OpenGL ES specification. WRAP_MODE_CLAMP, // BORDER GL_CLAMP_TO_BORDER Clamps texture coordinates at all // MIPmaps such that the texture filter always samples border // texels for fragments whose corresponding texture coordinate // is sufficiently far outside the range [0, 1]. WRAP_MODE_BORDER }; WrapMode wrapS,wrapT,wrapU; unsigned int maxMipLevel; float mipBias; bool operator==(const Texture& rhs) const; bool operator!=(const Texture& rhs) const; }; typedef std::vector<Texture> TextureList; TextureList textures; float shininess; float reflectivity; bool operator==(const MaterialEffectInfo& rhs) const; bool operator!=(const MaterialEffectInfo& rhs) const; }; typedef std::vector<MaterialEffectInfo> MaterialEffectInfoList; struct SIRIKATA_MESH_EXPORT InstanceSkinAnimation { }; /** Represents a series of key frames */ struct SIRIKATA_MESH_EXPORT TransformationKeyFrames { typedef std::vector<float> TimeList; TimeList inputs; typedef std::vector<Matrix4x4f> TransformationList; TransformationList outputs; }; // A scene graph node. Contains a transformation, set of children nodes, // camera instances, geometry instances, skin controller instances, light // instances, and instances of other nodes. struct SIRIKATA_MESH_EXPORT Node { Node(); Node(NodeIndex par, const Matrix4x4f& xform); Node(const Matrix4x4f& xform); bool containsInstanceController; // Parent node in the actual hierarchy (not instantiated). NodeIndex parent; // Transformation to apply when traversing this node. Matrix4x4f transform; // Direct children, i.e. they are contained by this node directly and their // parent NodeIndex will reflect that. NodeIndexList children; // Instantiations of other nodes (and their children) into this // subtree. Because they are instantiations, their // instanceChildren[i]->parent != this node's index. NodeIndexList instanceChildren; // Map of name -> animation curve. typedef std::map<String, TransformationKeyFrames> AnimationMap; AnimationMap animations; }; typedef std::vector<Node> NodeList; struct SIRIKATA_MESH_EXPORT Meshdata : public Visual { private: static String sType; public: virtual ~Meshdata(); virtual const String& type() const; SubMeshGeometryList geometry; TextureList textures; LightInfoList lights; MaterialEffectInfoList materials; long id; bool hasAnimations; GeometryInstanceList instances; LightInstanceList lightInstances; // The global transform should be applied to all nodes and instances Matrix4x4f globalTransform; // We track two sets of nodes: roots and the full list. (Obviously the roots // are a subset of the full list). The node list is just the full set, // usually only used to look up children/parents. The roots list is just a // set of indices into the full list. NodeList nodes; NodeIndexList rootNodes; //Stores a list of transforms on the path from the scene root //to the instance controller for the skeleton. std::vector<Matrix4x4f> mInstanceControllerTransformList; // Joints are tracked as indices of the nodes they are associated with. NodeIndexList joints; // Be careful using these methods. Since there are no "parent" links for // instance nodes (and even if there were, there could be more than one), // these methods cannot correctly compute the transform when instance_nodes // are involved. Matrix4x4f getTransform(NodeIndex index) const; private: // A stack of NodeState is used to track the current traversal state for // instance iterators struct SIRIKATA_MESH_EXPORT NodeState { enum Step { Init, Nodes, InstanceNodes, InstanceGeometries, InstanceLights, Done }; NodeIndex index; Matrix4x4f transform; Step step; int32 currentChild; }; struct SIRIKATA_MESH_EXPORT JointNodeState : public NodeState { uint32 joint_id; std::vector<Matrix4x4f> transformList; }; public: // Allows you to generate a list of GeometryInstances with their transformations. class SIRIKATA_MESH_EXPORT GeometryInstanceIterator { public: GeometryInstanceIterator(const Meshdata* const mesh); // Get the next GeometryInstance and its transform. Returns true if // values were set, false if there were no more instances. The index // returned is of the geometry instance. bool next(uint32* geoinst_idx, Matrix4x4f* xform); private: const Meshdata* mMesh; int32 mRoot; std::stack<NodeState> mStack; }; GeometryInstanceIterator getGeometryInstanceIterator() const; /** Get count of instanced geometry. This can differ from instances.size() * because many nodes may refer to the same InstanceGeometry. */ uint32 getInstancedGeometryCount() const; // Allows you to generate a list of joints with their transformations. class SIRIKATA_MESH_EXPORT JointIterator { public: JointIterator(const Meshdata* const mesh); // Get the next Joint's unique ID, its index in the list of joints, its // transform, and parent joint ID. Also gets the list of transforms from the root node // to the instance controller of the skeleton referencing the joint. Returns true if // values were set, false if there were no more joints. Joint IDs are // non-zero, so you can check for, e.g., no parent with parent_id == 0 // or if (parent_id). The joint_idx is an index into Meshdata::joints. bool next(uint32* joint_id, uint32* joint_idx, Matrix4x4f* xform, uint32* parent_id, std::vector<Matrix4x4f>& transformList); private: const Meshdata* mMesh; int32 mRoot; std::stack<JointNodeState> mStack; uint32 mNextID; }; JointIterator getJointIterator() const; /** Get count of joints geometry. This can differ from joints.size() * because nodes acting as joints may be instantiated multiple times. */ uint32 getJointCount() const; // Allows you to generate a list of GeometryInstances with their transformations. class SIRIKATA_MESH_EXPORT LightInstanceIterator { public: LightInstanceIterator(const Meshdata* const mesh); // Get the next LightInstance and its transform. Returns true if // values were set, false if there were no more instances. The index // returned is of the light instance. bool next(uint32* lightinst_idx, Matrix4x4f* xform); private: const Meshdata* mMesh; int32 mRoot; std::stack<NodeState> mStack; }; LightInstanceIterator getLightInstanceIterator() const; /** Get count of instanced lights. This can differ from * lightInstances.size() because many nodes may refer to the same * InstanceLight. */ uint32 getInstancedLightCount() const; }; } // namespace Mesh } // namespace Sirikata #endif //_SIRIKATA_MESH_MESHDATA_HPP_
36.757282
138
0.719427
pathorn
2530cd464b924151a2e29ae753940bfa5eaa65a9
1,040
cpp
C++
hashing/timer/clock.cpp
ShuhaoZhangTony/WalnutDB
9ccc10b23351aa2e6793e0f5c7bd3dd511d7b050
[ "MIT" ]
null
null
null
hashing/timer/clock.cpp
ShuhaoZhangTony/WalnutDB
9ccc10b23351aa2e6793e0f5c7bd3dd511d7b050
[ "MIT" ]
null
null
null
hashing/timer/clock.cpp
ShuhaoZhangTony/WalnutDB
9ccc10b23351aa2e6793e0f5c7bd3dd511d7b050
[ "MIT" ]
null
null
null
// // Created by Shuhao Zhang on 3/3/20. //https://stackoverflow.com/questions/275004/timer-function-to-provide-time-in-nano-seconds-using-c/11485388#11485388 #include "clock.h" #include <iostream> #include <thread> int x::test_clock() { // Define real time units typedef std::chrono::duration<unsigned long long, std::pico> picoseconds; // or: // typedef std::chrono::nanoseconds nanoseconds; // Define double-based unit of clock tick typedef std::chrono::duration<double, typename x::clock::period> Cycle; using std::chrono::duration_cast; const int N = 100000000; // Do it auto t0 = x::clock::now(); for (int j = 0; j < N; ++j) asm volatile(""); auto t1 = x::clock::now(); // Get the clock ticks per iteration auto ticks_per_iter = Cycle(t1-t0)/N; std::cout << ticks_per_iter.count() << " clock ticks per iteration\n"; // Convert to real time units std::cout << duration_cast<picoseconds>(ticks_per_iter).count() << "ps per iteration\n"; }
33.548387
117
0.649038
ShuhaoZhangTony
2532703c98e156e338f8abd5c4d6dcc28a4dc5d0
8,616
cpp
C++
PrgApps4/17-MMFSparse/MMFSparse.cpp
JimYang365/samples
920c2d98b1ef0dc3d3b861b9b73ab6a3d0e5ced0
[ "MIT" ]
null
null
null
PrgApps4/17-MMFSparse/MMFSparse.cpp
JimYang365/samples
920c2d98b1ef0dc3d3b861b9b73ab6a3d0e5ced0
[ "MIT" ]
null
null
null
PrgApps4/17-MMFSparse/MMFSparse.cpp
JimYang365/samples
920c2d98b1ef0dc3d3b861b9b73ab6a3d0e5ced0
[ "MIT" ]
null
null
null
/****************************************************************************** Module: MMFSparse.cpp Notices: Copyright (c) 2000 Jeffrey Richter ******************************************************************************/ #include "..\CmnHdr.h" /* See Appendix A. */ #include <tchar.h> #include <WindowsX.h> #include <WinIoCtl.h> #include "SparseStream.h" #include "Resource.h" ////////////////////////////////////////////////////////////////////////////// // This class makes it easy to work with memory-mapped sparse files class CMMFSparse : public CSparseStream { private: HANDLE m_hfilemap; // File-mapping object PVOID m_pvFile; // Address to start of mapped file public: // Creates a Sparse MMF and maps it in the process's address space. CMMFSparse(HANDLE hstream = NULL, SIZE_T dwStreamSizeMax = 0); // Closes a Sparse MMF virtual ~CMMFSparse() { ForceClose(); } // Creates a sparse MMF and maps it in the process's address space. BOOL Initialize(HANDLE hstream, SIZE_T dwStreamSizeMax); // MMF to BYTE cast operator returns address of first byte // in the memory-mapped sparse file. operator PBYTE() const { return((PBYTE) m_pvFile); } // Allows you to explicitly close the MMF without having // to wait for the destructor to be called. VOID ForceClose(); }; ////////////////////////////////////////////////////////////////////////////// CMMFSparse::CMMFSparse(HANDLE hstream, SIZE_T dwStreamSizeMax) { Initialize(hstream, dwStreamSizeMax); } ////////////////////////////////////////////////////////////////////////////// BOOL CMMFSparse::Initialize(HANDLE hstream, SIZE_T dwStreamSizeMax) { if (m_hfilemap != NULL) ForceClose(); // Initialize to NULL in case something goes wrong m_hfilemap = m_pvFile = NULL; BOOL fOk = TRUE; // Assume success if (hstream != NULL) { if (dwStreamSizeMax == 0) { DebugBreak(); // Illegal stream size } CSparseStream::Initialize(hstream); fOk = MakeSparse(); // Make the stream sparse if (fOk) { // Create a file-mapping object m_hfilemap = ::CreateFileMapping(hstream, NULL, PAGE_READWRITE, (DWORD) (dwStreamSizeMax >> 32I64), (DWORD) dwStreamSizeMax, NULL); if (m_hfilemap != NULL) { // Map the stream into the process's address space m_pvFile = ::MapViewOfFile(m_hfilemap, FILE_MAP_WRITE | FILE_MAP_READ, 0, 0, 0); } else { // Failed to map the file, cleanup CSparseStream::Initialize(NULL); ForceClose(); fOk = FALSE; } } } return(fOk); } ////////////////////////////////////////////////////////////////////////////// VOID CMMFSparse::ForceClose() { // Cleanup everything that was done sucessfully if (m_pvFile != NULL) { ::UnmapViewOfFile(m_pvFile); m_pvFile = NULL; } if (m_hfilemap != NULL) { ::CloseHandle(m_hfilemap); m_hfilemap = NULL; } } ////////////////////////////////////////////////////////////////////////////// #define STREAMSIZE (1 * 1024 * 1024) // 1 MB (1024 KB) TCHAR szPathname[] = TEXT("C:\\MMFSparse."); HANDLE g_hstream = INVALID_HANDLE_VALUE; CMMFSparse g_mmf; /////////////////////////////////////////////////////////////////////////////// BOOL Dlg_OnInitDialog(HWND hwnd, HWND hwndFocus, LPARAM lParam) { chSETDLGICONS(hwnd, IDI_MMFSPARSE); // Initialize the dialog box controls. EnableWindow(GetDlgItem(hwnd, IDC_OFFSET), FALSE); Edit_LimitText(GetDlgItem(hwnd, IDC_OFFSET), 4); SetDlgItemInt(hwnd, IDC_OFFSET, 1000, FALSE); EnableWindow(GetDlgItem(hwnd, IDC_BYTE), FALSE); Edit_LimitText(GetDlgItem(hwnd, IDC_BYTE), 3); SetDlgItemInt(hwnd, IDC_BYTE, 5, FALSE); EnableWindow(GetDlgItem(hwnd, IDC_WRITEBYTE), FALSE); EnableWindow(GetDlgItem(hwnd, IDC_READBYTE), FALSE); EnableWindow(GetDlgItem(hwnd, IDC_FREEALLOCATEDREGIONS), FALSE); return(TRUE); } /////////////////////////////////////////////////////////////////////////////// void Dlg_ShowAllocatedRanges(HWND hwnd) { // Fill in the Allocated Ranges edit control DWORD dwNumEntries; FILE_ALLOCATED_RANGE_BUFFER* pfarb = g_mmf.QueryAllocatedRanges(&dwNumEntries); if (dwNumEntries == 0) { SetDlgItemText(hwnd, IDC_FILESTATUS, TEXT("No allocated ranges in the file")); } else { TCHAR sz[4096] = { 0 }; for (DWORD dwEntry = 0; dwEntry < dwNumEntries; dwEntry++) { wsprintf(_tcschr(sz, 0), TEXT("Offset: %7.7u, Length: %7.7u\r\n"), pfarb[dwEntry].FileOffset.LowPart, pfarb[dwEntry].Length.LowPart); } SetDlgItemText(hwnd, IDC_FILESTATUS, sz); } g_mmf.FreeAllocatedRanges(pfarb); } /////////////////////////////////////////////////////////////////////////////// void Dlg_OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify) { switch (id) { case IDCANCEL: if (g_hstream != INVALID_HANDLE_VALUE) CloseHandle(g_hstream); EndDialog(hwnd, id); break; case IDC_CREATEMMF: // Create the file g_hstream = CreateFile(szPathname, GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (g_hstream == INVALID_HANDLE_VALUE) { chFAIL("Failed to create file."); } // Create a 1MB (1024 KB) MMF using the file if (!g_mmf.Initialize(g_hstream, STREAMSIZE)) { chFAIL("Failed to initialize Sparse MMF."); } Dlg_ShowAllocatedRanges(hwnd); // Enable/disable the other controls. EnableWindow(GetDlgItem(hwnd, IDC_CREATEMMF), FALSE); EnableWindow(GetDlgItem(hwnd, IDC_OFFSET), TRUE); EnableWindow(GetDlgItem(hwnd, IDC_BYTE), TRUE); EnableWindow(GetDlgItem(hwnd, IDC_WRITEBYTE), TRUE); EnableWindow(GetDlgItem(hwnd, IDC_READBYTE), TRUE); EnableWindow(GetDlgItem(hwnd, IDC_FREEALLOCATEDREGIONS), TRUE); // Force the Offset edit control to have the focus. SetFocus(GetDlgItem(hwnd, IDC_OFFSET)); break; case IDC_WRITEBYTE: { BOOL fTranslated; DWORD dwOffset = GetDlgItemInt(hwnd, IDC_OFFSET, &fTranslated, FALSE); if (fTranslated) { g_mmf[dwOffset * 1024] = (BYTE) GetDlgItemInt(hwnd, IDC_BYTE, NULL, FALSE); Dlg_ShowAllocatedRanges(hwnd); } } break; case IDC_READBYTE: { BOOL fTranslated; DWORD dwOffset = GetDlgItemInt(hwnd, IDC_OFFSET, &fTranslated, FALSE); if (fTranslated) { SetDlgItemInt(hwnd, IDC_BYTE, g_mmf[dwOffset * 1024], FALSE); Dlg_ShowAllocatedRanges(hwnd); } } break; case IDC_FREEALLOCATEDREGIONS: // Normally the destructor causes the file-mapping to close. // But, in this case, we wish to force it so that we can reset // a portion of the file back to all zeroes. g_mmf.ForceClose(); // We call ForceClose above because attempting to zero a portion of // the file while it is mapped, causes DeviceIoControl to fail with // error ERROR_USER_MAPPED_FILE ("The requested operation cannot // be performed on a file with a user-mapped section open.") g_mmf.DecommitPortionOfStream(0, STREAMSIZE); g_mmf.Initialize(g_hstream, STREAMSIZE); Dlg_ShowAllocatedRanges(hwnd); break; } } /////////////////////////////////////////////////////////////////////////////// INT_PTR WINAPI Dlg_Proc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { chHANDLE_DLGMSG(hwnd, WM_INITDIALOG, Dlg_OnInitDialog); chHANDLE_DLGMSG(hwnd, WM_COMMAND, Dlg_OnCommand); } return(FALSE); } /////////////////////////////////////////////////////////////////////////////// int WINAPI _tWinMain(HINSTANCE hinstExe, HINSTANCE, PTSTR pszCmdLine, int) { chWindows2000Required(); DialogBox(hinstExe, MAKEINTRESOURCE(IDD_MMFSPARSE), NULL, Dlg_Proc); return(0); } //////////////////////////////// End of File //////////////////////////////////
31.445255
80
0.543988
JimYang365
253595dff9926cc3c167493f95b92c4e424811a0
1,565
cpp
C++
treefunctions.cpp
waha99922/JuicyBros_TOOLBOX_V1.0
ff59f3842e9a4bf1b40e18613f555b923cd9b949
[ "MIT" ]
null
null
null
treefunctions.cpp
waha99922/JuicyBros_TOOLBOX_V1.0
ff59f3842e9a4bf1b40e18613f555b923cd9b949
[ "MIT" ]
null
null
null
treefunctions.cpp
waha99922/JuicyBros_TOOLBOX_V1.0
ff59f3842e9a4bf1b40e18613f555b923cd9b949
[ "MIT" ]
null
null
null
#include <iostream> #include "Tree.h" using namespace std; Tree::Tree() { root = NULL; } void Tree::insert(double value) { Tnode* ptr = new Tnode(value); Tnode* temp = root; if (root == NULL) { root = ptr; } else { while (temp != NULL) { if (temp->data > value && temp->left == NULL) { temp->left = ptr; break; } else if (temp->data < value && temp->right == NULL) { temp->right = ptr; break; } else if (temp->data > value && temp->left != NULL) { temp = temp->left; } else if (temp->data < value && temp->right != NULL) { temp = temp->right; } } } } Tnode* Tree::Inorder_print(Tnode* temp) { if (temp == NULL) { return NULL; } else { Inorder_print(temp->left); cout << temp->data <<endl; Inorder_print(temp->right); } } Tnode* Tree::Postorder_print(Tnode* temp) { if (temp == NULL) { return NULL; } else { Postorder_print(temp->left); Postorder_print(temp->right); cout << temp->data <<endl; } } Tnode* Tree::Preorder_print(Tnode* temp) { if (temp == NULL) { return NULL; } else { cout << temp->data <<endl; Preorder_print(temp->left); Postorder_print(temp->right); } } Tnode* Tree::search(Tnode* temp,double key) { if (temp == NULL) { return NULL; } else if (temp->data == key) { return temp; } else if (key < temp->data) { search(temp->left, key); } else if (key>temp->data) { search(temp->right, key); } }
14.490741
55
0.532907
waha99922
2536ba074888894f3711036500cd7a040eb22d84
4,865
cpp
C++
main.cpp
gnole/CG-HW3
9c0859bda43291d49a47b929352d6ba5da2bdae9
[ "MIT" ]
null
null
null
main.cpp
gnole/CG-HW3
9c0859bda43291d49a47b929352d6ba5da2bdae9
[ "MIT" ]
null
null
null
main.cpp
gnole/CG-HW3
9c0859bda43291d49a47b929352d6ba5da2bdae9
[ "MIT" ]
null
null
null
#include <SFML/Graphics.hpp> #include <unistd.h> #include <cmath> #include <iostream> void drawLineRed(int x1, int y1, int x2, int y2, sf::RenderWindow &window) { const int deltaX = abs(x2 - x1); const int deltaY = abs(y2 - y1); const int signX = x1 < x2 ? 1 : -1; const int signY = y1 < y2 ? 1 : -1; int error = deltaX - deltaY; sf::Vertex point(sf::Vector2f(x2, y2), sf::Color::Red); window.draw(&point, 1, sf::Points); while (x1 != x2 || y1 != y2) { sf::Vertex point1(sf::Vector2f(x1, y1), sf::Color::Red); window.draw(&point1, 1, sf::Points); int error2 = error * 2; if (error2 > -deltaY) { error -= deltaY; x1 += signX; } if (error2 < deltaX) { error += deltaX; y1 += signY; } } } int dot(std::pair<int, int> p0, std::pair<int, int> p1) { return p0.first * p1.first + p0.second * p1.second; } float max(std::vector<float> t) { float maximum = -1000000; for (int i = 0; i < t.size(); i++) if (t[i] > maximum) maximum = t[i]; return maximum; } float min(std::vector<float> t) { float minimum = 1000000; for (int i = 0; i < t.size(); i++) if (t[i] < minimum) minimum = t[i]; return minimum; } void cyrusBeck(std::vector<std::pair<int, int>> vertices, std::vector<std::pair<int, int>> line, std::vector<std::pair<int, int>> &vec_line_cb) { const int n = vertices.size(); std::pair<int, int> *newPair = new std::pair<int, int>[2]; std::pair<int, int> *normal = new std::pair<int, int>[n]; for (int i = 0; i < n; i++) { normal[i].second = vertices[(i + 1) % n].first - vertices[i].first; normal[i].first = vertices[i].second - vertices[(i + 1) % n].second; } std::pair<int, int> P1_P0 = std::make_pair(line[1].first - line[0].first, line[1].second - line[0].second); std::pair<int, int> *P0_PEi = new std::pair<int, int>[n]; for (int i = 0; i < n; i++) { P0_PEi[i].first = vertices[i].first - line[0].first; P0_PEi[i].second = vertices[i].second - line[0].second; } int *numerator = new int[n], *denominator = new int[n]; for (int i = 0; i < n; i++) { numerator[i] = dot(normal[i], P0_PEi[i]); denominator[i] = dot(normal[i], P1_P0); } float *t = new float[n]; std::vector<float> tE, tL; for (int i = 0; i < n; i++) { t[i] = (float)(numerator[i]) / (float)(denominator[i]); if (denominator[i] > 0) tE.push_back(t[i]); else tL.push_back(t[i]); } float temp[2]; tE.push_back(0.f); temp[0] = max(tE); tL.push_back(1.f); temp[1] = min(tL); if (temp[0] > temp[1]) { newPair[0] = std::make_pair(-1, -1); newPair[1] = std::make_pair(-1, -1); vec_line_cb.push_back(std::make_pair(newPair[0].first, newPair[0].second)); vec_line_cb.push_back(std::make_pair(newPair[1].first, newPair[1].second)); } else { newPair[0].first = (float)line[0].first + (float)P1_P0.first * (float)temp[0]; newPair[0].second = (float)line[0].second + (float)P1_P0.second * (float)temp[0]; newPair[1].first = (float)line[0].first + (float)P1_P0.first * (float)temp[1]; newPair[1].second = (float)line[0].second + (float)P1_P0.second * (float)temp[1]; } vec_line_cb.push_back(std::make_pair(newPair[0].first, newPair[0].second)); vec_line_cb.push_back(std::make_pair(newPair[1].first, newPair[1].second)); } int main() { sf::RenderWindow window(sf::VideoMode(740, 680), "HW3"); window.setFramerateLimit(50); std::vector<std::pair<int, int>> vec_points; std::vector<std::pair<int, int>> vec_line; std::vector<std::pair<int, int>> vec_line_cb; bool dr = false; while (window.isOpen()) { sf::Event event; while (window.pollEvent(event)) { switch (event.type) { case sf::Event::Closed: { window.close(); return 0; } case sf::Event::MouseButtonPressed: { if (sf::Mouse::isButtonPressed(sf::Mouse::Left)) { if (dr) { vec_line.insert(vec_line.begin(), 1, std::make_pair(event.mouseButton.x, event.mouseButton.y)); } else { vec_points.push_back(std::make_pair(event.mouseButton.x, event.mouseButton.y)); } } if (sf::Mouse::isButtonPressed(sf::Mouse::Right)) { dr = true; auto itend = vec_points.begin(); vec_points.push_back(std::make_pair(itend->first, itend->second)); } } } } window.clear(sf::Color::White); if (vec_points.size() >= 2) { auto it0 = vec_points.begin(); auto it1 = vec_points.begin(); ++it1; for (; it1 != vec_points.end(); ++it0, ++it1) { drawLineRed(it0->first, it0->second, it1->first, it1->second, window); } } if (vec_line.size() >= 2) { if (vec_line.size() % 2 == 0) { cyrusBeck(vec_points, vec_line, vec_line_cb); } auto it0 = vec_line_cb.begin(); auto it1 = vec_line_cb.begin(); ++it1; for (int i = 0; it1 != vec_line_cb.end(); ++it1, ++it0, ++i) { if (i % 2 == 0) { drawLineRed(it0->first, it0->second, it1->first, it1->second, window); } } } window.display(); } return 0; }
29.131737
101
0.610277
gnole
2536d4a70dc875741c6131f4b37f41f5ebd314dd
780
cpp
C++
Team01/Game/Project/SceneGame.cpp
OiCGame/GameJam03
535fff1e39a3c509c4104029bd40386c5d8b4a69
[ "MIT" ]
null
null
null
Team01/Game/Project/SceneGame.cpp
OiCGame/GameJam03
535fff1e39a3c509c4104029bd40386c5d8b4a69
[ "MIT" ]
null
null
null
Team01/Game/Project/SceneGame.cpp
OiCGame/GameJam03
535fff1e39a3c509c4104029bd40386c5d8b4a69
[ "MIT" ]
1
2021-02-01T02:48:17.000Z
2021-02-01T02:48:17.000Z
#include "SceneGame.h" CSceneGame::CSceneGame() { } CSceneGame::~CSceneGame() { } bool CSceneGame::Load() { return false; } void CSceneGame::Initialize() { m_Game.Initialize(); } void CSceneGame::Update() { FadeInOut(); if (m_bEndStart) { return; } m_Game.Update(); // if (g_pInput->IsKeyPush(MOFKEY_F2)) { if (m_Game.GetPhaseNo() == 2) { m_Alpha = 255; } // if (m_Game.IsAllPhaseEnd()) { if (m_Game.BossDead()) { m_bEndStart = true; m_NextSceneNo = SCENENO_GAMECLEAR; } // if (g_pInput->IsKeyPush(MOFKEY_F3)) { if (m_Game.IsPlayerDead()) { m_bEndStart = true; m_NextSceneNo = SCENENO_GAMEOVER; } } void CSceneGame::Render() { m_Game.Render(); RenderFade(); } void CSceneGame::RenderDebug() { } void CSceneGame::Release() { m_Game.Release(); }
15.6
41
0.664103
OiCGame
2538fdd3e154e6fe6f933447ee849fa4d272cdfc
18
cpp
C++
src/root/root.cpp
keithalewis/libfms
8389d2d022af2a23764653f13addf989d6d9e7fe
[ "MIT" ]
null
null
null
src/root/root.cpp
keithalewis/libfms
8389d2d022af2a23764653f13addf989d6d9e7fe
[ "MIT" ]
null
null
null
src/root/root.cpp
keithalewis/libfms
8389d2d022af2a23764653f13addf989d6d9e7fe
[ "MIT" ]
null
null
null
#include "root.h"
9
17
0.666667
keithalewis
25399c4fdef84031784b3f8f3136b92e2f289d4a
1,448
hpp
C++
include/thermistor/util.hpp
matt1795/thermistor
8f7a858fb0fc13b47b16597ae889209726352e71
[ "Apache-2.0" ]
null
null
null
include/thermistor/util.hpp
matt1795/thermistor
8f7a858fb0fc13b47b16597ae889209726352e71
[ "Apache-2.0" ]
null
null
null
include/thermistor/util.hpp
matt1795/thermistor
8f7a858fb0fc13b47b16597ae889209726352e71
[ "Apache-2.0" ]
null
null
null
// Thermistor utility functions // // Author: Matthew Knight // File Name: util.hpp // Date: 2019-08-12 #pragma once #include <iterator> namespace Thermistor { // constexpr range checker. predicate is used to compare every element and // its predesesor template <typename Iterator, typename Predicate> constexpr bool all_of(Iterator first, Iterator last, Predicate p) { first++; for (;first != last; ++first) if (!p(*first, *std::prev(first))) return false; return true; } template <typename Iterator, typename Predicate> constexpr bool any_of(Iterator first, Iterator last, Predicate p) { first++; for (;first != last; ++first) if (p(*first, *std::prev(first))) return true; return false; } // checks if range is in ascending order template <typename Iterator> constexpr bool ascending(Iterator first, Iterator last) { return all_of(first, last, [](auto& current, auto& previous) { return current > previous; }); } // checks if range is in descending order template <typename Iterator> constexpr bool descending(Iterator first, Iterator last) { return all_of(first, last, [](auto& current, auto& previous) { return current < previous; }); } // checks to see if any values are equal template <typename Iterator> constexpr bool over_sampled(Iterator first, Iterator last) { return any_of(first, last, [](auto& current, auto& previous) { return current == previous; }); } }
24.965517
75
0.697514
matt1795
253a85ba64ff7c4ced3e3c7c26e811efead82d1f
1,306
hh
C++
elements/local/autodpaint.hh
MacWR/Click-changed-for-ParaGraph
18285e5da578fbb7285d10380836146e738dee6e
[ "Apache-2.0" ]
null
null
null
elements/local/autodpaint.hh
MacWR/Click-changed-for-ParaGraph
18285e5da578fbb7285d10380836146e738dee6e
[ "Apache-2.0" ]
null
null
null
elements/local/autodpaint.hh
MacWR/Click-changed-for-ParaGraph
18285e5da578fbb7285d10380836146e738dee6e
[ "Apache-2.0" ]
null
null
null
#ifndef CLICK_AUTODPAINT_HH #define CLICK_AUTODPAINT_HH #include <click/element.hh> CLICK_DECLS /* =c AutoDPaint(COLORANGE,OPERATIONCOLOR) =s autoDpaint sets packet two layers' autodpaint annotations =d The first layer Paint is to protect the consistency of the packet copys: Sets each packet's first Paint annotation (default is startanno=8 )to STARTCOLOR, an integer 0-2^16-1, default is startcolor=0; The second layer Paint is to mark the operation on the packert copys: Set each packert's second Paint annotation ( default is startanno+1 ) to COLOR, an integer 250..254, default is color=0(operation: read); The ANNO argument can specify any one-byte annotation. =h color read/write Get/set the color to autodpaint. =a Paint, PaintTee */ class AutoDPaint : public Element { public: AutoDPaint() CLICK_COLD; const char *class_name() const { return "AutoDPaint"; } const char *port_count() const { return PORTS_1_1; } int configure(Vector<String> &, ErrorHandler *) CLICK_COLD; bool can_live_reconfigure() const { return true; } void add_handlers() CLICK_COLD; Packet *simple_action(Packet *); private: uint16_t _startcolor; uint16_t _nowcolor; uint8_t _operationcolor; int _colorange; uint16_t _nowrange; }; CLICK_ENDDECLS #endif
24.185185
137
0.743492
MacWR
253ce622b9954c1ada6315da36f8d6ad38172cf0
388
cpp
C++
IOST14.cpp
aaryan0348/E-Lab-Object-Oriented-Programming
29f3ca80dbf2268441b5b9e426415650a607195a
[ "MIT" ]
null
null
null
IOST14.cpp
aaryan0348/E-Lab-Object-Oriented-Programming
29f3ca80dbf2268441b5b9e426415650a607195a
[ "MIT" ]
null
null
null
IOST14.cpp
aaryan0348/E-Lab-Object-Oriented-Programming
29f3ca80dbf2268441b5b9e426415650a607195a
[ "MIT" ]
null
null
null
#include <iostream> using namespace std; int main() { float n; float pi; cin>>n; int i=0; int n1=n; while(n>0) { pi=(float)22/7; cout.precision(n); cout<<pi; while(i) { cout<<'*'; i--; } i=n1-n+1; n--; cout<<endl; } cout<<"3"<<endl<<"Fill Setting:*"; return 0; } void d(){ cout.fill('a'); cout.width(10); }
12.125
37
0.466495
aaryan0348
2540014eae291b7d481e70e6939ec48afa99fdfb
200,731
inl
C++
2d_samples/pmj02_180.inl
st-ario/rayme
315c57c23f4aa4934a8a80e84e3243acd3400808
[ "MIT" ]
1
2021-12-10T23:35:04.000Z
2021-12-10T23:35:04.000Z
2d_samples/pmj02_180.inl
st-ario/rayme
315c57c23f4aa4934a8a80e84e3243acd3400808
[ "MIT" ]
null
null
null
2d_samples/pmj02_180.inl
st-ario/rayme
315c57c23f4aa4934a8a80e84e3243acd3400808
[ "MIT" ]
null
null
null
{std::array<float,2>{0.407800078f, 0.8442536f}, std::array<float,2>{0.587527096f, 0.23548229f}, std::array<float,2>{0.978728712f, 0.646827936f}, std::array<float,2>{0.130732656f, 0.300448418f}, std::array<float,2>{0.103660405f, 0.522768974f}, std::array<float,2>{0.782684922f, 0.481478781f}, std::array<float,2>{0.713951111f, 0.962670207f}, std::array<float,2>{0.30073148f, 0.00499550067f}, std::array<float,2>{0.340997994f, 0.709573328f}, std::array<float,2>{0.648365676f, 0.339554101f}, std::array<float,2>{0.820601285f, 0.807329476f}, std::array<float,2>{0.018924525f, 0.151460499f}, std::array<float,2>{0.247321576f, 0.877124131f}, std::array<float,2>{0.905929983f, 0.0813911036f}, std::array<float,2>{0.548345804f, 0.61819613f}, std::array<float,2>{0.456791341f, 0.432048112f}, std::array<float,2>{0.277148992f, 0.982685149f}, std::array<float,2>{0.743986547f, 0.0501060486f}, std::array<float,2>{0.757856607f, 0.535368085f}, std::array<float,2>{0.0630864277f, 0.44095251f}, std::array<float,2>{0.162640274f, 0.68412447f}, std::array<float,2>{0.967815936f, 0.25990811f}, std::array<float,2>{0.619917929f, 0.837838233f}, std::array<float,2>{0.393650919f, 0.188003272f}, std::array<float,2>{0.476973504f, 0.5719226f}, std::array<float,2>{0.531063199f, 0.381219268f}, std::array<float,2>{0.923539579f, 0.924037337f}, std::array<float,2>{0.191263899f, 0.0944396406f}, std::array<float,2>{0.0406171195f, 0.760097921f}, std::array<float,2>{0.868816078f, 0.172067776f}, std::array<float,2>{0.685444176f, 0.730339706f}, std::array<float,2>{0.372586936f, 0.344608366f}, std::array<float,2>{0.346662909f, 0.789863229f}, std::array<float,2>{0.669065595f, 0.134517998f}, std::array<float,2>{0.852965176f, 0.687735915f}, std::array<float,2>{0.0509867892f, 0.323053598f}, std::array<float,2>{0.215056375f, 0.595274866f}, std::array<float,2>{0.909260869f, 0.420297325f}, std::array<float,2>{0.506124198f, 0.902223229f}, std::array<float,2>{0.48880133f, 0.0654655099f}, std::array<float,2>{0.378038228f, 0.637833595f}, std::array<float,2>{0.608418703f, 0.283659577f}, std::array<float,2>{0.950592816f, 0.869384646f}, std::array<float,2>{0.179770336f, 0.222733393f}, std::array<float,2>{0.0919908658f, 0.949330807f}, std::array<float,2>{0.78020376f, 0.0236400198f}, std::array<float,2>{0.732879877f, 0.504261851f}, std::array<float,2>{0.260396898f, 0.489553899f}, std::array<float,2>{0.445002854f, 0.91425705f}, std::array<float,2>{0.54076916f, 0.11024221f}, std::array<float,2>{0.884152472f, 0.5799734f}, std::array<float,2>{0.222507253f, 0.395714849f}, std::array<float,2>{0.00965865608f, 0.739356577f}, std::array<float,2>{0.834269226f, 0.371792018f}, std::array<float,2>{0.637296796f, 0.775155663f}, std::array<float,2>{0.312705249f, 0.161678031f}, std::array<float,2>{0.284860462f, 0.554244876f}, std::array<float,2>{0.69564271f, 0.464865297f}, std::array<float,2>{0.804718673f, 0.99447161f}, std::array<float,2>{0.117304727f, 0.0337151326f}, std::array<float,2>{0.148720101f, 0.826953292f}, std::array<float,2>{0.990704f, 0.207547486f}, std::array<float,2>{0.567569375f, 0.667353034f}, std::array<float,2>{0.42272976f, 0.281058222f}, std::array<float,2>{0.49331224f, 0.77315557f}, std::array<float,2>{0.508405089f, 0.1653613f}, std::array<float,2>{0.914393485f, 0.742680132f}, std::array<float,2>{0.206856087f, 0.365188807f}, std::array<float,2>{0.054897882f, 0.587071419f}, std::array<float,2>{0.847211301f, 0.404284149f}, std::array<float,2>{0.663582563f, 0.911589146f}, std::array<float,2>{0.354949206f, 0.124640524f}, std::array<float,2>{0.256600976f, 0.662967324f}, std::array<float,2>{0.726482093f, 0.271277845f}, std::array<float,2>{0.765996695f, 0.814541519f}, std::array<float,2>{0.0816338062f, 0.217510566f}, std::array<float,2>{0.173378974f, 0.988176823f}, std::array<float,2>{0.941348612f, 0.0421277247f}, std::array<float,2>{0.599058151f, 0.562450945f}, std::array<float,2>{0.38435784f, 0.459767342f}, std::array<float,2>{0.323674768f, 0.895264328f}, std::array<float,2>{0.631596744f, 0.0706630498f}, std::array<float,2>{0.841234326f, 0.603139997f}, std::array<float,2>{0.00163358485f, 0.406949043f}, std::array<float,2>{0.227949619f, 0.697604775f}, std::array<float,2>{0.882083654f, 0.315044045f}, std::array<float,2>{0.53641504f, 0.783590555f}, std::array<float,2>{0.449078381f, 0.127173364f}, std::array<float,2>{0.433736444f, 0.514228582f}, std::array<float,2>{0.57316649f, 0.497259825f}, std::array<float,2>{0.997710943f, 0.939372659f}, std::array<float,2>{0.144460827f, 0.0183427017f}, std::array<float,2>{0.110407591f, 0.862124979f}, std::array<float,2>{0.799519837f, 0.232644349f}, std::array<float,2>{0.694805741f, 0.629477739f}, std::array<float,2>{0.290382296f, 0.290739834f}, std::array<float,2>{0.310096264f, 0.834093034f}, std::array<float,2>{0.70742619f, 0.201512501f}, std::array<float,2>{0.791399121f, 0.6784724f}, std::array<float,2>{0.0972860381f, 0.25335598f}, std::array<float,2>{0.139236212f, 0.542568684f}, std::array<float,2>{0.970144689f, 0.450458378f}, std::array<float,2>{0.580245674f, 0.973264396f}, std::array<float,2>{0.417151004f, 0.059310738f}, std::array<float,2>{0.466592312f, 0.719223619f}, std::array<float,2>{0.556581616f, 0.356821895f}, std::array<float,2>{0.895227373f, 0.75231415f}, std::array<float,2>{0.234469935f, 0.18720001f}, std::array<float,2>{0.025924528f, 0.936584175f}, std::array<float,2>{0.815787315f, 0.108674511f}, std::array<float,2>{0.653830111f, 0.565007627f}, std::array<float,2>{0.328151435f, 0.388601631f}, std::array<float,2>{0.40212363f, 0.957877576f}, std::array<float,2>{0.610874712f, 0.00954037812f}, std::array<float,2>{0.953150094f, 0.524623334f}, std::array<float,2>{0.164949998f, 0.475803316f}, std::array<float,2>{0.0756694227f, 0.651290834f}, std::array<float,2>{0.757591903f, 0.306503564f}, std::array<float,2>{0.74129349f, 0.854687214f}, std::array<float,2>{0.270782471f, 0.249976739f}, std::array<float,2>{0.363641679f, 0.614321113f}, std::array<float,2>{0.671944261f, 0.424458712f}, std::array<float,2>{0.861762941f, 0.885710657f}, std::array<float,2>{0.0333211236f, 0.0891774967f}, std::array<float,2>{0.20086661f, 0.799280822f}, std::array<float,2>{0.937116027f, 0.142556131f}, std::array<float,2>{0.522614956f, 0.712271154f}, std::array<float,2>{0.470711589f, 0.333427578f}, std::array<float,2>{0.388623744f, 0.812211156f}, std::array<float,2>{0.594500422f, 0.15287149f}, std::array<float,2>{0.942827761f, 0.706393301f}, std::array<float,2>{0.176652983f, 0.342898756f}, std::array<float,2>{0.0826201364f, 0.624080956f}, std::array<float,2>{0.772027135f, 0.436022013f}, std::array<float,2>{0.719068646f, 0.879550219f}, std::array<float,2>{0.252090663f, 0.0858609527f}, std::array<float,2>{0.357299477f, 0.642480254f}, std::array<float,2>{0.657624066f, 0.304558963f}, std::array<float,2>{0.848836362f, 0.850528717f}, std::array<float,2>{0.0611987561f, 0.241425619f}, std::array<float,2>{0.208286315f, 0.967661738f}, std::array<float,2>{0.92110914f, 0.00182187103f}, std::array<float,2>{0.513671815f, 0.518064857f}, std::array<float,2>{0.49717018f, 0.479422539f}, std::array<float,2>{0.294903666f, 0.928037763f}, std::array<float,2>{0.690481901f, 0.0981527194f}, std::array<float,2>{0.801632762f, 0.576050162f}, std::array<float,2>{0.114739195f, 0.377047062f}, std::array<float,2>{0.146478072f, 0.73282963f}, std::array<float,2>{0.996013701f, 0.34807539f}, std::array<float,2>{0.576001108f, 0.762289166f}, std::array<float,2>{0.433488071f, 0.178781077f}, std::array<float,2>{0.449219137f, 0.532912254f}, std::array<float,2>{0.533353984f, 0.441479385f}, std::array<float,2>{0.878864169f, 0.976987422f}, std::array<float,2>{0.233585164f, 0.0512894504f}, std::array<float,2>{0.00665393565f, 0.840637386f}, std::array<float,2>{0.838939846f, 0.191796377f}, std::array<float,2>{0.626270533f, 0.680124104f}, std::array<float,2>{0.327953875f, 0.264478862f}, std::array<float,2>{0.333593756f, 0.871495247f}, std::array<float,2>{0.648543477f, 0.218937173f}, std::array<float,2>{0.817587376f, 0.636083603f}, std::array<float,2>{0.0294836741f, 0.288520604f}, std::array<float,2>{0.240476608f, 0.500685334f}, std::array<float,2>{0.893328726f, 0.48801285f}, std::array<float,2>{0.561872005f, 0.948143542f}, std::array<float,2>{0.461407006f, 0.0290995762f}, std::array<float,2>{0.420626223f, 0.691942036f}, std::array<float,2>{0.583666682f, 0.32808277f}, std::array<float,2>{0.975660086f, 0.796263754f}, std::array<float,2>{0.135991469f, 0.14061299f}, std::array<float,2>{0.100726105f, 0.905622959f}, std::array<float,2>{0.796414614f, 0.0698261335f}, std::array<float,2>{0.70628202f, 0.599173486f}, std::array<float,2>{0.306217939f, 0.415550143f}, std::array<float,2>{0.47600463f, 0.998870194f}, std::array<float,2>{0.516188204f, 0.0353293344f}, std::array<float,2>{0.932674825f, 0.549348891f}, std::array<float,2>{0.198199302f, 0.461116254f}, std::array<float,2>{0.0376486517f, 0.671339035f}, std::array<float,2>{0.864086986f, 0.275141418f}, std::array<float,2>{0.677708209f, 0.82406503f}, std::array<float,2>{0.36273697f, 0.204850554f}, std::array<float,2>{0.267366916f, 0.583033502f}, std::array<float,2>{0.735691011f, 0.391706198f}, std::array<float,2>{0.752574503f, 0.92045176f}, std::array<float,2>{0.0722872168f, 0.115434937f}, std::array<float,2>{0.168665215f, 0.780546784f}, std::array<float,2>{0.957067549f, 0.159333989f}, std::array<float,2>{0.614732146f, 0.734807014f}, std::array<float,2>{0.405130297f, 0.370120108f}, std::array<float,2>{0.457224429f, 0.817982376f}, std::array<float,2>{0.552010417f, 0.212290391f}, std::array<float,2>{0.900605857f, 0.658466458f}, std::array<float,2>{0.244201586f, 0.268995106f}, std::array<float,2>{0.0221697409f, 0.557135999f}, std::array<float,2>{0.82716471f, 0.456625611f}, std::array<float,2>{0.643815041f, 0.988455474f}, std::array<float,2>{0.336760014f, 0.0442448184f}, std::array<float,2>{0.30262661f, 0.747653723f}, std::array<float,2>{0.715126157f, 0.361557931f}, std::array<float,2>{0.788158417f, 0.767303407f}, std::array<float,2>{0.107898936f, 0.169469029f}, std::array<float,2>{0.128565311f, 0.908115089f}, std::array<float,2>{0.980905652f, 0.120990574f}, std::array<float,2>{0.593687594f, 0.591980577f}, std::array<float,2>{0.41259262f, 0.400172234f}, std::array<float,2>{0.370026022f, 0.941775084f}, std::array<float,2>{0.680722654f, 0.0196406413f}, std::array<float,2>{0.874131262f, 0.508871913f}, std::array<float,2>{0.0440699011f, 0.494355112f}, std::array<float,2>{0.19265607f, 0.62503469f}, std::array<float,2>{0.926576257f, 0.294730186f}, std::array<float,2>{0.526447475f, 0.865051866f}, std::array<float,2>{0.481470257f, 0.23011978f}, std::array<float,2>{0.398376912f, 0.607328475f}, std::array<float,2>{0.621509016f, 0.41038543f}, std::array<float,2>{0.961684406f, 0.892019808f}, std::array<float,2>{0.158998922f, 0.0745794326f}, std::array<float,2>{0.0666533113f, 0.786859274f}, std::array<float,2>{0.764476836f, 0.13115485f}, std::array<float,2>{0.746237934f, 0.70230335f}, std::array<float,2>{0.279104769f, 0.317477107f}, std::array<float,2>{0.26199457f, 0.75700599f}, std::array<float,2>{0.729268909f, 0.180913851f}, std::array<float,2>{0.775640368f, 0.725953639f}, std::array<float,2>{0.0885100886f, 0.352957755f}, std::array<float,2>{0.184136584f, 0.567822278f}, std::array<float,2>{0.946556151f, 0.385947883f}, std::array<float,2>{0.601894855f, 0.93338871f}, std::array<float,2>{0.379741549f, 0.104967512f}, std::array<float,2>{0.486559421f, 0.673461676f}, std::array<float,2>{0.50235188f, 0.255850315f}, std::array<float,2>{0.911413252f, 0.831084311f}, std::array<float,2>{0.214753106f, 0.198372915f}, std::array<float,2>{0.0477297679f, 0.971329689f}, std::array<float,2>{0.855946898f, 0.057430502f}, std::array<float,2>{0.667217255f, 0.546526074f}, std::array<float,2>{0.350905031f, 0.447329879f}, std::array<float,2>{0.425847024f, 0.890043318f}, std::array<float,2>{0.565899849f, 0.0931400359f}, std::array<float,2>{0.987779438f, 0.610598147f}, std::array<float,2>{0.15334034f, 0.428494334f}, std::array<float,2>{0.121543474f, 0.717390954f}, std::array<float,2>{0.811366141f, 0.331563771f}, std::array<float,2>{0.699797571f, 0.801396489f}, std::array<float,2>{0.287676424f, 0.145555481f}, std::array<float,2>{0.319651484f, 0.530496657f}, std::array<float,2>{0.636328042f, 0.471472651f}, std::array<float,2>{0.829169333f, 0.954607129f}, std::array<float,2>{0.0131604057f, 0.0139937364f}, std::array<float,2>{0.225607395f, 0.857046247f}, std::array<float,2>{0.888626575f, 0.245189324f}, std::array<float,2>{0.544569075f, 0.654186547f}, std::array<float,2>{0.437935233f, 0.311698079f}, std::array<float,2>{0.39214474f, 0.839653254f}, std::array<float,2>{0.618335426f, 0.191159308f}, std::array<float,2>{0.966076553f, 0.686898708f}, std::array<float,2>{0.160930097f, 0.259198308f}, std::array<float,2>{0.0650830716f, 0.537700951f}, std::array<float,2>{0.760437727f, 0.438577086f}, std::array<float,2>{0.744758725f, 0.981775403f}, std::array<float,2>{0.273723453f, 0.0476011299f}, std::array<float,2>{0.374456614f, 0.727907181f}, std::array<float,2>{0.686308622f, 0.345900267f}, std::array<float,2>{0.869488478f, 0.758589745f}, std::array<float,2>{0.041853413f, 0.174592376f}, std::array<float,2>{0.188433394f, 0.92213279f}, std::array<float,2>{0.924613476f, 0.095964618f}, std::array<float,2>{0.529154301f, 0.573418677f}, std::array<float,2>{0.47916761f, 0.380441248f}, std::array<float,2>{0.297846705f, 0.96310854f}, std::array<float,2>{0.71203506f, 0.00652603153f}, std::array<float,2>{0.784033f, 0.520200968f}, std::array<float,2>{0.10276103f, 0.484083772f}, std::array<float,2>{0.131277591f, 0.645650327f}, std::array<float,2>{0.978118181f, 0.298546523f}, std::array<float,2>{0.589101374f, 0.847303033f}, std::array<float,2>{0.409638077f, 0.237477913f}, std::array<float,2>{0.454192549f, 0.620211184f}, std::array<float,2>{0.549742162f, 0.43054077f}, std::array<float,2>{0.902784348f, 0.875646591f}, std::array<float,2>{0.249286845f, 0.0784615055f}, std::array<float,2>{0.0169686191f, 0.806392491f}, std::array<float,2>{0.823862433f, 0.148619682f}, std::array<float,2>{0.646289229f, 0.707868695f}, std::array<float,2>{0.342205524f, 0.337391883f}, std::array<float,2>{0.315231621f, 0.776924908f}, std::array<float,2>{0.639747798f, 0.162384361f}, std::array<float,2>{0.833170116f, 0.741469502f}, std::array<float,2>{0.0109010097f, 0.374350637f}, std::array<float,2>{0.219952822f, 0.581498027f}, std::array<float,2>{0.884854734f, 0.398058474f}, std::array<float,2>{0.541159809f, 0.917203605f}, std::array<float,2>{0.44165957f, 0.111978024f}, std::array<float,2>{0.425078541f, 0.665395021f}, std::array<float,2>{0.570168078f, 0.277795851f}, std::array<float,2>{0.990105629f, 0.825835466f}, std::array<float,2>{0.151464283f, 0.210772812f}, std::array<float,2>{0.119205862f, 0.993170321f}, std::array<float,2>{0.80824244f, 0.0319462791f}, std::array<float,2>{0.697387338f, 0.5517537f}, std::array<float,2>{0.281361759f, 0.467261165f}, std::array<float,2>{0.491174787f, 0.900075853f}, std::array<float,2>{0.504326582f, 0.06432724f}, std::array<float,2>{0.907155395f, 0.596960008f}, std::array<float,2>{0.217191711f, 0.41828841f}, std::array<float,2>{0.0530938096f, 0.689706624f}, std::array<float,2>{0.85476613f, 0.32189849f}, std::array<float,2>{0.671329916f, 0.792057216f}, std::array<float,2>{0.344777822f, 0.135309562f}, std::array<float,2>{0.258722007f, 0.506961823f}, std::array<float,2>{0.730477273f, 0.491352886f}, std::array<float,2>{0.77793628f, 0.952292621f}, std::array<float,2>{0.0913099721f, 0.0273388624f}, std::array<float,2>{0.182279229f, 0.868515432f}, std::array<float,2>{0.952219188f, 0.225858644f}, std::array<float,2>{0.605646968f, 0.639111698f}, std::array<float,2>{0.375875086f, 0.282675385f}, std::array<float,2>{0.445404589f, 0.781529486f}, std::array<float,2>{0.538246989f, 0.1264759f}, std::array<float,2>{0.880136192f, 0.697002411f}, std::array<float,2>{0.228771269f, 0.313969582f}, std::array<float,2>{0.00351237855f, 0.604052246f}, std::array<float,2>{0.84204495f, 0.408901244f}, std::array<float,2>{0.630729795f, 0.897060633f}, std::array<float,2>{0.321703434f, 0.0739533752f}, std::array<float,2>{0.291474074f, 0.632784128f}, std::array<float,2>{0.691957355f, 0.291982383f}, std::array<float,2>{0.797536612f, 0.860208631f}, std::array<float,2>{0.111967944f, 0.231501773f}, std::array<float,2>{0.14119415f, 0.940890551f}, std::array<float,2>{0.999885261f, 0.016818149f}, std::array<float,2>{0.571309745f, 0.51296401f}, std::array<float,2>{0.436867148f, 0.499112517f}, std::array<float,2>{0.353077561f, 0.912769496f}, std::array<float,2>{0.660629272f, 0.12277998f}, std::array<float,2>{0.844532609f, 0.588145912f}, std::array<float,2>{0.0577432141f, 0.404488564f}, std::array<float,2>{0.203638941f, 0.745908856f}, std::array<float,2>{0.917910814f, 0.365257829f}, std::array<float,2>{0.509824693f, 0.770660162f}, std::array<float,2>{0.494715363f, 0.167087689f}, std::array<float,2>{0.38607648f, 0.560364246f}, std::array<float,2>{0.600943089f, 0.457492501f}, std::array<float,2>{0.938341141f, 0.986161768f}, std::array<float,2>{0.174110338f, 0.03928826f}, std::array<float,2>{0.0785425678f, 0.813009799f}, std::array<float,2>{0.767648339f, 0.216300324f}, std::array<float,2>{0.723633349f, 0.661445677f}, std::array<float,2>{0.254109144f, 0.27322191f}, std::array<float,2>{0.272639006f, 0.853186011f}, std::array<float,2>{0.739504397f, 0.24658379f}, std::array<float,2>{0.754607141f, 0.648792922f}, std::array<float,2>{0.0764547735f, 0.307633311f}, std::array<float,2>{0.166501865f, 0.525849998f}, std::array<float,2>{0.955955684f, 0.473437935f}, std::array<float,2>{0.611508846f, 0.960688055f}, std::array<float,2>{0.39849925f, 0.0110436622f}, std::array<float,2>{0.470601052f, 0.713797033f}, std::array<float,2>{0.520832181f, 0.335666627f}, std::array<float,2>{0.933807135f, 0.797804058f}, std::array<float,2>{0.201264814f, 0.144331768f}, std::array<float,2>{0.0328588635f, 0.883463562f}, std::array<float,2>{0.861020923f, 0.0878087804f}, std::array<float,2>{0.675451458f, 0.615429759f}, std::array<float,2>{0.366024435f, 0.42353031f}, std::array<float,2>{0.415228248f, 0.974789023f}, std::array<float,2>{0.579960048f, 0.0605898872f}, std::array<float,2>{0.971613467f, 0.540011108f}, std::array<float,2>{0.137899518f, 0.451973766f}, std::array<float,2>{0.0953332856f, 0.675859809f}, std::array<float,2>{0.789370656f, 0.250897408f}, std::array<float,2>{0.709659755f, 0.833530605f}, std::array<float,2>{0.31154865f, 0.199481249f}, std::array<float,2>{0.330471218f, 0.563907802f}, std::array<float,2>{0.655210733f, 0.389783412f}, std::array<float,2>{0.813119292f, 0.934480965f}, std::array<float,2>{0.0248409901f, 0.106917977f}, std::array<float,2>{0.238140345f, 0.750756979f}, std::array<float,2>{0.898065567f, 0.183640629f}, std::array<float,2>{0.557583332f, 0.720808864f}, std::array<float,2>{0.468466222f, 0.357581168f}, std::array<float,2>{0.430905491f, 0.765448213f}, std::array<float,2>{0.577270508f, 0.176731616f}, std::array<float,2>{0.992563665f, 0.731974721f}, std::array<float,2>{0.147867993f, 0.351103067f}, std::array<float,2>{0.115861207f, 0.577195525f}, std::array<float,2>{0.80364424f, 0.375787735f}, std::array<float,2>{0.68773663f, 0.92656517f}, std::array<float,2>{0.295378029f, 0.101396635f}, std::array<float,2>{0.32509473f, 0.683481514f}, std::array<float,2>{0.627925873f, 0.263487279f}, std::array<float,2>{0.835987747f, 0.842866421f}, std::array<float,2>{0.00517386151f, 0.194847926f}, std::array<float,2>{0.232182413f, 0.979006529f}, std::array<float,2>{0.876427412f, 0.0531123169f}, std::array<float,2>{0.532134235f, 0.534440517f}, std::array<float,2>{0.452620506f, 0.444689512f}, std::array<float,2>{0.251265764f, 0.882345796f}, std::array<float,2>{0.722341955f, 0.0822830945f}, std::array<float,2>{0.770029426f, 0.621996701f}, std::array<float,2>{0.0855053812f, 0.433835208f}, std::array<float,2>{0.179474682f, 0.7044487f}, std::array<float,2>{0.943846822f, 0.341133028f}, std::array<float,2>{0.596171558f, 0.809433043f}, std::array<float,2>{0.388905346f, 0.155820951f}, std::array<float,2>{0.49941203f, 0.516616166f}, std::array<float,2>{0.514285088f, 0.476798654f}, std::array<float,2>{0.919676006f, 0.965253651f}, std::array<float,2>{0.210526913f, 0.00233853213f}, std::array<float,2>{0.0587263219f, 0.848745763f}, std::array<float,2>{0.851372361f, 0.239263117f}, std::array<float,2>{0.659098685f, 0.643137634f}, std::array<float,2>{0.359024376f, 0.300859272f}, std::array<float,2>{0.361200035f, 0.821722746f}, std::array<float,2>{0.678126097f, 0.205832973f}, std::array<float,2>{0.866943777f, 0.668590486f}, std::array<float,2>{0.0360662341f, 0.275914341f}, std::array<float,2>{0.195727512f, 0.548553765f}, std::array<float,2>{0.930145204f, 0.462957323f}, std::array<float,2>{0.518704295f, 0.997960448f}, std::array<float,2>{0.473420173f, 0.0387429297f}, std::array<float,2>{0.403534442f, 0.737801433f}, std::array<float,2>{0.615316033f, 0.369112462f}, std::array<float,2>{0.959219456f, 0.777662694f}, std::array<float,2>{0.170337498f, 0.158167362f}, std::array<float,2>{0.0720550716f, 0.918954432f}, std::array<float,2>{0.750513911f, 0.114521116f}, std::array<float,2>{0.736694872f, 0.584249556f}, std::array<float,2>{0.26795125f, 0.394394636f}, std::array<float,2>{0.46346879f, 0.946514845f}, std::array<float,2>{0.558665276f, 0.0312227216f}, std::array<float,2>{0.891808748f, 0.50200516f}, std::array<float,2>{0.238801822f, 0.484907538f}, std::array<float,2>{0.0278833583f, 0.633889019f}, std::array<float,2>{0.818944156f, 0.28541857f}, std::array<float,2>{0.650577664f, 0.874738693f}, std::array<float,2>{0.335067898f, 0.221357748f}, std::array<float,2>{0.308271408f, 0.59967196f}, std::array<float,2>{0.704034269f, 0.416461587f}, std::array<float,2>{0.793772876f, 0.903361857f}, std::array<float,2>{0.0979364812f, 0.0678821802f}, std::array<float,2>{0.133110151f, 0.793952525f}, std::array<float,2>{0.97360152f, 0.137770861f}, std::array<float,2>{0.585564792f, 0.693700552f}, std::array<float,2>{0.419803143f, 0.324950069f}, std::array<float,2>{0.483108222f, 0.865911782f}, std::array<float,2>{0.523747623f, 0.226751938f}, std::array<float,2>{0.929680824f, 0.628245294f}, std::array<float,2>{0.194428846f, 0.295606941f}, std::array<float,2>{0.0465325862f, 0.510032058f}, std::array<float,2>{0.872163355f, 0.493478417f}, std::array<float,2>{0.682685316f, 0.945297837f}, std::array<float,2>{0.368669152f, 0.0224835165f}, std::array<float,2>{0.280736566f, 0.700398207f}, std::array<float,2>{0.749181747f, 0.319896191f}, std::array<float,2>{0.762358367f, 0.788493335f}, std::array<float,2>{0.0684948266f, 0.130726665f}, std::array<float,2>{0.15652056f, 0.894476831f}, std::array<float,2>{0.963696182f, 0.0772592872f}, std::array<float,2>{0.624921024f, 0.608892918f}, std::array<float,2>{0.395222336f, 0.413482219f}, std::array<float,2>{0.339586556f, 0.991027355f}, std::array<float,2>{0.642169297f, 0.0454329811f}, std::array<float,2>{0.824472785f, 0.556195617f}, std::array<float,2>{0.0209426042f, 0.454979181f}, std::array<float,2>{0.243461072f, 0.656735778f}, std::array<float,2>{0.899548411f, 0.267387092f}, std::array<float,2>{0.554203153f, 0.819984972f}, std::array<float,2>{0.459265471f, 0.214704335f}, std::array<float,2>{0.411329597f, 0.590845764f}, std::array<float,2>{0.590169489f, 0.401060343f}, std::array<float,2>{0.983068347f, 0.908992529f}, std::array<float,2>{0.125382155f, 0.118383616f}, std::array<float,2>{0.107131861f, 0.768579841f}, std::array<float,2>{0.785319686f, 0.170786366f}, std::array<float,2>{0.716955781f, 0.749455512f}, std::array<float,2>{0.303002685f, 0.361108392f}, std::array<float,2>{0.286008298f, 0.803569257f}, std::array<float,2>{0.702156246f, 0.147713408f}, std::array<float,2>{0.809389651f, 0.716467679f}, std::array<float,2>{0.123463891f, 0.329362005f}, std::array<float,2>{0.156219363f, 0.611963391f}, std::array<float,2>{0.985434592f, 0.427625269f}, std::array<float,2>{0.564112067f, 0.888247311f}, std::array<float,2>{0.429311663f, 0.0916610658f}, std::array<float,2>{0.440047115f, 0.654954672f}, std::array<float,2>{0.545056999f, 0.310478568f}, std::array<float,2>{0.889341295f, 0.858947515f}, std::array<float,2>{0.223955408f, 0.243080422f}, std::array<float,2>{0.0147097073f, 0.956411362f}, std::array<float,2>{0.831688523f, 0.0130475787f}, std::array<float,2>{0.633896351f, 0.527444959f}, std::array<float,2>{0.316465527f, 0.469010949f}, std::array<float,2>{0.382679313f, 0.930815578f}, std::array<float,2>{0.605376482f, 0.102565587f}, std::array<float,2>{0.948376238f, 0.568876565f}, std::array<float,2>{0.187056631f, 0.384312034f}, std::array<float,2>{0.0876016542f, 0.722934186f}, std::array<float,2>{0.77419591f, 0.354108214f}, std::array<float,2>{0.726570308f, 0.755042791f}, std::array<float,2>{0.26454249f, 0.18279773f}, std::array<float,2>{0.348626792f, 0.543819487f}, std::array<float,2>{0.664188921f, 0.445757776f}, std::array<float,2>{0.857609153f, 0.97066313f}, std::array<float,2>{0.0506838895f, 0.0564820096f}, std::array<float,2>{0.212611273f, 0.828845441f}, std::array<float,2>{0.913470507f, 0.196137995f}, std::array<float,2>{0.500569224f, 0.674351037f}, std::array<float,2>{0.484903544f, 0.256354392f}, std::array<float,2>{0.376459539f, 0.870499015f}, std::array<float,2>{0.607164085f, 0.224390805f}, std::array<float,2>{0.952095628f, 0.637283921f}, std::array<float,2>{0.182621986f, 0.284826636f}, std::array<float,2>{0.0902179256f, 0.504964769f}, std::array<float,2>{0.77900821f, 0.488304257f}, std::array<float,2>{0.731606126f, 0.950235069f}, std::array<float,2>{0.259710371f, 0.0250334367f}, std::array<float,2>{0.344691813f, 0.688612938f}, std::array<float,2>{0.670178771f, 0.323929697f}, std::array<float,2>{0.853683412f, 0.790087104f}, std::array<float,2>{0.0546334051f, 0.133054763f}, std::array<float,2>{0.218740776f, 0.90112406f}, std::array<float,2>{0.907901049f, 0.0650304556f}, std::array<float,2>{0.505827487f, 0.59418124f}, std::array<float,2>{0.491839677f, 0.421582669f}, std::array<float,2>{0.28226614f, 0.995607376f}, std::array<float,2>{0.698809326f, 0.0345584527f}, std::array<float,2>{0.807386398f, 0.55290693f}, std::array<float,2>{0.120490715f, 0.466003388f}, std::array<float,2>{0.150694445f, 0.666873991f}, std::array<float,2>{0.988608003f, 0.279513985f}, std::array<float,2>{0.568589032f, 0.827696323f}, std::array<float,2>{0.423949659f, 0.208357364f}, std::array<float,2>{0.442815781f, 0.57909286f}, std::array<float,2>{0.542569816f, 0.394723088f}, std::array<float,2>{0.886312544f, 0.915612876f}, std::array<float,2>{0.218952641f, 0.11088632f}, std::array<float,2>{0.00989048835f, 0.774101913f}, std::array<float,2>{0.832580566f, 0.160498753f}, std::array<float,2>{0.639636815f, 0.739238262f}, std::array<float,2>{0.316321254f, 0.372581959f}, std::array<float,2>{0.3435013f, 0.808181286f}, std::array<float,2>{0.644578695f, 0.151331261f}, std::array<float,2>{0.822710037f, 0.709987283f}, std::array<float,2>{0.0160662606f, 0.338420063f}, std::array<float,2>{0.248915061f, 0.618043423f}, std::array<float,2>{0.903545499f, 0.432664007f}, std::array<float,2>{0.550261259f, 0.878105462f}, std::array<float,2>{0.453282386f, 0.080662027f}, std::array<float,2>{0.408750236f, 0.648035944f}, std::array<float,2>{0.588666558f, 0.298881143f}, std::array<float,2>{0.977033079f, 0.844861865f}, std::array<float,2>{0.132707208f, 0.234413043f}, std::array<float,2>{0.101574905f, 0.961701512f}, std::array<float,2>{0.784790516f, 0.00421790034f}, std::array<float,2>{0.711446404f, 0.52232635f}, std::array<float,2>{0.297994524f, 0.480702877f}, std::array<float,2>{0.479888201f, 0.92501682f}, std::array<float,2>{0.528006434f, 0.0954090804f}, std::array<float,2>{0.925130725f, 0.570543647f}, std::array<float,2>{0.189114705f, 0.382377386f}, std::array<float,2>{0.0423936322f, 0.728835762f}, std::array<float,2>{0.871021926f, 0.345499039f}, std::array<float,2>{0.687429428f, 0.760900497f}, std::array<float,2>{0.373556674f, 0.173598468f}, std::array<float,2>{0.275066525f, 0.536201596f}, std::array<float,2>{0.745346904f, 0.439867288f}, std::array<float,2>{0.761407793f, 0.983957589f}, std::array<float,2>{0.0656989068f, 0.0493787155f}, std::array<float,2>{0.161449969f, 0.836049259f}, std::array<float,2>{0.965679348f, 0.189048722f}, std::array<float,2>{0.617403865f, 0.685312212f}, std::array<float,2>{0.391496897f, 0.261234999f}, std::array<float,2>{0.467300534f, 0.75330925f}, std::array<float,2>{0.557764292f, 0.186118051f}, std::array<float,2>{0.897328794f, 0.719989479f}, std::array<float,2>{0.236956045f, 0.356038988f}, std::array<float,2>{0.0235385634f, 0.565487146f}, std::array<float,2>{0.813557863f, 0.387227327f}, std::array<float,2>{0.655467629f, 0.935987532f}, std::array<float,2>{0.331843883f, 0.107720755f}, std::array<float,2>{0.311129004f, 0.678910792f}, std::array<float,2>{0.710621059f, 0.252783537f}, std::array<float,2>{0.790814996f, 0.835925281f}, std::array<float,2>{0.094620578f, 0.203106955f}, std::array<float,2>{0.137295321f, 0.97423929f}, std::array<float,2>{0.972596288f, 0.0601938553f}, std::array<float,2>{0.57903707f, 0.54172045f}, std::array<float,2>{0.414721668f, 0.449500263f}, std::array<float,2>{0.366809279f, 0.885893762f}, std::array<float,2>{0.674702823f, 0.0885955691f}, std::array<float,2>{0.860233068f, 0.613550067f}, std::array<float,2>{0.0312910043f, 0.425566196f}, std::array<float,2>{0.202985033f, 0.711746275f}, std::array<float,2>{0.934612572f, 0.332081437f}, std::array<float,2>{0.520301282f, 0.800258517f}, std::array<float,2>{0.469712973f, 0.141132846f}, std::array<float,2>{0.399699062f, 0.52429682f}, std::array<float,2>{0.612982929f, 0.47521618f}, std::array<float,2>{0.956517816f, 0.958076537f}, std::array<float,2>{0.167156205f, 0.00850879867f}, std::array<float,2>{0.0774962306f, 0.854030788f}, std::array<float,2>{0.755422413f, 0.248809159f}, std::array<float,2>{0.738822579f, 0.651418328f}, std::array<float,2>{0.271925956f, 0.304934502f}, std::array<float,2>{0.255490571f, 0.816147149f}, std::array<float,2>{0.723543167f, 0.218168363f}, std::array<float,2>{0.76913923f, 0.664053202f}, std::array<float,2>{0.0794734433f, 0.269759893f}, std::array<float,2>{0.17531839f, 0.560569048f}, std::array<float,2>{0.938538432f, 0.460465014f}, std::array<float,2>{0.599831223f, 0.986390531f}, std::array<float,2>{0.385582596f, 0.0410644636f}, std::array<float,2>{0.495855033f, 0.744065225f}, std::array<float,2>{0.51141125f, 0.363902956f}, std::array<float,2>{0.916514993f, 0.771777272f}, std::array<float,2>{0.20460549f, 0.164634943f}, std::array<float,2>{0.0567004979f, 0.910267174f}, std::array<float,2>{0.845273077f, 0.123851426f}, std::array<float,2>{0.661600947f, 0.586175859f}, std::array<float,2>{0.351780057f, 0.402463019f}, std::array<float,2>{0.436403453f, 0.93843776f}, std::array<float,2>{0.570840478f, 0.0189837012f}, std::array<float,2>{0.9985376f, 0.515240073f}, std::array<float,2>{0.141820237f, 0.49670884f}, std::array<float,2>{0.112319827f, 0.62989527f}, std::array<float,2>{0.798111975f, 0.289840937f}, std::array<float,2>{0.692741215f, 0.863097906f}, std::array<float,2>{0.292010695f, 0.233917177f}, std::array<float,2>{0.32042405f, 0.601844788f}, std::array<float,2>{0.629326642f, 0.408151329f}, std::array<float,2>{0.843470335f, 0.896361351f}, std::array<float,2>{0.00206798222f, 0.0718520433f}, std::array<float,2>{0.230197668f, 0.784939468f}, std::array<float,2>{0.879524171f, 0.128044263f}, std::array<float,2>{0.537745893f, 0.69887954f}, std::array<float,2>{0.446859509f, 0.316368014f}, std::array<float,2>{0.418053657f, 0.795366466f}, std::array<float,2>{0.584742904f, 0.139049143f}, std::array<float,2>{0.974215806f, 0.693143845f}, std::array<float,2>{0.134502068f, 0.32632646f}, std::array<float,2>{0.0993236229f, 0.598320127f}, std::array<float,2>{0.794411182f, 0.41447562f}, std::array<float,2>{0.704905272f, 0.904529274f}, std::array<float,2>{0.30711025f, 0.0686947182f}, std::array<float,2>{0.334843874f, 0.635603428f}, std::array<float,2>{0.651846707f, 0.287139893f}, std::array<float,2>{0.820027649f, 0.872361839f}, std::array<float,2>{0.028539177f, 0.219814628f}, std::array<float,2>{0.240137905f, 0.948646784f}, std::array<float,2>{0.890851796f, 0.0283090621f}, std::array<float,2>{0.560022891f, 0.501750648f}, std::array<float,2>{0.464656323f, 0.486664116f}, std::array<float,2>{0.269000173f, 0.921161711f}, std::array<float,2>{0.737701297f, 0.116913483f}, std::array<float,2>{0.751786292f, 0.582403779f}, std::array<float,2>{0.0708467737f, 0.391563952f}, std::array<float,2>{0.171693087f, 0.735697269f}, std::array<float,2>{0.960732102f, 0.369711101f}, std::array<float,2>{0.616650581f, 0.779664636f}, std::array<float,2>{0.403000206f, 0.158514649f}, std::array<float,2>{0.473880798f, 0.550210416f}, std::array<float,2>{0.51833719f, 0.462442309f}, std::array<float,2>{0.931203246f, 0.999309301f}, std::array<float,2>{0.196913257f, 0.0362814888f}, std::array<float,2>{0.0364864022f, 0.822332025f}, std::array<float,2>{0.865887582f, 0.203423738f}, std::array<float,2>{0.679496765f, 0.670399129f}, std::array<float,2>{0.359502286f, 0.273779809f}, std::array<float,2>{0.357751429f, 0.850634813f}, std::array<float,2>{0.659470081f, 0.240767285f}, std::array<float,2>{0.850506425f, 0.641406596f}, std::array<float,2>{0.0605247132f, 0.302908272f}, std::array<float,2>{0.209277168f, 0.518821657f}, std::array<float,2>{0.918260872f, 0.480232149f}, std::array<float,2>{0.515459239f, 0.968669891f}, std::array<float,2>{0.49846971f, 0.000748933235f}, std::array<float,2>{0.390472919f, 0.705357313f}, std::array<float,2>{0.597103894f, 0.342516482f}, std::array<float,2>{0.94500041f, 0.811356068f}, std::array<float,2>{0.178156868f, 0.153825387f}, std::array<float,2>{0.084174782f, 0.880134404f}, std::array<float,2>{0.771352649f, 0.0840693712f}, std::array<float,2>{0.721473753f, 0.623227656f}, std::array<float,2>{0.250576586f, 0.437077254f}, std::array<float,2>{0.451882422f, 0.978259146f}, std::array<float,2>{0.533202052f, 0.0524256825f}, std::array<float,2>{0.875500083f, 0.531882524f}, std::array<float,2>{0.2312987f, 0.443274736f}, std::array<float,2>{0.00452649267f, 0.681139886f}, std::array<float,2>{0.837599277f, 0.264894783f}, std::array<float,2>{0.628586233f, 0.841314554f}, std::array<float,2>{0.325563431f, 0.19239825f}, std::array<float,2>{0.296355695f, 0.574750483f}, std::array<float,2>{0.689161003f, 0.378573209f}, std::array<float,2>{0.804176807f, 0.929275036f}, std::array<float,2>{0.116496317f, 0.0989582017f}, std::array<float,2>{0.147132516f, 0.763458848f}, std::array<float,2>{0.993406653f, 0.177735746f}, std::array<float,2>{0.576456368f, 0.734049737f}, std::array<float,2>{0.43064779f, 0.349180013f}, std::array<float,2>{0.485663086f, 0.830744445f}, std::array<float,2>{0.501947939f, 0.197766542f}, std::array<float,2>{0.91265893f, 0.672255933f}, std::array<float,2>{0.211672813f, 0.254376829f}, std::array<float,2>{0.0490491092f, 0.545874119f}, std::array<float,2>{0.858745873f, 0.448950946f}, std::array<float,2>{0.665929377f, 0.971852779f}, std::array<float,2>{0.348823309f, 0.0578030683f}, std::array<float,2>{0.265157461f, 0.725150526f}, std::array<float,2>{0.728509009f, 0.352082103f}, std::array<float,2>{0.775253475f, 0.756405175f}, std::array<float,2>{0.0865998641f, 0.180600807f}, std::array<float,2>{0.185992599f, 0.932274461f}, std::array<float,2>{0.948005259f, 0.104339719f}, std::array<float,2>{0.603986681f, 0.566938221f}, std::array<float,2>{0.381632924f, 0.385520637f}, std::array<float,2>{0.317738503f, 0.953937232f}, std::array<float,2>{0.633229852f, 0.0155791715f}, std::array<float,2>{0.830186963f, 0.529971182f}, std::array<float,2>{0.0140524302f, 0.472050428f}, std::array<float,2>{0.223530605f, 0.65310216f}, std::array<float,2>{0.889989614f, 0.311094701f}, std::array<float,2>{0.546420157f, 0.856321394f}, std::array<float,2>{0.440610975f, 0.244575948f}, std::array<float,2>{0.427925199f, 0.609758615f}, std::array<float,2>{0.562998712f, 0.428962916f}, std::array<float,2>{0.985062718f, 0.889469326f}, std::array<float,2>{0.154654533f, 0.0923320502f}, std::array<float,2>{0.124463506f, 0.802360296f}, std::array<float,2>{0.810037017f, 0.145193785f}, std::array<float,2>{0.701862156f, 0.717888296f}, std::array<float,2>{0.286426365f, 0.331032693f}, std::array<float,2>{0.304061592f, 0.765637398f}, std::array<float,2>{0.718061924f, 0.168540061f}, std::array<float,2>{0.786136866f, 0.74673593f}, std::array<float,2>{0.106005415f, 0.363132119f}, std::array<float,2>{0.126614153f, 0.593155146f}, std::array<float,2>{0.983712554f, 0.398658484f}, std::array<float,2>{0.59151721f, 0.906806171f}, std::array<float,2>{0.410429358f, 0.119958267f}, std::array<float,2>{0.460206151f, 0.659730017f}, std::array<float,2>{0.553032637f, 0.268211246f}, std::array<float,2>{0.898987412f, 0.817274272f}, std::array<float,2>{0.242266729f, 0.211315915f}, std::array<float,2>{0.0199743286f, 0.990069807f}, std::array<float,2>{0.825275123f, 0.0431098081f}, std::array<float,2>{0.640656054f, 0.558422506f}, std::array<float,2>{0.338356733f, 0.455570877f}, std::array<float,2>{0.395828009f, 0.891275227f}, std::array<float,2>{0.623734772f, 0.0759909675f}, std::array<float,2>{0.964636981f, 0.606342852f}, std::array<float,2>{0.157513633f, 0.411737472f}, std::array<float,2>{0.0693995208f, 0.701793611f}, std::array<float,2>{0.763148785f, 0.316643834f}, std::array<float,2>{0.748185754f, 0.785794258f}, std::array<float,2>{0.279856175f, 0.132796571f}, std::array<float,2>{0.367726505f, 0.507973492f}, std::array<float,2>{0.68258661f, 0.49522084f}, std::array<float,2>{0.871758521f, 0.942952871f}, std::array<float,2>{0.0458465517f, 0.0209367611f}, std::array<float,2>{0.194050387f, 0.863344252f}, std::array<float,2>{0.928185523f, 0.229142323f}, std::array<float,2>{0.524787247f, 0.626341641f}, std::array<float,2>{0.483579844f, 0.29344064f}, std::array<float,2>{0.423804909f, 0.824314177f}, std::array<float,2>{0.56657064f, 0.209874839f}, std::array<float,2>{0.991378069f, 0.664655745f}, std::array<float,2>{0.149548203f, 0.279154092f}, std::array<float,2>{0.118850097f, 0.552557826f}, std::array<float,2>{0.806639016f, 0.467967838f}, std::array<float,2>{0.696538329f, 0.992567778f}, std::array<float,2>{0.283796132f, 0.0328660272f}, std::array<float,2>{0.314189762f, 0.741178751f}, std::array<float,2>{0.637880802f, 0.37378028f}, std::array<float,2>{0.835584939f, 0.77613312f}, std::array<float,2>{0.00823593326f, 0.164037064f}, std::array<float,2>{0.221650198f, 0.916425765f}, std::array<float,2>{0.883384228f, 0.113207817f}, std::array<float,2>{0.539912105f, 0.581026316f}, std::array<float,2>{0.444196612f, 0.397096485f}, std::array<float,2>{0.261107653f, 0.951215446f}, std::array<float,2>{0.733538568f, 0.0258203913f}, std::array<float,2>{0.780318737f, 0.50667274f}, std::array<float,2>{0.0930427536f, 0.490946501f}, std::array<float,2>{0.181404293f, 0.640071452f}, std::array<float,2>{0.949292183f, 0.281808376f}, std::array<float,2>{0.607560217f, 0.868091762f}, std::array<float,2>{0.37773487f, 0.225194246f}, std::array<float,2>{0.489298642f, 0.596473157f}, std::array<float,2>{0.507626653f, 0.419551075f}, std::array<float,2>{0.908667803f, 0.898741901f}, std::array<float,2>{0.216460451f, 0.0632154718f}, std::array<float,2>{0.0527336001f, 0.791709602f}, std::array<float,2>{0.85237056f, 0.136321336f}, std::array<float,2>{0.668735147f, 0.691106498f}, std::array<float,2>{0.347245336f, 0.320707053f}, std::array<float,2>{0.371774286f, 0.759105504f}, std::array<float,2>{0.684216976f, 0.17515716f}, std::array<float,2>{0.86731261f, 0.726894915f}, std::array<float,2>{0.0400292799f, 0.347100675f}, std::array<float,2>{0.189761549f, 0.572828352f}, std::array<float,2>{0.922669053f, 0.379596323f}, std::array<float,2>{0.529628575f, 0.923188567f}, std::array<float,2>{0.477970898f, 0.0968795717f}, std::array<float,2>{0.393248767f, 0.686493337f}, std::array<float,2>{0.620525062f, 0.25837332f}, std::array<float,2>{0.967521906f, 0.837955117f}, std::array<float,2>{0.163972318f, 0.190299824f}, std::array<float,2>{0.0639365241f, 0.980696142f}, std::array<float,2>{0.759680331f, 0.0482412204f}, std::array<float,2>{0.743148565f, 0.538461268f}, std::array<float,2>{0.275785536f, 0.438086331f}, std::array<float,2>{0.455468088f, 0.876775622f}, std::array<float,2>{0.547042131f, 0.0791949704f}, std::array<float,2>{0.904308498f, 0.61940825f}, std::array<float,2>{0.24649246f, 0.43143782f}, std::array<float,2>{0.0179843493f, 0.708352208f}, std::array<float,2>{0.822244406f, 0.336013347f}, std::array<float,2>{0.646979094f, 0.805657208f}, std::array<float,2>{0.340123087f, 0.149518594f}, std::array<float,2>{0.299512088f, 0.520962656f}, std::array<float,2>{0.713368773f, 0.482845306f}, std::array<float,2>{0.781320572f, 0.96417737f}, std::array<float,2>{0.105316751f, 0.00773037784f}, std::array<float,2>{0.129154086f, 0.846604049f}, std::array<float,2>{0.980275273f, 0.237093464f}, std::array<float,2>{0.586190164f, 0.645110965f}, std::array<float,2>{0.406785399f, 0.297395766f}, std::array<float,2>{0.472018212f, 0.798360229f}, std::array<float,2>{0.521528125f, 0.143361717f}, std::array<float,2>{0.936358809f, 0.714828432f}, std::array<float,2>{0.200173199f, 0.334332407f}, std::array<float,2>{0.0350981876f, 0.616347373f}, std::array<float,2>{0.862828493f, 0.422419459f}, std::array<float,2>{0.672921479f, 0.884250402f}, std::array<float,2>{0.364282906f, 0.0860977024f}, std::array<float,2>{0.270137936f, 0.650131345f}, std::array<float,2>{0.740709901f, 0.307519764f}, std::array<float,2>{0.756203294f, 0.852238297f}, std::array<float,2>{0.0745345056f, 0.247197345f}, std::array<float,2>{0.165090844f, 0.95986712f}, std::array<float,2>{0.95450139f, 0.0105340006f}, std::array<float,2>{0.609431565f, 0.527290583f}, std::array<float,2>{0.401360601f, 0.474294215f}, std::array<float,2>{0.329347163f, 0.934995353f}, std::array<float,2>{0.652624965f, 0.105718881f}, std::array<float,2>{0.815019429f, 0.562531769f}, std::array<float,2>{0.0270480122f, 0.389276683f}, std::array<float,2>{0.235965669f, 0.722253621f}, std::array<float,2>{0.8962152f, 0.359205872f}, std::array<float,2>{0.555155396f, 0.751655757f}, std::array<float,2>{0.465303779f, 0.1854067f}, std::array<float,2>{0.416093498f, 0.540374398f}, std::array<float,2>{0.581656814f, 0.452189356f}, std::array<float,2>{0.969161749f, 0.976484239f}, std::array<float,2>{0.140077457f, 0.0618839711f}, std::array<float,2>{0.0960148796f, 0.83231312f}, std::array<float,2>{0.792116821f, 0.200756162f}, std::array<float,2>{0.708954513f, 0.677160442f}, std::array<float,2>{0.309047192f, 0.251071423f}, std::array<float,2>{0.28966549f, 0.860384703f}, std::array<float,2>{0.694029987f, 0.230987817f}, std::array<float,2>{0.799845934f, 0.630889058f}, std::array<float,2>{0.110273845f, 0.29227376f}, std::array<float,2>{0.143345445f, 0.512009442f}, std::array<float,2>{0.996772468f, 0.49805066f}, std::array<float,2>{0.573302567f, 0.940125942f}, std::array<float,2>{0.435074776f, 0.0157894976f}, std::array<float,2>{0.448213339f, 0.695974767f}, std::array<float,2>{0.535925686f, 0.313241422f}, std::array<float,2>{0.881143808f, 0.782463729f}, std::array<float,2>{0.227479771f, 0.125102609f}, std::array<float,2>{0.000939437421f, 0.89796114f}, std::array<float,2>{0.840144336f, 0.0724379346f}, std::array<float,2>{0.632361889f, 0.605256259f}, std::array<float,2>{0.322332472f, 0.409288317f}, std::array<float,2>{0.383167475f, 0.984912038f}, std::array<float,2>{0.598345101f, 0.0402359813f}, std::array<float,2>{0.939927578f, 0.558672845f}, std::array<float,2>{0.172383472f, 0.458608657f}, std::array<float,2>{0.0804190487f, 0.660974324f}, std::array<float,2>{0.767491162f, 0.272453666f}, std::array<float,2>{0.724770308f, 0.814031124f}, std::array<float,2>{0.257017374f, 0.215471417f}, std::array<float,2>{0.354272515f, 0.589432716f}, std::array<float,2>{0.662653208f, 0.405542284f}, std::array<float,2>{0.846511006f, 0.913895845f}, std::array<float,2>{0.0564602204f, 0.121749312f}, std::array<float,2>{0.205626443f, 0.770393729f}, std::array<float,2>{0.915755808f, 0.166362494f}, std::array<float,2>{0.509572566f, 0.744632483f}, std::array<float,2>{0.492780179f, 0.366280735f}, std::array<float,2>{0.405980468f, 0.778943777f}, std::array<float,2>{0.613506973f, 0.157153621f}, std::array<float,2>{0.958705604f, 0.736665845f}, std::array<float,2>{0.169676825f, 0.368036032f}, std::array<float,2>{0.0734835863f, 0.585382998f}, std::array<float,2>{0.753194451f, 0.392895371f}, std::array<float,2>{0.734619379f, 0.918498278f}, std::array<float,2>{0.265755564f, 0.113915555f}, std::array<float,2>{0.36167562f, 0.669611752f}, std::array<float,2>{0.676344097f, 0.277254999f}, std::array<float,2>{0.865169644f, 0.82096678f}, std::array<float,2>{0.0384238474f, 0.206785306f}, std::array<float,2>{0.19876416f, 0.996252716f}, std::array<float,2>{0.931950748f, 0.0374734811f}, std::array<float,2>{0.516627252f, 0.547351539f}, std::array<float,2>{0.474995673f, 0.464432478f}, std::array<float,2>{0.30529967f, 0.902602732f}, std::array<float,2>{0.705233634f, 0.0672708005f}, std::array<float,2>{0.795737207f, 0.600812972f}, std::array<float,2>{0.100361057f, 0.417465895f}, std::array<float,2>{0.134860262f, 0.694823086f}, std::array<float,2>{0.975465178f, 0.325906932f}, std::array<float,2>{0.582380056f, 0.793346584f}, std::array<float,2>{0.420962065f, 0.13692677f}, std::array<float,2>{0.462299228f, 0.503693879f}, std::array<float,2>{0.560991228f, 0.486041844f}, std::array<float,2>{0.893957734f, 0.945813656f}, std::array<float,2>{0.242177978f, 0.0293587334f}, std::array<float,2>{0.030626867f, 0.873350561f}, std::array<float,2>{0.817261636f, 0.222623512f}, std::array<float,2>{0.649861872f, 0.633044899f}, std::array<float,2>{0.332767963f, 0.286857992f}, std::array<float,2>{0.326959878f, 0.842234373f}, std::array<float,2>{0.625262737f, 0.19348304f}, std::array<float,2>{0.838798225f, 0.681680083f}, std::array<float,2>{0.00729339151f, 0.26185295f}, std::array<float,2>{0.233273834f, 0.534092844f}, std::array<float,2>{0.877615809f, 0.443835258f}, std::array<float,2>{0.534923434f, 0.979539454f}, std::array<float,2>{0.450421274f, 0.0546697862f}, std::array<float,2>{0.432572663f, 0.730549097f}, std::array<float,2>{0.57514292f, 0.350457937f}, std::array<float,2>{0.99476546f, 0.764297128f}, std::array<float,2>{0.144738019f, 0.177033827f}, std::array<float,2>{0.114152871f, 0.926862121f}, std::array<float,2>{0.801759005f, 0.100080013f}, std::array<float,2>{0.690189481f, 0.576596975f}, std::array<float,2>{0.293357134f, 0.375976652f}, std::array<float,2>{0.496321619f, 0.966626167f}, std::array<float,2>{0.512036502f, 0.00381708657f}, std::array<float,2>{0.92016542f, 0.516104937f}, std::array<float,2>{0.207455084f, 0.478405863f}, std::array<float,2>{0.0619154423f, 0.643727541f}, std::array<float,2>{0.847747326f, 0.301975042f}, std::array<float,2>{0.656853795f, 0.848040402f}, std::array<float,2>{0.355493069f, 0.238774642f}, std::array<float,2>{0.253041059f, 0.622274399f}, std::array<float,2>{0.720412314f, 0.435212135f}, std::array<float,2>{0.773156703f, 0.88170898f}, std::array<float,2>{0.0832161829f, 0.083129935f}, std::array<float,2>{0.17725037f, 0.809876263f}, std::array<float,2>{0.941451728f, 0.154539704f}, std::array<float,2>{0.595532417f, 0.703380942f}, std::array<float,2>{0.387016982f, 0.340691358f}, std::array<float,2>{0.439113438f, 0.85757941f}, std::array<float,2>{0.543832362f, 0.243839264f}, std::array<float,2>{0.886741459f, 0.656211317f}, std::array<float,2>{0.225569069f, 0.308739394f}, std::array<float,2>{0.0119907688f, 0.529229641f}, std::array<float,2>{0.828632176f, 0.469853491f}, std::array<float,2>{0.635550499f, 0.956044137f}, std::array<float,2>{0.319265544f, 0.0121656619f}, std::array<float,2>{0.288840413f, 0.71523875f}, std::array<float,2>{0.700471759f, 0.32821238f}, std::array<float,2>{0.812123418f, 0.804047048f}, std::array<float,2>{0.122171022f, 0.146621227f}, std::array<float,2>{0.153058395f, 0.887075543f}, std::array<float,2>{0.987053692f, 0.0906333253f}, std::array<float,2>{0.565403163f, 0.612420142f}, std::array<float,2>{0.427049309f, 0.426202863f}, std::array<float,2>{0.349714011f, 0.969111145f}, std::array<float,2>{0.666494012f, 0.0554511994f}, std::array<float,2>{0.857327402f, 0.544358492f}, std::array<float,2>{0.048037827f, 0.44657737f}, std::array<float,2>{0.213778049f, 0.675662637f}, std::array<float,2>{0.910261214f, 0.256864011f}, std::array<float,2>{0.50353241f, 0.829127312f}, std::array<float,2>{0.488038093f, 0.196512967f}, std::array<float,2>{0.379993081f, 0.570219219f}, std::array<float,2>{0.603135109f, 0.383307517f}, std::array<float,2>{0.945506334f, 0.929703057f}, std::array<float,2>{0.184980735f, 0.101928234f}, std::array<float,2>{0.089577049f, 0.754421353f}, std::array<float,2>{0.776800573f, 0.1825753f}, std::array<float,2>{0.729620755f, 0.724348009f}, std::array<float,2>{0.262916178f, 0.354956567f}, std::array<float,2>{0.2775428f, 0.787388861f}, std::array<float,2>{0.74799484f, 0.129109412f}, std::array<float,2>{0.765153408f, 0.699424267f}, std::array<float,2>{0.067578651f, 0.319093525f}, std::array<float,2>{0.160035506f, 0.607596397f}, std::array<float,2>{0.962509274f, 0.412130564f}, std::array<float,2>{0.622997522f, 0.892901182f}, std::array<float,2>{0.39686358f, 0.0768947005f}, std::array<float,2>{0.480494499f, 0.627587795f}, std::array<float,2>{0.525887728f, 0.296204984f}, std::array<float,2>{0.927369595f, 0.867089689f}, std::array<float,2>{0.191804826f, 0.227992535f}, std::array<float,2>{0.0434516035f, 0.943893552f}, std::array<float,2>{0.873166203f, 0.0219417159f}, std::array<float,2>{0.680279553f, 0.511380553f}, std::array<float,2>{0.370534748f, 0.492984891f}, std::array<float,2>{0.413623273f, 0.909745932f}, std::array<float,2>{0.591871917f, 0.117482617f}, std::array<float,2>{0.98228246f, 0.590554118f}, std::array<float,2>{0.12754038f, 0.40222156f}, std::array<float,2>{0.10936591f, 0.74854207f}, std::array<float,2>{0.788062811f, 0.359661222f}, std::array<float,2>{0.716437578f, 0.767733037f}, std::array<float,2>{0.301213175f, 0.171808943f}, std::array<float,2>{0.336987197f, 0.555022776f}, std::array<float,2>{0.643104315f, 0.45377925f}, std::array<float,2>{0.826611161f, 0.991888821f}, std::array<float,2>{0.0224857721f, 0.0460524112f}, std::array<float,2>{0.24531433f, 0.818624735f}, std::array<float,2>{0.901433647f, 0.213521063f}, std::array<float,2>{0.551652312f, 0.657415152f}, std::array<float,2>{0.458275437f, 0.265950203f}, std::array<float,2>{0.434903204f, 0.862482488f}, std::array<float,2>{0.573967695f, 0.233684912f}, std::array<float,2>{0.996415496f, 0.630732f}, std::array<float,2>{0.142717481f, 0.289439559f}, std::array<float,2>{0.109754421f, 0.515018702f}, std::array<float,2>{0.800626457f, 0.496471494f}, std::array<float,2>{0.693416476f, 0.937712491f}, std::array<float,2>{0.289190054f, 0.0195184126f}, std::array<float,2>{0.322761416f, 0.698679745f}, std::array<float,2>{0.632073045f, 0.315458298f}, std::array<float,2>{0.84060812f, 0.784510076f}, std::array<float,2>{4.65709418e-05f, 0.1287435f}, std::array<float,2>{0.226916984f, 0.895791352f}, std::array<float,2>{0.881369174f, 0.0713513717f}, std::array<float,2>{0.535403609f, 0.602194309f}, std::array<float,2>{0.447490662f, 0.407583922f}, std::array<float,2>{0.257786691f, 0.986943424f}, std::array<float,2>{0.725209951f, 0.041861739f}, std::array<float,2>{0.766702235f, 0.561302602f}, std::array<float,2>{0.0806553513f, 0.460306048f}, std::array<float,2>{0.172203094f, 0.663380146f}, std::array<float,2>{0.940150678f, 0.27030921f}, std::array<float,2>{0.597935021f, 0.815765083f}, std::array<float,2>{0.38340044f, 0.218570888f}, std::array<float,2>{0.492256999f, 0.586623788f}, std::array<float,2>{0.508927166f, 0.403036356f}, std::array<float,2>{0.91524905f, 0.911055565f}, std::array<float,2>{0.2055372f, 0.123408221f}, std::array<float,2>{0.0560934544f, 0.772442698f}, std::array<float,2>{0.846017957f, 0.164162204f}, std::array<float,2>{0.662156224f, 0.74346751f}, std::array<float,2>{0.353699803f, 0.36362049f}, std::array<float,2>{0.364990115f, 0.800649583f}, std::array<float,2>{0.673812807f, 0.140955999f}, std::array<float,2>{0.862476289f, 0.711374462f}, std::array<float,2>{0.034324903f, 0.332737058f}, std::array<float,2>{0.199489772f, 0.613873243f}, std::array<float,2>{0.935969412f, 0.424955398f}, std::array<float,2>{0.522133648f, 0.88640362f}, std::array<float,2>{0.472638041f, 0.0878945887f}, std::array<float,2>{0.400485426f, 0.652016282f}, std::array<float,2>{0.610176861f, 0.305594236f}, std::array<float,2>{0.955020368f, 0.853993118f}, std::array<float,2>{0.16568248f, 0.248281136f}, std::array<float,2>{0.0751129016f, 0.958824277f}, std::array<float,2>{0.756365418f, 0.00792081095f}, std::array<float,2>{0.740886807f, 0.523506105f}, std::array<float,2>{0.269681275f, 0.474845976f}, std::array<float,2>{0.465630591f, 0.936196387f}, std::array<float,2>{0.555514574f, 0.108374104f}, std::array<float,2>{0.89577347f, 0.566277802f}, std::array<float,2>{0.23547855f, 0.386828512f}, std::array<float,2>{0.0265270341f, 0.720324457f}, std::array<float,2>{0.814841986f, 0.355782121f}, std::array<float,2>{0.653213501f, 0.753614187f}, std::array<float,2>{0.329997569f, 0.185597524f}, std::array<float,2>{0.309332669f, 0.541105747f}, std::array<float,2>{0.708294272f, 0.450154006f}, std::array<float,2>{0.792877555f, 0.973876417f}, std::array<float,2>{0.0964665711f, 0.0595910661f}, std::array<float,2>{0.140616432f, 0.835283518f}, std::array<float,2>{0.969691038f, 0.202306166f}, std::array<float,2>{0.581239164f, 0.679402351f}, std::array<float,2>{0.416550815f, 0.252039015f}, std::array<float,2>{0.478384852f, 0.761442363f}, std::array<float,2>{0.5301404f, 0.173162133f}, std::array<float,2>{0.922305286f, 0.729480922f}, std::array<float,2>{0.190420419f, 0.345162749f}, std::array<float,2>{0.0392670296f, 0.571051776f}, std::array<float,2>{0.86780113f, 0.381844848f}, std::array<float,2>{0.683955967f, 0.925477862f}, std::array<float,2>{0.371356755f, 0.0952112824f}, std::array<float,2>{0.276215076f, 0.684867859f}, std::array<float,2>{0.742409945f, 0.260892898f}, std::array<float,2>{0.758836985f, 0.836791456f}, std::array<float,2>{0.0643258318f, 0.188756779f}, std::array<float,2>{0.163221732f, 0.983656287f}, std::array<float,2>{0.966870308f, 0.0490773246f}, std::array<float,2>{0.620764434f, 0.537050068f}, std::array<float,2>{0.392642051f, 0.440360695f}, std::array<float,2>{0.340680033f, 0.878702223f}, std::array<float,2>{0.646525383f, 0.0802309811f}, std::array<float,2>{0.821358383f, 0.617300391f}, std::array<float,2>{0.0184756164f, 0.433312416f}, std::array<float,2>{0.246941254f, 0.710795283f}, std::array<float,2>{0.904820502f, 0.337997139f}, std::array<float,2>{0.547604799f, 0.80761838f}, std::array<float,2>{0.455736279f, 0.150822461f}, std::array<float,2>{0.406563699f, 0.521500289f}, std::array<float,2>{0.586585462f, 0.481292635f}, std::array<float,2>{0.979724407f, 0.961321056f}, std::array<float,2>{0.129775017f, 0.00445871288f}, std::array<float,2>{0.104603641f, 0.845463276f}, std::array<float,2>{0.781998336f, 0.235194445f}, std::array<float,2>{0.713516831f, 0.647575259f}, std::array<float,2>{0.298875421f, 0.299384803f}, std::array<float,2>{0.283458441f, 0.827389836f}, std::array<float,2>{0.697049499f, 0.208507583f}, std::array<float,2>{0.805731833f, 0.666116297f}, std::array<float,2>{0.118210115f, 0.280197918f}, std::array<float,2>{0.150174856f, 0.553698361f}, std::array<float,2>{0.991982698f, 0.466616929f}, std::array<float,2>{0.566910565f, 0.99537915f}, std::array<float,2>{0.423035085f, 0.0347298533f}, std::array<float,2>{0.443731517f, 0.738612175f}, std::array<float,2>{0.539203703f, 0.372246653f}, std::array<float,2>{0.882880569f, 0.773726404f}, std::array<float,2>{0.220884457f, 0.160873801f}, std::array<float,2>{0.00837633666f, 0.915375829f}, std::array<float,2>{0.835214376f, 0.110709623f}, std::array<float,2>{0.638447762f, 0.578561425f}, std::array<float,2>{0.313905209f, 0.395380557f}, std::array<float,2>{0.377083659f, 0.950912893f}, std::array<float,2>{0.608244956f, 0.0246934425f}, std::array<float,2>{0.950082898f, 0.505780995f}, std::array<float,2>{0.180998564f, 0.488942266f}, std::array<float,2>{0.0936926752f, 0.637114644f}, std::array<float,2>{0.780918837f, 0.284603655f}, std::array<float,2>{0.733985603f, 0.870696902f}, std::array<float,2>{0.261245191f, 0.224024624f}, std::array<float,2>{0.347075015f, 0.59436363f}, std::array<float,2>{0.668431163f, 0.421314955f}, std::array<float,2>{0.851842105f, 0.9008407f}, std::array<float,2>{0.0519385561f, 0.0648909062f}, std::array<float,2>{0.216168627f, 0.79064554f}, std::array<float,2>{0.9091416f, 0.133375317f}, std::array<float,2>{0.506891549f, 0.689225793f}, std::array<float,2>{0.489974171f, 0.323346943f}, std::array<float,2>{0.397284597f, 0.785383761f}, std::array<float,2>{0.622351646f, 0.13201949f}, std::array<float,2>{0.962081611f, 0.701234519f}, std::array<float,2>{0.159544215f, 0.316923231f}, std::array<float,2>{0.0681659579f, 0.605509937f}, std::array<float,2>{0.764656663f, 0.411351711f}, std::array<float,2>{0.747206032f, 0.890885413f}, std::array<float,2>{0.278244883f, 0.0754690692f}, std::array<float,2>{0.370920837f, 0.626655936f}, std::array<float,2>{0.679987133f, 0.293934256f}, std::array<float,2>{0.873564065f, 0.864048123f}, std::array<float,2>{0.043666359f, 0.228735551f}, std::array<float,2>{0.191922724f, 0.942487061f}, std::array<float,2>{0.926946223f, 0.0213090051f}, std::array<float,2>{0.525584757f, 0.508771181f}, std::array<float,2>{0.481023401f, 0.495700896f}, std::array<float,2>{0.301342815f, 0.906346977f}, std::array<float,2>{0.716154277f, 0.119549274f}, std::array<float,2>{0.787149191f, 0.593749881f}, std::array<float,2>{0.108719423f, 0.39915356f}, std::array<float,2>{0.127359524f, 0.746482015f}, std::array<float,2>{0.981682241f, 0.362523198f}, std::array<float,2>{0.592318118f, 0.766179681f}, std::array<float,2>{0.413393795f, 0.168233439f}, std::array<float,2>{0.458846271f, 0.557714462f}, std::array<float,2>{0.550984085f, 0.455233365f}, std::array<float,2>{0.901932955f, 0.989303648f}, std::array<float,2>{0.245985493f, 0.0437498912f}, std::array<float,2>{0.0234236624f, 0.816509187f}, std::array<float,2>{0.827013791f, 0.211566776f}, std::array<float,2>{0.642980158f, 0.65956825f}, std::array<float,2>{0.337807536f, 0.267911166f}, std::array<float,2>{0.318725318f, 0.855534554f}, std::array<float,2>{0.634845614f, 0.244716182f}, std::array<float,2>{0.828153968f, 0.652640224f}, std::array<float,2>{0.0123262014f, 0.310793668f}, std::array<float,2>{0.224923268f, 0.529489696f}, std::array<float,2>{0.887235463f, 0.472413719f}, std::array<float,2>{0.543381095f, 0.953283012f}, std::array<float,2>{0.438571036f, 0.0147293713f}, std::array<float,2>{0.427470654f, 0.718530238f}, std::array<float,2>{0.564531565f, 0.330478102f}, std::array<float,2>{0.986380517f, 0.802087069f}, std::array<float,2>{0.152489051f, 0.144984841f}, std::array<float,2>{0.122734696f, 0.888882279f}, std::array<float,2>{0.811899781f, 0.0918048918f}, std::array<float,2>{0.701112092f, 0.610049069f}, std::array<float,2>{0.288396269f, 0.429445505f}, std::array<float,2>{0.487331212f, 0.972392797f}, std::array<float,2>{0.503135085f, 0.0581240878f}, std::array<float,2>{0.910828829f, 0.544991314f}, std::array<float,2>{0.213244349f, 0.448333502f}, std::array<float,2>{0.0486672632f, 0.672374964f}, std::array<float,2>{0.856888592f, 0.254505575f}, std::array<float,2>{0.66651994f, 0.830432832f}, std::array<float,2>{0.350245386f, 0.197426066f}, std::array<float,2>{0.263376117f, 0.566771269f}, std::array<float,2>{0.73037076f, 0.384765983f}, std::array<float,2>{0.777144015f, 0.931872904f}, std::array<float,2>{0.0891217738f, 0.103843138f}, std::array<float,2>{0.185131267f, 0.75594002f}, std::array<float,2>{0.945833206f, 0.179734811f}, std::array<float,2>{0.602926314f, 0.724816918f}, std::array<float,2>{0.380484581f, 0.351599455f}, std::array<float,2>{0.450910926f, 0.841092348f}, std::array<float,2>{0.534508228f, 0.193352342f}, std::array<float,2>{0.877335906f, 0.681238472f}, std::array<float,2>{0.232800037f, 0.265502572f}, std::array<float,2>{0.00745793339f, 0.53131932f}, std::array<float,2>{0.838280201f, 0.442857057f}, std::array<float,2>{0.625822783f, 0.977896512f}, std::array<float,2>{0.326573581f, 0.051983051f}, std::array<float,2>{0.293880433f, 0.733472645f}, std::array<float,2>{0.689764857f, 0.348854274f}, std::array<float,2>{0.802473009f, 0.763165772f}, std::array<float,2>{0.113494866f, 0.178462565f}, std::array<float,2>{0.14524889f, 0.929112613f}, std::array<float,2>{0.994346678f, 0.0991394594f}, std::array<float,2>{0.574266911f, 0.574607432f}, std::array<float,2>{0.431859761f, 0.378212899f}, std::array<float,2>{0.356127799f, 0.967989624f}, std::array<float,2>{0.656417668f, 0.000169046209f}, std::array<float,2>{0.848543763f, 0.51909095f}, std::array<float,2>{0.0624896511f, 0.479787081f}, std::array<float,2>{0.207629532f, 0.640856743f}, std::array<float,2>{0.920443773f, 0.303278595f}, std::array<float,2>{0.512306631f, 0.85144496f}, std::array<float,2>{0.496977895f, 0.240342915f}, std::array<float,2>{0.387299329f, 0.624000609f}, std::array<float,2>{0.595087707f, 0.436943322f}, std::array<float,2>{0.942375362f, 0.880673945f}, std::array<float,2>{0.177082747f, 0.0845698863f}, std::array<float,2>{0.0836105421f, 0.810658038f}, std::array<float,2>{0.772755265f, 0.153324381f}, std::array<float,2>{0.720098019f, 0.705728769f}, std::array<float,2>{0.25350818f, 0.342103004f}, std::array<float,2>{0.266317129f, 0.780126452f}, std::array<float,2>{0.735224724f, 0.159121901f}, std::array<float,2>{0.753603816f, 0.735865712f}, std::array<float,2>{0.0738992169f, 0.369481087f}, std::array<float,2>{0.169118911f, 0.582532465f}, std::array<float,2>{0.958129227f, 0.390887141f}, std::array<float,2>{0.614050388f, 0.921428859f}, std::array<float,2>{0.405298352f, 0.11658553f}, std::array<float,2>{0.475472569f, 0.670599759f}, std::array<float,2>{0.517257631f, 0.274051517f}, std::array<float,2>{0.932240844f, 0.822862327f}, std::array<float,2>{0.198268279f, 0.203748494f}, std::array<float,2>{0.038582202f, 0.999626875f}, std::array<float,2>{0.864306867f, 0.0366216116f}, std::array<float,2>{0.67597419f, 0.5505597f}, std::array<float,2>{0.362200797f, 0.462084442f}, std::array<float,2>{0.421696544f, 0.905002773f}, std::array<float,2>{0.582973599f, 0.0688713118f}, std::array<float,2>{0.974710345f, 0.597954929f}, std::array<float,2>{0.135652259f, 0.414920866f}, std::array<float,2>{0.0997019783f, 0.692708552f}, std::array<float,2>{0.795091927f, 0.326726049f}, std::array<float,2>{0.706018984f, 0.795464516f}, std::array<float,2>{0.304807216f, 0.13961038f}, std::array<float,2>{0.332154453f, 0.501135886f}, std::array<float,2>{0.650370955f, 0.487110287f}, std::array<float,2>{0.816813648f, 0.949175775f}, std::array<float,2>{0.03107691f, 0.0277459398f}, std::array<float,2>{0.241650641f, 0.872740507f}, std::array<float,2>{0.894360185f, 0.220289931f}, std::array<float,2>{0.561074138f, 0.635004699f}, std::array<float,2>{0.462684393f, 0.287791789f}, std::array<float,2>{0.385166287f, 0.813661218f}, std::array<float,2>{0.600306213f, 0.215120539f}, std::array<float,2>{0.939129293f, 0.660352647f}, std::array<float,2>{0.174964458f, 0.271774918f}, std::array<float,2>{0.079677701f, 0.559326053f}, std::array<float,2>{0.769017518f, 0.458432287f}, std::array<float,2>{0.722729623f, 0.98462224f}, std::array<float,2>{0.25498423f, 0.0408877321f}, std::array<float,2>{0.352071375f, 0.744479418f}, std::array<float,2>{0.662030637f, 0.367133349f}, std::array<float,2>{0.844870985f, 0.769865394f}, std::array<float,2>{0.0572891496f, 0.166793898f}, std::array<float,2>{0.204388052f, 0.913372159f}, std::array<float,2>{0.916046441f, 0.121429063f}, std::array<float,2>{0.511031687f, 0.58927083f}, std::array<float,2>{0.495406181f, 0.406005323f}, std::array<float,2>{0.292727143f, 0.939823389f}, std::array<float,2>{0.693194687f, 0.0164075848f}, std::array<float,2>{0.79840076f, 0.512606204f}, std::array<float,2>{0.112871788f, 0.498751044f}, std::array<float,2>{0.14214921f, 0.631417274f}, std::array<float,2>{0.998314798f, 0.292859733f}, std::array<float,2>{0.5704633f, 0.860888839f}, std::array<float,2>{0.436018497f, 0.230488658f}, std::array<float,2>{0.446371257f, 0.604897738f}, std::array<float,2>{0.537562013f, 0.40984571f}, std::array<float,2>{0.879062057f, 0.897481501f}, std::array<float,2>{0.229595885f, 0.0731116459f}, std::array<float,2>{0.00245260284f, 0.783008277f}, std::array<float,2>{0.842989862f, 0.125803888f}, std::array<float,2>{0.629507005f, 0.695364654f}, std::array<float,2>{0.321254075f, 0.312594324f}, std::array<float,2>{0.331091166f, 0.751369536f}, std::array<float,2>{0.655984044f, 0.184755132f}, std::array<float,2>{0.814400792f, 0.72180897f}, std::array<float,2>{0.0243893676f, 0.358800471f}, std::array<float,2>{0.236776382f, 0.56331706f}, std::array<float,2>{0.896623313f, 0.389131755f}, std::array<float,2>{0.558391333f, 0.935212851f}, std::array<float,2>{0.467212021f, 0.10599412f}, std::array<float,2>{0.414168358f, 0.677278101f}, std::array<float,2>{0.578388512f, 0.251892835f}, std::array<float,2>{0.971913517f, 0.832913697f}, std::array<float,2>{0.136899918f, 0.200246662f}, std::array<float,2>{0.0937905014f, 0.975885987f}, std::array<float,2>{0.790141106f, 0.0620838478f}, std::array<float,2>{0.70999068f, 0.540707171f}, std::array<float,2>{0.310608923f, 0.452982157f}, std::array<float,2>{0.468859166f, 0.884758294f}, std::array<float,2>{0.51960206f, 0.086885348f}, std::array<float,2>{0.935413539f, 0.616894484f}, std::array<float,2>{0.202210218f, 0.422077745f}, std::array<float,2>{0.032065697f, 0.714248776f}, std::array<float,2>{0.859482646f, 0.334664404f}, std::array<float,2>{0.674031436f, 0.797872245f}, std::array<float,2>{0.366434783f, 0.142699197f}, std::array<float,2>{0.272196025f, 0.526818514f}, std::array<float,2>{0.738382101f, 0.473998755f}, std::array<float,2>{0.755304039f, 0.95909673f}, std::array<float,2>{0.0777859911f, 0.00993445795f}, std::array<float,2>{0.16759029f, 0.851597369f}, std::array<float,2>{0.956695497f, 0.247885227f}, std::array<float,2>{0.612324059f, 0.649445653f}, std::array<float,2>{0.400300711f, 0.306858748f}, std::array<float,2>{0.453623444f, 0.804728508f}, std::array<float,2>{0.550431013f, 0.149986789f}, std::array<float,2>{0.90401727f, 0.708501101f}, std::array<float,2>{0.248431414f, 0.336491674f}, std::array<float,2>{0.01642498f, 0.620072603f}, std::array<float,2>{0.82277447f, 0.430844337f}, std::array<float,2>{0.645206213f, 0.876282573f}, std::array<float,2>{0.343141258f, 0.0798662975f}, std::array<float,2>{0.29854086f, 0.644632101f}, std::array<float,2>{0.711424947f, 0.296933413f}, std::array<float,2>{0.784605205f, 0.845829725f}, std::array<float,2>{0.102162659f, 0.236539587f}, std::array<float,2>{0.132231459f, 0.964532137f}, std::array<float,2>{0.977120757f, 0.00727838976f}, std::array<float,2>{0.588061273f, 0.521141052f}, std::array<float,2>{0.408523083f, 0.483073652f}, std::array<float,2>{0.373397648f, 0.923512638f}, std::array<float,2>{0.686956823f, 0.0974674523f}, std::array<float,2>{0.870212197f, 0.572742581f}, std::array<float,2>{0.0429662094f, 0.379040718f}, std::array<float,2>{0.188591883f, 0.727199793f}, std::array<float,2>{0.925655603f, 0.347195536f}, std::array<float,2>{0.527805388f, 0.759284914f}, std::array<float,2>{0.480457872f, 0.175316706f}, std::array<float,2>{0.390738815f, 0.538699269f}, std::array<float,2>{0.617688298f, 0.437649578f}, std::array<float,2>{0.964885652f, 0.981116116f}, std::array<float,2>{0.16208005f, 0.0488024466f}, std::array<float,2>{0.0661819279f, 0.838831186f}, std::array<float,2>{0.760979593f, 0.189595729f}, std::array<float,2>{0.745612323f, 0.685707629f}, std::array<float,2>{0.274605453f, 0.257938743f}, std::array<float,2>{0.258820266f, 0.867325425f}, std::array<float,2>{0.731953621f, 0.224690929f}, std::array<float,2>{0.77840817f, 0.640551269f}, std::array<float,2>{0.0906326622f, 0.281464934f}, std::array<float,2>{0.18335703f, 0.505947173f}, std::array<float,2>{0.951572895f, 0.490628242f}, std::array<float,2>{0.606576562f, 0.951866448f}, std::array<float,2>{0.376937419f, 0.0260633379f}, std::array<float,2>{0.491232127f, 0.690645516f}, std::array<float,2>{0.50507313f, 0.320843965f}, std::array<float,2>{0.907351851f, 0.791077197f}, std::array<float,2>{0.21825774f, 0.135973021f}, std::array<float,2>{0.0537401475f, 0.899170995f}, std::array<float,2>{0.854211152f, 0.0628786907f}, std::array<float,2>{0.670770288f, 0.596064389f}, std::array<float,2>{0.343888938f, 0.419398218f}, std::array<float,2>{0.424379975f, 0.993010879f}, std::array<float,2>{0.569305658f, 0.0325559527f}, std::array<float,2>{0.989095688f, 0.552240252f}, std::array<float,2>{0.15123105f, 0.468719184f}, std::array<float,2>{0.120799452f, 0.664149106f}, std::array<float,2>{0.806911588f, 0.278638482f}, std::array<float,2>{0.6985237f, 0.825019121f}, std::array<float,2>{0.283064425f, 0.209319457f}, std::array<float,2>{0.315728635f, 0.58047235f}, std::array<float,2>{0.638733566f, 0.396694273f}, std::array<float,2>{0.832118392f, 0.916514874f}, std::array<float,2>{0.010717757f, 0.112589367f}, std::array<float,2>{0.219363108f, 0.775865614f}, std::array<float,2>{0.886201084f, 0.163502589f}, std::array<float,2>{0.542461336f, 0.740642726f}, std::array<float,2>{0.443012416f, 0.373316258f}, std::array<float,2>{0.410952538f, 0.768401384f}, std::array<float,2>{0.590873539f, 0.171018869f}, std::array<float,2>{0.984011173f, 0.7483055f}, std::array<float,2>{0.126204133f, 0.359954745f}, std::array<float,2>{0.10580641f, 0.590038896f}, std::array<float,2>{0.787058711f, 0.401489705f}, std::array<float,2>{0.718747973f, 0.909661055f}, std::array<float,2>{0.304518372f, 0.117764205f}, std::array<float,2>{0.338632315f, 0.657897711f}, std::array<float,2>{0.641450167f, 0.266585529f}, std::array<float,2>{0.825757146f, 0.819252729f}, std::array<float,2>{0.0204297341f, 0.213188037f}, std::array<float,2>{0.242976218f, 0.991266072f}, std::array<float,2>{0.898566008f, 0.0467512086f}, std::array<float,2>{0.55360353f, 0.555582345f}, std::array<float,2>{0.460808277f, 0.453307241f}, std::array<float,2>{0.279417098f, 0.893297851f}, std::array<float,2>{0.748588741f, 0.0764652416f}, std::array<float,2>{0.763385236f, 0.608303905f}, std::array<float,2>{0.0702528507f, 0.412805021f}, std::array<float,2>{0.157828271f, 0.700048864f}, std::array<float,2>{0.964182615f, 0.318501115f}, std::array<float,2>{0.623446286f, 0.787798285f}, std::array<float,2>{0.396165967f, 0.129402325f}, std::array<float,2>{0.484100878f, 0.511129022f}, std::array<float,2>{0.525052607f, 0.492656559f}, std::array<float,2>{0.928357363f, 0.943841815f}, std::array<float,2>{0.193477303f, 0.0219933689f}, std::array<float,2>{0.0450383276f, 0.866586089f}, std::array<float,2>{0.87151593f, 0.228136092f}, std::array<float,2>{0.682058394f, 0.627296865f}, std::array<float,2>{0.367582768f, 0.296498388f}, std::array<float,2>{0.349575579f, 0.829743266f}, std::array<float,2>{0.665132165f, 0.197063819f}, std::array<float,2>{0.85900569f, 0.675135911f}, std::array<float,2>{0.0498030186f, 0.257644415f}, std::array<float,2>{0.211161941f, 0.544490337f}, std::array<float,2>{0.912474513f, 0.447012991f}, std::array<float,2>{0.501008213f, 0.969461381f}, std::array<float,2>{0.486297101f, 0.0549251214f}, std::array<float,2>{0.381224632f, 0.723808646f}, std::array<float,2>{0.604375184f, 0.355233878f}, std::array<float,2>{0.947720528f, 0.75430572f}, std::array<float,2>{0.186226368f, 0.18189612f}, std::array<float,2>{0.0861159861f, 0.930523217f}, std::array<float,2>{0.774699926f, 0.102315895f}, std::array<float,2>{0.728013277f, 0.5697335f}, std::array<float,2>{0.264903784f, 0.382885486f}, std::array<float,2>{0.441009641f, 0.955379725f}, std::array<float,2>{0.546068072f, 0.0124696046f}, std::array<float,2>{0.890602112f, 0.5287323f}, std::array<float,2>{0.222961128f, 0.470361143f}, std::array<float,2>{0.0145290224f, 0.65566802f}, std::array<float,2>{0.830931067f, 0.309309036f}, std::array<float,2>{0.633654118f, 0.85823518f}, std::array<float,2>{0.317947984f, 0.243339419f}, std::array<float,2>{0.286827087f, 0.613219738f}, std::array<float,2>{0.701650023f, 0.426751941f}, std::array<float,2>{0.810505509f, 0.887312233f}, std::array<float,2>{0.124618322f, 0.0898522958f}, std::array<float,2>{0.155143172f, 0.8043136f}, std::array<float,2>{0.984452009f, 0.147360146f}, std::array<float,2>{0.562974393f, 0.715665519f}, std::array<float,2>{0.428588927f, 0.328701377f}, std::array<float,2>{0.498728901f, 0.848170817f}, std::array<float,2>{0.514950335f, 0.238640308f}, std::array<float,2>{0.918747544f, 0.644062042f}, std::array<float,2>{0.209675908f, 0.302565873f}, std::array<float,2>{0.0596758984f, 0.516128182f}, std::array<float,2>{0.849956691f, 0.477876335f}, std::array<float,2>{0.660117924f, 0.965857685f}, std::array<float,2>{0.358293086f, 0.00307745743f}, std::array<float,2>{0.250031769f, 0.70396167f}, std::array<float,2>{0.721049547f, 0.340115905f}, std::array<float,2>{0.770854592f, 0.810065389f}, std::array<float,2>{0.0845821649f, 0.155269429f}, std::array<float,2>{0.178486004f, 0.880942345f}, std::array<float,2>{0.944434643f, 0.0834986046f}, std::array<float,2>{0.597481251f, 0.622595251f}, std::array<float,2>{0.390011489f, 0.434954703f}, std::array<float,2>{0.325695664f, 0.98043859f}, std::array<float,2>{0.627988279f, 0.0540323891f}, std::array<float,2>{0.837070644f, 0.533410728f}, std::array<float,2>{0.00416932767f, 0.444033563f}, std::array<float,2>{0.230611533f, 0.68244499f}, std::array<float,2>{0.875272274f, 0.262377739f}, std::array<float,2>{0.532279253f, 0.842511892f}, std::array<float,2>{0.451361597f, 0.193874225f}, std::array<float,2>{0.430104673f, 0.576975822f}, std::array<float,2>{0.577055097f, 0.376625657f}, std::array<float,2>{0.993995428f, 0.927345872f}, std::array<float,2>{0.146493554f, 0.100277506f}, std::array<float,2>{0.117137991f, 0.763813019f}, std::array<float,2>{0.804620028f, 0.177466363f}, std::array<float,2>{0.688520432f, 0.731415629f}, std::array<float,2>{0.296508819f, 0.350015998f}, std::array<float,2>{0.307262689f, 0.793879151f}, std::array<float,2>{0.704521954f, 0.137487531f}, std::array<float,2>{0.794797719f, 0.695219755f}, std::array<float,2>{0.0987502113f, 0.32534349f}, std::array<float,2>{0.134065747f, 0.601180017f}, std::array<float,2>{0.97390908f, 0.417953908f}, std::array<float,2>{0.584391415f, 0.903011382f}, std::array<float,2>{0.418707132f, 0.0666323826f}, std::array<float,2>{0.464107096f, 0.633359492f}, std::array<float,2>{0.560079336f, 0.286135703f}, std::array<float,2>{0.891550004f, 0.87378186f}, std::array<float,2>{0.23939772f, 0.221949905f}, std::array<float,2>{0.0292278156f, 0.945623279f}, std::array<float,2>{0.819418132f, 0.0298630241f}, std::array<float,2>{0.65211302f, 0.503237128f}, std::array<float,2>{0.334234506f, 0.485687405f}, std::array<float,2>{0.402351588f, 0.918415904f}, std::array<float,2>{0.617109716f, 0.11345385f}, std::array<float,2>{0.960117519f, 0.585812807f}, std::array<float,2>{0.170922056f, 0.393364429f}, std::array<float,2>{0.0707706213f, 0.737270832f}, std::array<float,2>{0.751389563f, 0.367467761f}, std::array<float,2>{0.738068342f, 0.77865082f}, std::array<float,2>{0.269298732f, 0.156592742f}, std::array<float,2>{0.360130519f, 0.547446966f}, std::array<float,2>{0.678911984f, 0.46421814f}, std::array<float,2>{0.865611196f, 0.996984363f}, std::array<float,2>{0.0368964076f, 0.0378252566f}, std::array<float,2>{0.196368814f, 0.820683241f}, std::array<float,2>{0.930782318f, 0.206229985f}, std::array<float,2>{0.51775825f, 0.669364512f}, std::array<float,2>{0.47455129f, 0.276589364f}, std::array<float,2>{0.398948282f, 0.855033755f}, std::array<float,2>{0.611934781f, 0.249025166f}, std::array<float,2>{0.955199063f, 0.650580585f}, std::array<float,2>{0.166662425f, 0.305927694f}, std::array<float,2>{0.0770287588f, 0.525291145f}, std::array<float,2>{0.754369318f, 0.476544231f}, std::array<float,2>{0.739915609f, 0.95723331f}, std::array<float,2>{0.273107976f, 0.00892534014f}, std::array<float,2>{0.365698129f, 0.712466598f}, std::array<float,2>{0.674975574f, 0.333983272f}, std::array<float,2>{0.860525012f, 0.799517572f}, std::array<float,2>{0.0323596746f, 0.141856179f}, std::array<float,2>{0.201911986f, 0.884906828f}, std::array<float,2>{0.934107304f, 0.0897863209f}, std::array<float,2>{0.521068633f, 0.614954174f}, std::array<float,2>{0.469775915f, 0.42411238f}, std::array<float,2>{0.312205225f, 0.973005772f}, std::array<float,2>{0.709163547f, 0.0590748787f}, std::array<float,2>{0.789875269f, 0.542158306f}, std::array<float,2>{0.0948834866f, 0.451120675f}, std::array<float,2>{0.138196945f, 0.677782834f}, std::array<float,2>{0.970748782f, 0.253476232f}, std::array<float,2>{0.579330623f, 0.834783316f}, std::array<float,2>{0.415571928f, 0.202012554f}, std::array<float,2>{0.467798531f, 0.564701259f}, std::array<float,2>{0.556988537f, 0.387736738f}, std::array<float,2>{0.897583365f, 0.937430024f}, std::array<float,2>{0.2374219f, 0.10907083f}, std::array<float,2>{0.0251401775f, 0.752659261f}, std::array<float,2>{0.812536776f, 0.186527371f}, std::array<float,2>{0.654566288f, 0.719652474f}, std::array<float,2>{0.330572009f, 0.357119799f}, std::array<float,2>{0.321822822f, 0.783744216f}, std::array<float,2>{0.629950404f, 0.12748605f}, std::array<float,2>{0.842705131f, 0.697947264f}, std::array<float,2>{0.00317999674f, 0.314698637f}, std::array<float,2>{0.229391798f, 0.602913082f}, std::array<float,2>{0.880471647f, 0.40661037f}, std::array<float,2>{0.53897351f, 0.894581854f}, std::array<float,2>{0.44600752f, 0.070961453f}, std::array<float,2>{0.437035769f, 0.629324079f}, std::array<float,2>{0.571874022f, 0.290103137f}, std::array<float,2>{0.999075472f, 0.861589611f}, std::array<float,2>{0.140857831f, 0.233087167f}, std::array<float,2>{0.111783579f, 0.938701749f}, std::array<float,2>{0.796927869f, 0.0178311877f}, std::array<float,2>{0.691585481f, 0.513702512f}, std::array<float,2>{0.29170537f, 0.497902811f}, std::array<float,2>{0.494573742f, 0.91179651f}, std::array<float,2>{0.510733485f, 0.124448173f}, std::array<float,2>{0.917477965f, 0.587459505f}, std::array<float,2>{0.203476712f, 0.403808117f}, std::array<float,2>{0.0581548922f, 0.742411077f}, std::array<float,2>{0.844007075f, 0.36434117f}, std::array<float,2>{0.661031842f, 0.772674263f}, std::array<float,2>{0.352850527f, 0.16570577f}, std::array<float,2>{0.25469923f, 0.56161654f}, std::array<float,2>{0.724502444f, 0.459131628f}, std::array<float,2>{0.768128514f, 0.987408936f}, std::array<float,2>{0.0786182508f, 0.042538695f}, std::array<float,2>{0.174400732f, 0.81499958f}, std::array<float,2>{0.937602043f, 0.216939852f}, std::array<float,2>{0.601357698f, 0.662430525f}, std::array<float,2>{0.386427879f, 0.270546675f}, std::array<float,2>{0.44221431f, 0.774848342f}, std::array<float,2>{0.541956425f, 0.161365375f}, std::array<float,2>{0.885713816f, 0.739838183f}, std::array<float,2>{0.220216021f, 0.371566772f}, std::array<float,2>{0.0113577163f, 0.579187453f}, std::array<float,2>{0.833759665f, 0.39633128f}, std::array<float,2>{0.640606403f, 0.91484046f}, std::array<float,2>{0.314939737f, 0.109675363f}, std::array<float,2>{0.282116055f, 0.667621076f}, std::array<float,2>{0.698000491f, 0.280542552f}, std::array<float,2>{0.807942271f, 0.826490819f}, std::array<float,2>{0.119642474f, 0.207425669f}, std::array<float,2>{0.152249902f, 0.994685411f}, std::array<float,2>{0.989306688f, 0.0334448777f}, std::array<float,2>{0.569723189f, 0.55379194f}, std::array<float,2>{0.425632894f, 0.465749502f}, std::array<float,2>{0.345451683f, 0.901646316f}, std::array<float,2>{0.671708703f, 0.066326119f}, std::array<float,2>{0.855012715f, 0.594924629f}, std::array<float,2>{0.0535083003f, 0.420423329f}, std::array<float,2>{0.217717737f, 0.688036799f}, std::array<float,2>{0.90665108f, 0.322370887f}, std::array<float,2>{0.504778624f, 0.789231896f}, std::array<float,2>{0.490353525f, 0.134091228f}, std::array<float,2>{0.375040025f, 0.504584014f}, std::array<float,2>{0.605990469f, 0.489888459f}, std::array<float,2>{0.952682555f, 0.949933827f}, std::array<float,2>{0.181979612f, 0.0243427493f}, std::array<float,2>{0.0909060687f, 0.869813085f}, std::array<float,2>{0.777542949f, 0.223359317f}, std::array<float,2>{0.73104763f, 0.63838762f}, std::array<float,2>{0.258128017f, 0.283724785f}, std::array<float,2>{0.274096072f, 0.837011337f}, std::array<float,2>{0.744173467f, 0.187527746f}, std::array<float,2>{0.760019183f, 0.68401885f}, std::array<float,2>{0.0649147555f, 0.260560542f}, std::array<float,2>{0.160218582f, 0.535777509f}, std::array<float,2>{0.966464043f, 0.440680504f}, std::array<float,2>{0.61910969f, 0.982960284f}, std::array<float,2>{0.39188236f, 0.050488852f}, std::array<float,2>{0.478875816f, 0.729738832f}, std::array<float,2>{0.52879113f, 0.344057858f}, std::array<float,2>{0.923885405f, 0.760333717f}, std::array<float,2>{0.187802628f, 0.172606781f}, std::array<float,2>{0.0410389006f, 0.924528897f}, std::array<float,2>{0.869750798f, 0.0940210298f}, std::array<float,2>{0.685667694f, 0.57139653f}, std::array<float,2>{0.374745488f, 0.381558597f}, std::array<float,2>{0.410062134f, 0.962168872f}, std::array<float,2>{0.589743555f, 0.00572682824f}, std::array<float,2>{0.977992535f, 0.523436487f}, std::array<float,2>{0.131500259f, 0.481979489f}, std::array<float,2>{0.103148252f, 0.647278666f}, std::array<float,2>{0.783618033f, 0.299844533f}, std::array<float,2>{0.712582707f, 0.843854547f}, std::array<float,2>{0.296922088f, 0.236224279f}, std::array<float,2>{0.342378229f, 0.618726552f}, std::array<float,2>{0.645941436f, 0.432489932f}, std::array<float,2>{0.823313594f, 0.877453864f}, std::array<float,2>{0.0173686706f, 0.0818014145f}, std::array<float,2>{0.249624446f, 0.806668818f}, std::array<float,2>{0.902849019f, 0.152108461f}, std::array<float,2>{0.549048305f, 0.70929569f}, std::array<float,2>{0.454639465f, 0.339140534f}, std::array<float,2>{0.42912516f, 0.801063716f}, std::array<float,2>{0.563814461f, 0.146388888f}, std::array<float,2>{0.985840976f, 0.716887712f}, std::array<float,2>{0.155464828f, 0.3313196f}, std::array<float,2>{0.123882234f, 0.610855937f}, std::array<float,2>{0.808654845f, 0.427805841f}, std::array<float,2>{0.702697098f, 0.890408516f}, std::array<float,2>{0.285220832f, 0.09329734f}, std::array<float,2>{0.317285687f, 0.653652966f}, std::array<float,2>{0.634557784f, 0.312301666f}, std::array<float,2>{0.83149749f, 0.856558263f}, std::array<float,2>{0.0154928565f, 0.245782569f}, std::array<float,2>{0.224191844f, 0.954196751f}, std::array<float,2>{0.888774812f, 0.0143245216f}, std::array<float,2>{0.545466065f, 0.531011105f}, std::array<float,2>{0.439819723f, 0.470890433f}, std::array<float,2>{0.263966531f, 0.932807624f}, std::array<float,2>{0.727528334f, 0.105378129f}, std::array<float,2>{0.773457885f, 0.567871511f}, std::array<float,2>{0.0870598927f, 0.386498123f}, std::array<float,2>{0.186593592f, 0.726530492f}, std::array<float,2>{0.94903636f, 0.353037119f}, std::array<float,2>{0.604708314f, 0.757485092f}, std::array<float,2>{0.381964326f, 0.181407616f}, std::array<float,2>{0.484585881f, 0.545991004f}, std::array<float,2>{0.500098467f, 0.448050976f}, std::array<float,2>{0.913683712f, 0.971158326f}, std::array<float,2>{0.211951882f, 0.0568984151f}, std::array<float,2>{0.0501320027f, 0.831584394f}, std::array<float,2>{0.858241379f, 0.198741063f}, std::array<float,2>{0.664638877f, 0.67319864f}, std::array<float,2>{0.347779363f, 0.254987419f}, std::array<float,2>{0.368218392f, 0.864421785f}, std::array<float,2>{0.683120131f, 0.229842037f}, std::array<float,2>{0.872693121f, 0.625638247f}, std::array<float,2>{0.0461226925f, 0.294298768f}, std::array<float,2>{0.194862574f, 0.509305835f}, std::array<float,2>{0.92893523f, 0.494850457f}, std::array<float,2>{0.52431792f, 0.942364395f}, std::array<float,2>{0.482455969f, 0.02038729f}, std::array<float,2>{0.394942492f, 0.702849805f}, std::array<float,2>{0.624037087f, 0.318081051f}, std::array<float,2>{0.963323236f, 0.786501408f}, std::array<float,2>{0.157180652f, 0.131811529f}, std::array<float,2>{0.0689287633f, 0.892265499f}, std::array<float,2>{0.761780143f, 0.0749478042f}, std::array<float,2>{0.749609947f, 0.606668532f}, std::array<float,2>{0.280866355f, 0.410697252f}, std::array<float,2>{0.459952712f, 0.989005268f}, std::array<float,2>{0.553952932f, 0.0447551422f}, std::array<float,2>{0.90007174f, 0.556738436f}, std::array<float,2>{0.243676975f, 0.456534535f}, std::array<float,2>{0.021371549f, 0.658802152f}, std::array<float,2>{0.824891925f, 0.269306481f}, std::array<float,2>{0.64180088f, 0.817753017f}, std::array<float,2>{0.33911401f, 0.212677523f}, std::array<float,2>{0.303587198f, 0.592572093f}, std::array<float,2>{0.717395604f, 0.399499327f}, std::array<float,2>{0.785680294f, 0.907693624f}, std::array<float,2>{0.106631555f, 0.120570637f}, std::array<float,2>{0.125516981f, 0.766848266f}, std::array<float,2>{0.982650518f, 0.169343099f}, std::array<float,2>{0.590725005f, 0.747525632f}, std::array<float,2>{0.411724061f, 0.362195075f}, std::array<float,2>{0.473109007f, 0.82343328f}, std::array<float,2>{0.519161403f, 0.204298675f}, std::array<float,2>{0.930443168f, 0.671683371f}, std::array<float,2>{0.195952684f, 0.274422497f}, std::array<float,2>{0.0355343372f, 0.549257159f}, std::array<float,2>{0.866263509f, 0.461611658f}, std::array<float,2>{0.678223252f, 0.998232305f}, std::array<float,2>{0.360390961f, 0.0356768519f}, std::array<float,2>{0.268091679f, 0.735035717f}, std::array<float,2>{0.736918271f, 0.371001244f}, std::array<float,2>{0.750180781f, 0.781143248f}, std::array<float,2>{0.0717041641f, 0.16009374f}, std::array<float,2>{0.170890912f, 0.920302987f}, std::array<float,2>{0.959850013f, 0.11619892f}, std::array<float,2>{0.615725994f, 0.583529711f}, std::array<float,2>{0.40415293f, 0.39213562f}, std::array<float,2>{0.335785598f, 0.947508991f}, std::array<float,2>{0.651148498f, 0.0283562578f}, std::array<float,2>{0.818636715f, 0.500138581f}, std::array<float,2>{0.0274496563f, 0.487519115f}, std::array<float,2>{0.238595814f, 0.636713684f}, std::array<float,2>{0.892571867f, 0.28902927f}, std::array<float,2>{0.55935055f, 0.871654809f}, std::array<float,2>{0.463140607f, 0.219659358f}, std::array<float,2>{0.419158876f, 0.598677456f}, std::array<float,2>{0.585392416f, 0.415185541f}, std::array<float,2>{0.972848356f, 0.905853391f}, std::array<float,2>{0.133521497f, 0.0694709122f}, std::array<float,2>{0.0984888077f, 0.796401143f}, std::array<float,2>{0.793411314f, 0.13997671f}, std::array<float,2>{0.703439236f, 0.691682577f}, std::array<float,2>{0.307904959f, 0.327176929f}, std::array<float,2>{0.295809507f, 0.762160599f}, std::array<float,2>{0.68804729f, 0.179402307f}, std::array<float,2>{0.80295217f, 0.733283341f}, std::array<float,2>{0.115533948f, 0.348319978f}, std::array<float,2>{0.148034051f, 0.575607896f}, std::array<float,2>{0.992724776f, 0.377903014f}, std::array<float,2>{0.578052819f, 0.928565502f}, std::array<float,2>{0.431175113f, 0.0979187116f}, std::array<float,2>{0.452838928f, 0.680455446f}, std::array<float,2>{0.531693876f, 0.263763905f}, std::array<float,2>{0.876799762f, 0.840220094f}, std::array<float,2>{0.231528431f, 0.192118675f}, std::array<float,2>{0.00568123441f, 0.977223337f}, std::array<float,2>{0.836568177f, 0.0507828705f}, std::array<float,2>{0.627322912f, 0.532425642f}, std::array<float,2>{0.324389726f, 0.442122877f}, std::array<float,2>{0.389511406f, 0.879236102f}, std::array<float,2>{0.596421719f, 0.0852827579f}, std::array<float,2>{0.944006562f, 0.624709487f}, std::array<float,2>{0.178862706f, 0.436172992f}, std::array<float,2>{0.0852004588f, 0.706918001f}, std::array<float,2>{0.769671261f, 0.34366709f}, std::array<float,2>{0.721939266f, 0.81197226f}, std::array<float,2>{0.251512945f, 0.15243268f}, std::array<float,2>{0.358500719f, 0.518147171f}, std::array<float,2>{0.658566713f, 0.478964329f}, std::array<float,2>{0.85084188f, 0.967176199f}, std::array<float,2>{0.0595397502f, 0.00134706427f}, std::array<float,2>{0.209995806f, 0.849865079f}, std::array<float,2>{0.919130743f, 0.242157295f}, std::array<float,2>{0.513985872f, 0.641785324f}, std::array<float,2>{0.499516636f, 0.303754091f}, std::array<float,2>{0.417568773f, 0.833139956f}, std::array<float,2>{0.580828488f, 0.199865863f}, std::array<float,2>{0.970460355f, 0.676294506f}, std::array<float,2>{0.139077231f, 0.250479549f}, std::array<float,2>{0.0969912112f, 0.539368391f}, std::array<float,2>{0.791796029f, 0.451411813f}, std::array<float,2>{0.707693577f, 0.975185156f}, std::array<float,2>{0.309944838f, 0.0613415837f}, std::array<float,2>{0.329086572f, 0.72137624f}, std::array<float,2>{0.65374583f, 0.358317077f}, std::array<float,2>{0.815947354f, 0.750408351f}, std::array<float,2>{0.0258051325f, 0.184161022f}, std::array<float,2>{0.235350817f, 0.933662176f}, std::array<float,2>{0.894858837f, 0.107271805f}, std::array<float,2>{0.555897593f, 0.564082265f}, std::array<float,2>{0.465948015f, 0.390283883f}, std::array<float,2>{0.271449417f, 0.960149169f}, std::array<float,2>{0.741799772f, 0.0114228241f}, std::array<float,2>{0.757059216f, 0.526248574f}, std::array<float,2>{0.0760218278f, 0.472941637f}, std::array<float,2>{0.164414346f, 0.6492818f}, std::array<float,2>{0.953715682f, 0.308273464f}, std::array<float,2>{0.610383034f, 0.852672696f}, std::array<float,2>{0.401640654f, 0.246137783f}, std::array<float,2>{0.471585006f, 0.616130769f}, std::array<float,2>{0.523193538f, 0.423130244f}, std::array<float,2>{0.936822236f, 0.882912755f}, std::array<float,2>{0.200537592f, 0.0872243568f}, std::array<float,2>{0.0341355726f, 0.79712975f}, std::array<float,2>{0.862132668f, 0.143896654f}, std::array<float,2>{0.672424078f, 0.713332057f}, std::array<float,2>{0.364252985f, 0.335441262f}, std::array<float,2>{0.355139524f, 0.771211445f}, std::array<float,2>{0.663551986f, 0.167801484f}, std::array<float,2>{0.846771598f, 0.745537341f}, std::array<float,2>{0.0552212894f, 0.365847826f}, std::array<float,2>{0.206353486f, 0.588581324f}, std::array<float,2>{0.914818943f, 0.40501371f}, std::array<float,2>{0.507888794f, 0.912259161f}, std::array<float,2>{0.493932992f, 0.122521043f}, std::array<float,2>{0.383865207f, 0.661813021f}, std::array<float,2>{0.599466443f, 0.272614956f}, std::array<float,2>{0.940834224f, 0.812574625f}, std::array<float,2>{0.17321527f, 0.216541573f}, std::array<float,2>{0.0812852681f, 0.985512555f}, std::array<float,2>{0.766297877f, 0.0399381109f}, std::array<float,2>{0.725984275f, 0.559699476f}, std::array<float,2>{0.255871505f, 0.457853258f}, std::array<float,2>{0.448604137f, 0.896610379f}, std::array<float,2>{0.537092388f, 0.0733457804f}, std::array<float,2>{0.882657826f, 0.603625834f}, std::array<float,2>{0.228176236f, 0.408614427f}, std::array<float,2>{0.00130258664f, 0.696547866f}, std::array<float,2>{0.841375291f, 0.313951105f}, std::array<float,2>{0.630892813f, 0.781744301f}, std::array<float,2>{0.32411167f, 0.126381636f}, std::array<float,2>{0.290658146f, 0.51349777f}, std::array<float,2>{0.694948137f, 0.499703646f}, std::array<float,2>{0.799046814f, 0.941207767f}, std::array<float,2>{0.111126222f, 0.0174720604f}, std::array<float,2>{0.143812016f, 0.85974735f}, std::array<float,2>{0.997380018f, 0.232060879f}, std::array<float,2>{0.572434306f, 0.631971896f}, std::array<float,2>{0.434261739f, 0.291301101f}, std::array<float,2>{0.488445371f, 0.792529583f}, std::array<float,2>{0.506618977f, 0.135225788f}, std::array<float,2>{0.909687817f, 0.690203905f}, std::array<float,2>{0.21572943f, 0.321304768f}, std::array<float,2>{0.0514055677f, 0.597187161f}, std::array<float,2>{0.853117168f, 0.418791205f}, std::array<float,2>{0.669902146f, 0.899693489f}, std::array<float,2>{0.34589991f, 0.0635732785f}, std::array<float,2>{0.25984633f, 0.639278471f}, std::array<float,2>{0.733376324f, 0.283028603f}, std::array<float,2>{0.779304266f, 0.869059503f}, std::array<float,2>{0.0923987478f, 0.226494536f}, std::array<float,2>{0.180507809f, 0.953031182f}, std::array<float,2>{0.950934291f, 0.0264862943f}, std::array<float,2>{0.609125495f, 0.507335544f}, std::array<float,2>{0.378569365f, 0.491830647f}, std::array<float,2>{0.313349128f, 0.917873144f}, std::array<float,2>{0.636813343f, 0.111639388f}, std::array<float,2>{0.834525049f, 0.581956029f}, std::array<float,2>{0.0089543378f, 0.39761135f}, std::array<float,2>{0.222018734f, 0.741765559f}, std::array<float,2>{0.884742975f, 0.374852568f}, std::array<float,2>{0.540486455f, 0.776638269f}, std::array<float,2>{0.444605052f, 0.162785769f}, std::array<float,2>{0.422350019f, 0.551062107f}, std::array<float,2>{0.568338156f, 0.467619002f}, std::array<float,2>{0.99119848f, 0.993662238f}, std::array<float,2>{0.149389356f, 0.0314262807f}, std::array<float,2>{0.117746949f, 0.825339615f}, std::array<float,2>{0.805330455f, 0.210350454f}, std::array<float,2>{0.696243107f, 0.66589421f}, std::array<float,2>{0.284517199f, 0.27824834f}, std::array<float,2>{0.300039172f, 0.847056627f}, std::array<float,2>{0.714727879f, 0.238243565f}, std::array<float,2>{0.782840431f, 0.646002769f}, std::array<float,2>{0.104294091f, 0.298124999f}, std::array<float,2>{0.130171269f, 0.519610345f}, std::array<float,2>{0.979030788f, 0.483639985f}, std::array<float,2>{0.587014198f, 0.963846266f}, std::array<float,2>{0.407575607f, 0.00626713922f}, std::array<float,2>{0.456422418f, 0.70706749f}, std::array<float,2>{0.547931552f, 0.337802619f}, std::array<float,2>{0.905697703f, 0.806093395f}, std::array<float,2>{0.248029381f, 0.149106786f}, std::array<float,2>{0.0190595593f, 0.875291407f}, std::array<float,2>{0.821269572f, 0.0790501535f}, std::array<float,2>{0.647680163f, 0.62105906f}, std::array<float,2>{0.341414183f, 0.429931015f}, std::array<float,2>{0.394420922f, 0.982172489f}, std::array<float,2>{0.619151473f, 0.0472220443f}, std::array<float,2>{0.968529224f, 0.537393272f}, std::array<float,2>{0.162581339f, 0.439017802f}, std::array<float,2>{0.0627167076f, 0.687307477f}, std::array<float,2>{0.758537292f, 0.259755731f}, std::array<float,2>{0.743335366f, 0.839312494f}, std::array<float,2>{0.276584446f, 0.190504357f}, std::array<float,2>{0.372113019f, 0.573987842f}, std::array<float,2>{0.684902549f, 0.379902393f}, std::array<float,2>{0.868534207f, 0.922472656f}, std::array<float,2>{0.0404684357f, 0.0964252949f}, std::array<float,2>{0.190643772f, 0.757923961f}, std::array<float,2>{0.922960699f, 0.173900634f}, std::array<float,2>{0.530578554f, 0.728486776f}, std::array<float,2>{0.477538109f, 0.346610606f}, std::array<float,2>{0.379352778f, 0.755673587f}, std::array<float,2>{0.602239609f, 0.183388963f}, std::array<float,2>{0.947222173f, 0.723214924f}, std::array<float,2>{0.18387866f, 0.353798866f}, std::array<float,2>{0.0882273838f, 0.568683386f}, std::array<float,2>{0.776317716f, 0.383957446f}, std::array<float,2>{0.728612125f, 0.931393445f}, std::array<float,2>{0.262514174f, 0.103030786f}, std::array<float,2>{0.351499528f, 0.674268961f}, std::array<float,2>{0.667818069f, 0.255909622f}, std::array<float,2>{0.856256843f, 0.828385115f}, std::array<float,2>{0.04712734f, 0.195537314f}, std::array<float,2>{0.214315861f, 0.969863653f}, std::array<float,2>{0.911918581f, 0.0559158921f}, std::array<float,2>{0.502443373f, 0.543173671f}, std::array<float,2>{0.486959279f, 0.445887387f}, std::array<float,2>{0.287578642f, 0.887789667f}, std::array<float,2>{0.699478507f, 0.0909899324f}, std::array<float,2>{0.810788155f, 0.611488223f}, std::array<float,2>{0.121636696f, 0.427085042f}, std::array<float,2>{0.153897583f, 0.716065168f}, std::array<float,2>{0.987871945f, 0.32990396f}, std::array<float,2>{0.566285729f, 0.803172886f}, std::array<float,2>{0.42633006f, 0.148198888f}, std::array<float,2>{0.438127369f, 0.528185129f}, std::array<float,2>{0.544405639f, 0.469536424f}, std::array<float,2>{0.887698889f, 0.956947803f}, std::array<float,2>{0.22630173f, 0.0132665047f}, std::array<float,2>{0.0132395541f, 0.858768344f}, std::array<float,2>{0.829919398f, 0.242396116f}, std::array<float,2>{0.6359272f, 0.65456003f}, std::array<float,2>{0.319956869f, 0.309654057f}, std::array<float,2>{0.336167246f, 0.819654286f}, std::array<float,2>{0.644477665f, 0.214276865f}, std::array<float,2>{0.827743888f, 0.657167435f}, std::array<float,2>{0.0219235774f, 0.267023623f}, std::array<float,2>{0.24508287f, 0.555875778f}, std::array<float,2>{0.90098083f, 0.454327583f}, std::array<float,2>{0.5525617f, 0.990450084f}, std::array<float,2>{0.45796454f, 0.0450804234f}, std::array<float,2>{0.413069665f, 0.749570429f}, std::array<float,2>{0.593220294f, 0.360579461f}, std::array<float,2>{0.981055915f, 0.769072711f}, std::array<float,2>{0.128164127f, 0.170073733f}, std::array<float,2>{0.107933886f, 0.90838486f}, std::array<float,2>{0.788773835f, 0.119043991f}, std::array<float,2>{0.715599477f, 0.591663063f}, std::array<float,2>{0.301826984f, 0.400506973f}, std::array<float,2>{0.481981456f, 0.944431484f}, std::array<float,2>{0.527310431f, 0.0229677428f}, std::array<float,2>{0.926250577f, 0.510657847f}, std::array<float,2>{0.193048418f, 0.493914336f}, std::array<float,2>{0.0448804051f, 0.628578722f}, std::array<float,2>{0.874630451f, 0.295120925f}, std::array<float,2>{0.681318581f, 0.865495741f}, std::array<float,2>{0.369242191f, 0.227211401f}, std::array<float,2>{0.278449893f, 0.608460903f}, std::array<float,2>{0.747036338f, 0.413692564f}, std::array<float,2>{0.764108956f, 0.893739045f}, std::array<float,2>{0.0673556626f, 0.0780302286f}, std::array<float,2>{0.15865007f, 0.788824856f}, std::array<float,2>{0.961397231f, 0.13033019f}, std::array<float,2>{0.621894836f, 0.7010656f}, std::array<float,2>{0.397551209f, 0.319501787f}, std::array<float,2>{0.461590141f, 0.874398947f}, std::array<float,2>{0.562374532f, 0.221066758f}, std::array<float,2>{0.892933846f, 0.634490252f}, std::array<float,2>{0.240839899f, 0.285744607f}, std::array<float,2>{0.0300006699f, 0.50273174f}, std::array<float,2>{0.818049133f, 0.484770238f}, std::array<float,2>{0.649331391f, 0.947219431f}, std::array<float,2>{0.333305568f, 0.0303160623f}, std::array<float,2>{0.305882454f, 0.694013178f}, std::array<float,2>{0.706594169f, 0.324304253f}, std::array<float,2>{0.796379924f, 0.794761002f}, std::array<float,2>{0.101412095f, 0.138547391f}, std::array<float,2>{0.136530921f, 0.903963566f}, std::array<float,2>{0.976195693f, 0.0675817057f}, std::array<float,2>{0.58302784f, 0.600570738f}, std::array<float,2>{0.420343816f, 0.416980505f}, std::array<float,2>{0.362924755f, 0.997407317f}, std::array<float,2>{0.676855505f, 0.0381727628f}, std::array<float,2>{0.863423228f, 0.5481444f}, std::array<float,2>{0.0372209065f, 0.463565648f}, std::array<float,2>{0.197356254f, 0.668095112f}, std::array<float,2>{0.933237731f, 0.275512367f}, std::array<float,2>{0.515832007f, 0.821897924f}, std::array<float,2>{0.4762806f, 0.205232218f}, std::array<float,2>{0.404782087f, 0.584562361f}, std::array<float,2>{0.614943743f, 0.393989712f}, std::array<float,2>{0.957768679f, 0.919537306f}, std::array<float,2>{0.167992607f, 0.115189508f}, std::array<float,2>{0.0732236058f, 0.778184652f}, std::array<float,2>{0.752029479f, 0.157649606f}, std::array<float,2>{0.735848129f, 0.73737973f}, std::array<float,2>{0.266863078f, 0.368311882f}, std::array<float,2>{0.252587199f, 0.808692575f}, std::array<float,2>{0.719420075f, 0.155342937f}, std::array<float,2>{0.771606207f, 0.705016136f}, std::array<float,2>{0.0820452869f, 0.341472775f}, std::array<float,2>{0.175798655f, 0.621390045f}, std::array<float,2>{0.942923725f, 0.434277147f}, std::array<float,2>{0.594114482f, 0.88218528f}, std::array<float,2>{0.388018787f, 0.0829027966f}, std::array<float,2>{0.497853786f, 0.642679453f}, std::array<float,2>{0.513165355f, 0.301560014f}, std::array<float,2>{0.921655297f, 0.849584103f}, std::array<float,2>{0.20856522f, 0.23983252f}, std::array<float,2>{0.0610159673f, 0.965371072f}, std::array<float,2>{0.849409044f, 0.00257579167f}, std::array<float,2>{0.657726884f, 0.517558098f}, std::array<float,2>{0.356853217f, 0.477093786f}, std::array<float,2>{0.433052033f, 0.92609024f}, std::array<float,2>{0.575537324f, 0.100950196f}, std::array<float,2>{0.995535433f, 0.577787519f}, std::array<float,2>{0.145963982f, 0.375014901f}, std::array<float,2>{0.114807032f, 0.731453419f}, std::array<float,2>{0.800947964f, 0.350732684f}, std::array<float,2>{0.690980375f, 0.76500982f}, std::array<float,2>{0.2942518f, 0.176238477f}, std::array<float,2>{0.327413738f, 0.534912944f}, std::array<float,2>{0.626797855f, 0.445222437f}, std::array<float,2>{0.839492857f, 0.978855133f}, std::array<float,2>{0.00586049212f, 0.0533290841f}, std::array<float,2>{0.234214112f, 0.843461931f}, std::array<float,2>{0.878363609f, 0.194602385f}, std::array<float,2>{0.534135818f, 0.682679534f}, std::array<float,2>{0.449750692f, 0.262750655f}, std::array<float,2>{0.426845312f, 0.856715441f}, std::array<float,2>{0.565141618f, 0.246032476f}, std::array<float,2>{0.987115204f, 0.653375983f}, std::array<float,2>{0.153090373f, 0.31219551f}, std::array<float,2>{0.122458376f, 0.530915439f}, std::array<float,2>{0.812412858f, 0.471046418f}, std::array<float,2>{0.700404227f, 0.954437673f}, std::array<float,2>{0.288721323f, 0.0146147516f}, std::array<float,2>{0.319081455f, 0.717280805f}, std::array<float,2>{0.63536799f, 0.331158787f}, std::array<float,2>{0.828975797f, 0.800969243f}, std::array<float,2>{0.0118858591f, 0.14618884f}, std::array<float,2>{0.225152448f, 0.890350521f}, std::array<float,2>{0.887029946f, 0.0935789272f}, std::array<float,2>{0.543547988f, 0.611137211f}, std::array<float,2>{0.439280242f, 0.428020447f}, std::array<float,2>{0.263127506f, 0.970886528f}, std::array<float,2>{0.729802191f, 0.0568394996f}, std::array<float,2>{0.77659291f, 0.546328962f}, std::array<float,2>{0.0897878036f, 0.447755903f}, std::array<float,2>{0.184800386f, 0.673093855f}, std::array<float,2>{0.945766866f, 0.255351365f}, std::array<float,2>{0.603450239f, 0.831788361f}, std::array<float,2>{0.380246818f, 0.199046746f}, std::array<float,2>{0.487917036f, 0.568196833f}, std::array<float,2>{0.503869772f, 0.386365503f}, std::array<float,2>{0.910444677f, 0.932997882f}, std::array<float,2>{0.213517442f, 0.105165742f}, std::array<float,2>{0.048132617f, 0.757668972f}, std::array<float,2>{0.857145607f, 0.181211457f}, std::array<float,2>{0.666238725f, 0.726159275f}, std::array<float,2>{0.350012332f, 0.353351712f}, std::array<float,2>{0.370166093f, 0.786136389f}, std::array<float,2>{0.680421233f, 0.131427601f}, std::array<float,2>{0.873317778f, 0.702898562f}, std::array<float,2>{0.043098297f, 0.318182319f}, std::array<float,2>{0.191489562f, 0.606910765f}, std::array<float,2>{0.927615941f, 0.411125571f}, std::array<float,2>{0.526193678f, 0.892546535f}, std::array<float,2>{0.480732024f, 0.0750040412f}, std::array<float,2>{0.396585763f, 0.625815392f}, std::array<float,2>{0.622733474f, 0.2940301f}, std::array<float,2>{0.962753177f, 0.864662826f}, std::array<float,2>{0.159886286f, 0.229638025f}, std::array<float,2>{0.0677131414f, 0.942115307f}, std::array<float,2>{0.765473247f, 0.0201748051f}, std::array<float,2>{0.747648358f, 0.509741604f}, std::array<float,2>{0.277706653f, 0.495091707f}, std::array<float,2>{0.458060443f, 0.907318354f}, std::array<float,2>{0.551315904f, 0.120157026f}, std::array<float,2>{0.901637256f, 0.592310369f}, std::array<float,2>{0.245599732f, 0.399660081f}, std::array<float,2>{0.0227594059f, 0.747307837f}, std::array<float,2>{0.826368034f, 0.36201027f}, std::array<float,2>{0.643472135f, 0.766820371f}, std::array<float,2>{0.337333769f, 0.169176042f}, std::array<float,2>{0.300948411f, 0.55692631f}, std::array<float,2>{0.71671927f, 0.456262708f}, std::array<float,2>{0.787641764f, 0.989197731f}, std::array<float,2>{0.108951814f, 0.0446775146f}, std::array<float,2>{0.127840027f, 0.817589581f}, std::array<float,2>{0.982069433f, 0.212579027f}, std::array<float,2>{0.592150271f, 0.659061074f}, std::array<float,2>{0.413863361f, 0.269124657f}, std::array<float,2>{0.474691421f, 0.780841053f}, std::array<float,2>{0.51688993f, 0.159794122f}, std::array<float,2>{0.931776762f, 0.735216439f}, std::array<float,2>{0.198976249f, 0.370701849f}, std::array<float,2>{0.0383008122f, 0.583861351f}, std::array<float,2>{0.864771664f, 0.392397612f}, std::array<float,2>{0.67667377f, 0.920069873f}, std::array<float,2>{0.361342251f, 0.115856826f}, std::array<float,2>{0.266020894f, 0.671470761f}, std::array<float,2>{0.734516263f, 0.274772435f}, std::array<float,2>{0.75306344f, 0.823707998f}, std::array<float,2>{0.0736780465f, 0.204566896f}, std::array<float,2>{0.16987446f, 0.998462915f}, std::array<float,2>{0.958790481f, 0.0359734222f}, std::array<float,2>{0.613602817f, 0.548891246f}, std::array<float,2>{0.406218708f, 0.461739361f}, std::array<float,2>{0.332547814f, 0.906100154f}, std::array<float,2>{0.649578214f, 0.06973885f}, std::array<float,2>{0.817138076f, 0.598904371f}, std::array<float,2>{0.0304994788f, 0.415516406f}, std::array<float,2>{0.241851255f, 0.691495478f}, std::array<float,2>{0.893792868f, 0.327563584f}, std::array<float,2>{0.560565412f, 0.796633363f}, std::array<float,2>{0.461952746f, 0.139814094f}, std::array<float,2>{0.421359837f, 0.500274122f}, std::array<float,2>{0.582056463f, 0.487582356f}, std::array<float,2>{0.975221097f, 0.947688103f}, std::array<float,2>{0.135243267f, 0.0285752993f}, std::array<float,2>{0.100260757f, 0.871979475f}, std::array<float,2>{0.795653641f, 0.219411254f}, std::array<float,2>{0.70553565f, 0.636266172f}, std::array<float,2>{0.305506706f, 0.288665652f}, std::array<float,2>{0.293100834f, 0.839993298f}, std::array<float,2>{0.690033734f, 0.192168251f}, std::array<float,2>{0.802033484f, 0.680328488f}, std::array<float,2>{0.11377418f, 0.264091909f}, std::array<float,2>{0.144915432f, 0.532573044f}, std::array<float,2>{0.995022118f, 0.442176342f}, std::array<float,2>{0.574754417f, 0.977316022f}, std::array<float,2>{0.432323188f, 0.0511201322f}, std::array<float,2>{0.45067516f, 0.732988954f}, std::array<float,2>{0.534753442f, 0.348600268f}, std::array<float,2>{0.877799749f, 0.761953473f}, std::array<float,2>{0.232933402f, 0.179464787f}, std::array<float,2>{0.00695443712f, 0.928348899f}, std::array<float,2>{0.83851862f, 0.0978141353f}, std::array<float,2>{0.625197291f, 0.575208068f}, std::array<float,2>{0.326835871f, 0.377671152f}, std::array<float,2>{0.386758626f, 0.966845751f}, std::array<float,2>{0.595276892f, 0.00104215799f}, std::array<float,2>{0.941689491f, 0.518464386f}, std::array<float,2>{0.177566558f, 0.478624016f}, std::array<float,2>{0.0833874866f, 0.642056465f}, std::array<float,2>{0.773366392f, 0.304015487f}, std::array<float,2>{0.720670521f, 0.84972471f}, std::array<float,2>{0.253203303f, 0.241941437f}, std::array<float,2>{0.355771214f, 0.624951839f}, std::array<float,2>{0.657162249f, 0.436513811f}, std::array<float,2>{0.847941756f, 0.878979445f}, std::array<float,2>{0.0617368817f, 0.0849631578f}, std::array<float,2>{0.207193896f, 0.811765969f}, std::array<float,2>{0.920246303f, 0.152807042f}, std::array<float,2>{0.511838913f, 0.706685126f}, std::array<float,2>{0.496493042f, 0.343265712f}, std::array<float,2>{0.400990546f, 0.799804628f}, std::array<float,2>{0.609658122f, 0.141769126f}, std::array<float,2>{0.954310238f, 0.712765694f}, std::array<float,2>{0.165392488f, 0.333513319f}, std::array<float,2>{0.0743840784f, 0.615026057f}, std::array<float,2>{0.755968988f, 0.423936039f}, std::array<float,2>{0.740370691f, 0.885204256f}, std::array<float,2>{0.270400941f, 0.0895434618f}, std::array<float,2>{0.364637882f, 0.650684476f}, std::array<float,2>{0.673163414f, 0.305802137f}, std::array<float,2>{0.86317569f, 0.855425656f}, std::array<float,2>{0.0347638093f, 0.249510184f}, std::array<float,2>{0.199729756f, 0.957358003f}, std::array<float,2>{0.936258197f, 0.00921436958f}, std::array<float,2>{0.521865666f, 0.525039673f}, std::array<float,2>{0.471795678f, 0.476198107f}, std::array<float,2>{0.308734357f, 0.937086463f}, std::array<float,2>{0.708525419f, 0.109205693f}, std::array<float,2>{0.792350113f, 0.564456463f}, std::array<float,2>{0.0957593396f, 0.388058394f}, std::array<float,2>{0.139744624f, 0.719419539f}, std::array<float,2>{0.96879673f, 0.357393473f}, std::array<float,2>{0.581922293f, 0.752881408f}, std::array<float,2>{0.416457683f, 0.186962366f}, std::array<float,2>{0.464908153f, 0.54240942f}, std::array<float,2>{0.554741502f, 0.45078212f}, std::array<float,2>{0.896321595f, 0.972875595f}, std::array<float,2>{0.236191779f, 0.0587468483f}, std::array<float,2>{0.0272912886f, 0.834631383f}, std::array<float,2>{0.815326035f, 0.201749042f}, std::array<float,2>{0.652533591f, 0.678077281f}, std::array<float,2>{0.329209059f, 0.253869593f}, std::array<float,2>{0.322539121f, 0.8613922f}, std::array<float,2>{0.63276577f, 0.233308956f}, std::array<float,2>{0.839992821f, 0.628965855f}, std::array<float,2>{0.000610792194f, 0.290496618f}, std::array<float,2>{0.227290317f, 0.514034688f}, std::array<float,2>{0.881076574f, 0.497559011f}, std::array<float,2>{0.535835326f, 0.938838363f}, std::array<float,2>{0.447960168f, 0.0175982397f}, std::array<float,2>{0.435403168f, 0.698157668f}, std::array<float,2>{0.573515594f, 0.314577997f}, std::array<float,2>{0.996864319f, 0.78396976f}, std::array<float,2>{0.143105134f, 0.12779206f}, std::array<float,2>{0.110082805f, 0.894854307f}, std::array<float,2>{0.800222576f, 0.0710584968f}, std::array<float,2>{0.694163501f, 0.602542996f}, std::array<float,2>{0.289803654f, 0.406287968f}, std::array<float,2>{0.492980242f, 0.987668753f}, std::array<float,2>{0.509333491f, 0.0429482721f}, std::array<float,2>{0.915962994f, 0.561855197f}, std::array<float,2>{0.206004322f, 0.459458113f}, std::array<float,2>{0.0561535917f, 0.662296414f}, std::array<float,2>{0.84627229f, 0.270793319f}, std::array<float,2>{0.66305995f, 0.815368056f}, std::array<float,2>{0.354237854f, 0.21707575f}, std::array<float,2>{0.257088453f, 0.587831557f}, std::array<float,2>{0.724956453f, 0.40351662f}, std::array<float,2>{0.767104506f, 0.911869347f}, std::array<float,2>{0.0801032931f, 0.124177642f}, std::array<float,2>{0.172723785f, 0.772876322f}, std::array<float,2>{0.939666688f, 0.166002288f}, std::array<float,2>{0.598529518f, 0.742491305f}, std::array<float,2>{0.382954061f, 0.364569187f}, std::array<float,2>{0.444077015f, 0.826262951f}, std::array<float,2>{0.539583802f, 0.207156822f}, std::array<float,2>{0.883632362f, 0.667945981f}, std::array<float,2>{0.221266717f, 0.280435175f}, std::array<float,2>{0.00802631304f, 0.55396229f}, std::array<float,2>{0.835693836f, 0.465404868f}, std::array<float,2>{0.638160229f, 0.99510181f}, std::array<float,2>{0.314347267f, 0.0335065909f}, std::array<float,2>{0.284129798f, 0.740087092f}, std::array<float,2>{0.696478903f, 0.371281832f}, std::array<float,2>{0.806356013f, 0.774632454f}, std::array<float,2>{0.118901432f, 0.161415264f}, std::array<float,2>{0.149791464f, 0.914597213f}, std::array<float,2>{0.991459131f, 0.109489195f}, std::array<float,2>{0.566801131f, 0.57948786f}, std::array<float,2>{0.423378915f, 0.396012247f}, std::array<float,2>{0.347414076f, 0.950170636f}, std::array<float,2>{0.668559968f, 0.0241433736f}, std::array<float,2>{0.85226053f, 0.504811823f}, std::array<float,2>{0.0522994027f, 0.4900814f}, std::array<float,2>{0.216782004f, 0.638537705f}, std::array<float,2>{0.908280849f, 0.284169495f}, std::array<float,2>{0.507411301f, 0.869918525f}, std::array<float,2>{0.489733696f, 0.2235239f}, std::array<float,2>{0.377540171f, 0.595036447f}, std::array<float,2>{0.607794106f, 0.420837492f}, std::array<float,2>{0.949533641f, 0.901590168f}, std::array<float,2>{0.181256667f, 0.065998584f}, std::array<float,2>{0.0928008854f, 0.789448798f}, std::array<float,2>{0.780733883f, 0.133796573f}, std::array<float,2>{0.733709455f, 0.688451111f}, std::array<float,2>{0.260932058f, 0.322661489f}, std::array<float,2>{0.275529206f, 0.760623872f}, std::array<float,2>{0.742749214f, 0.172666535f}, std::array<float,2>{0.759512126f, 0.729545951f}, std::array<float,2>{0.0637051016f, 0.343937725f}, std::array<float,2>{0.163692713f, 0.571582317f}, std::array<float,2>{0.967745185f, 0.381694943f}, std::array<float,2>{0.620303094f, 0.92468518f}, std::array<float,2>{0.39339301f, 0.0939459577f}, std::array<float,2>{0.477637798f, 0.683812082f}, std::array<float,2>{0.529298127f, 0.260366768f}, std::array<float,2>{0.922530055f, 0.837290645f}, std::array<float,2>{0.189557895f, 0.187933221f}, std::array<float,2>{0.0397377163f, 0.983300984f}, std::array<float,2>{0.867498219f, 0.0506579019f}, std::array<float,2>{0.684550703f, 0.535992742f}, std::array<float,2>{0.37197426f, 0.440616339f}, std::array<float,2>{0.407007694f, 0.877846599f}, std::array<float,2>{0.586069822f, 0.0815518573f}, std::array<float,2>{0.980170131f, 0.619083524f}, std::array<float,2>{0.128966734f, 0.432372242f}, std::array<float,2>{0.105209529f, 0.709097147f}, std::array<float,2>{0.781524956f, 0.338976741f}, std::array<float,2>{0.712948263f, 0.807012975f}, std::array<float,2>{0.299593717f, 0.151864514f}, std::array<float,2>{0.339953333f, 0.523038805f}, std::array<float,2>{0.647392392f, 0.482282043f}, std::array<float,2>{0.821973145f, 0.962119401f}, std::array<float,2>{0.0177558828f, 0.00540096499f}, std::array<float,2>{0.246164247f, 0.844087422f}, std::array<float,2>{0.90457958f, 0.236073762f}, std::array<float,2>{0.547181368f, 0.647118628f}, std::array<float,2>{0.45531258f, 0.300051242f}, std::array<float,2>{0.381394029f, 0.828191578f}, std::array<float,2>{0.603520036f, 0.195765138f}, std::array<float,2>{0.947835326f, 0.673856139f}, std::array<float,2>{0.185708284f, 0.256287873f}, std::array<float,2>{0.086803928f, 0.543436885f}, std::array<float,2>{0.775021136f, 0.446243972f}, std::array<float,2>{0.7281937f, 0.970204175f}, std::array<float,2>{0.265407562f, 0.0558401942f}, std::array<float,2>{0.349070996f, 0.723609209f}, std::array<float,2>{0.665683925f, 0.353719711f}, std::array<float,2>{0.8585127f, 0.755607963f}, std::array<float,2>{0.0492553301f, 0.183206975f}, std::array<float,2>{0.211665362f, 0.931482077f}, std::array<float,2>{0.912923217f, 0.103325434f}, std::array<float,2>{0.501483738f, 0.568477631f}, std::array<float,2>{0.485567659f, 0.384097457f}, std::array<float,2>{0.286359817f, 0.956604064f}, std::array<float,2>{0.701966882f, 0.0135846687f}, std::array<float,2>{0.809649169f, 0.528044224f}, std::array<float,2>{0.124182373f, 0.469283015f}, std::array<float,2>{0.154408425f, 0.654340088f}, std::array<float,2>{0.985338986f, 0.309991986f}, std::array<float,2>{0.563311994f, 0.858519256f}, std::array<float,2>{0.428077072f, 0.242608353f}, std::array<float,2>{0.440850884f, 0.611810446f}, std::array<float,2>{0.546662867f, 0.42693907f}, std::array<float,2>{0.88980943f, 0.887998641f}, std::array<float,2>{0.223366141f, 0.0910921246f}, std::array<float,2>{0.0137026226f, 0.802923799f}, std::array<float,2>{0.830358207f, 0.148099169f}, std::array<float,2>{0.633020341f, 0.715950191f}, std::array<float,2>{0.317564577f, 0.329806864f}, std::array<float,2>{0.337961555f, 0.769476712f}, std::array<float,2>{0.6409024f, 0.170292974f}, std::array<float,2>{0.825485528f, 0.74976629f}, std::array<float,2>{0.0196597576f, 0.360635906f}, std::array<float,2>{0.24244453f, 0.591421545f}, std::array<float,2>{0.899174213f, 0.400787175f}, std::array<float,2>{0.552927494f, 0.908499599f}, std::array<float,2>{0.460099638f, 0.118690029f}, std::array<float,2>{0.410207808f, 0.656858444f}, std::array<float,2>{0.591575146f, 0.266605198f}, std::array<float,2>{0.983398855f, 0.819453835f}, std::array<float,2>{0.126727849f, 0.213917136f}, std::array<float,2>{0.106405221f, 0.990701497f}, std::array<float,2>{0.786558211f, 0.0453686342f}, std::array<float,2>{0.717875659f, 0.556150079f}, std::array<float,2>{0.303809643f, 0.454529166f}, std::array<float,2>{0.483738899f, 0.893839896f}, std::array<float,2>{0.524465621f, 0.0778089315f}, std::array<float,2>{0.927764654f, 0.608779132f}, std::array<float,2>{0.194310725f, 0.414033234f}, std::array<float,2>{0.0456297174f, 0.700733244f}, std::array<float,2>{0.872049749f, 0.319632083f}, std::array<float,2>{0.682216525f, 0.788746059f}, std::array<float,2>{0.367954373f, 0.129943475f}, std::array<float,2>{0.280234337f, 0.510323703f}, std::array<float,2>{0.748408437f, 0.493852526f}, std::array<float,2>{0.762771189f, 0.9448089f}, std::array<float,2>{0.0696095005f, 0.0233096872f}, std::array<float,2>{0.157422364f, 0.865258336f}, std::array<float,2>{0.964386344f, 0.227360889f}, std::array<float,2>{0.623873115f, 0.628700256f}, std::array<float,2>{0.395680338f, 0.29519701f}, std::array<float,2>{0.464501381f, 0.794444203f}, std::array<float,2>{0.559746385f, 0.138425708f}, std::array<float,2>{0.891084552f, 0.694104433f}, std::array<float,2>{0.239845723f, 0.324491411f}, std::array<float,2>{0.0287363753f, 0.600280881f}, std::array<float,2>{0.820295513f, 0.416604012f}, std::array<float,2>{0.651441276f, 0.904116929f}, std::array<float,2>{0.33460182f, 0.067816034f}, std::array<float,2>{0.306880504f, 0.634631753f}, std::array<float,2>{0.704595327f, 0.285890371f}, std::array<float,2>{0.793968201f, 0.874166131f}, std::array<float,2>{0.0995323434f, 0.220806614f}, std::array<float,2>{0.134585604f, 0.946981966f}, std::array<float,2>{0.974471569f, 0.030656008f}, std::array<float,2>{0.584565282f, 0.502460837f}, std::array<float,2>{0.418256015f, 0.484531105f}, std::array<float,2>{0.359828234f, 0.919851959f}, std::array<float,2>{0.679212987f, 0.114982739f}, std::array<float,2>{0.866009295f, 0.584816456f}, std::array<float,2>{0.0362176038f, 0.393653899f}, std::array<float,2>{0.197214693f, 0.737644374f}, std::array<float,2>{0.931412935f, 0.368642926f}, std::array<float,2>{0.518075287f, 0.778048515f}, std::array<float,2>{0.473861963f, 0.157363176f}, std::array<float,2>{0.403131038f, 0.54796505f}, std::array<float,2>{0.616442919f, 0.463787287f}, std::array<float,2>{0.960527718f, 0.997260749f}, std::array<float,2>{0.171441883f, 0.0384694785f}, std::array<float,2>{0.0711093396f, 0.822107136f}, std::array<float,2>{0.751566112f, 0.205448046f}, std::array<float,2>{0.737356603f, 0.668250382f}, std::array<float,2>{0.268579215f, 0.275873244f}, std::array<float,2>{0.250927866f, 0.849364877f}, std::array<float,2>{0.721426368f, 0.240146473f}, std::array<float,2>{0.770999491f, 0.642871439f}, std::array<float,2>{0.0844154581f, 0.301393479f}, std::array<float,2>{0.177750021f, 0.517166257f}, std::array<float,2>{0.945215106f, 0.477513283f}, std::array<float,2>{0.596797943f, 0.96575141f}, std::array<float,2>{0.390188873f, 0.00275294832f}, std::array<float,2>{0.498188317f, 0.704818726f}, std::array<float,2>{0.51521337f, 0.341702729f}, std::array<float,2>{0.918089092f, 0.808954239f}, std::array<float,2>{0.209066406f, 0.155558854f}, std::array<float,2>{0.0601837076f, 0.881924808f}, std::array<float,2>{0.850247502f, 0.0827098265f}, std::array<float,2>{0.659283936f, 0.621289372f}, std::array<float,2>{0.357428432f, 0.434355795f}, std::array<float,2>{0.430265665f, 0.978522122f}, std::array<float,2>{0.57620877f, 0.0534764864f}, std::array<float,2>{0.993552923f, 0.534673154f}, std::array<float,2>{0.147268876f, 0.445042402f}, std::array<float,2>{0.116266102f, 0.683045566f}, std::array<float,2>{0.80373913f, 0.263035208f}, std::array<float,2>{0.689213693f, 0.843634367f}, std::array<float,2>{0.296070904f, 0.194377869f}, std::array<float,2>{0.325383455f, 0.578007817f}, std::array<float,2>{0.628888249f, 0.375355482f}, std::array<float,2>{0.837846756f, 0.92592442f}, std::array<float,2>{0.00475392397f, 0.100704186f}, std::array<float,2>{0.231114328f, 0.764847755f}, std::array<float,2>{0.875793278f, 0.175977334f}, std::array<float,2>{0.532843709f, 0.731852829f}, std::array<float,2>{0.452054888f, 0.351044148f}, std::array<float,2>{0.41493538f, 0.750160038f}, std::array<float,2>{0.578832209f, 0.184347302f}, std::array<float,2>{0.972410202f, 0.721547663f}, std::array<float,2>{0.137537777f, 0.357981086f}, std::array<float,2>{0.0944679752f, 0.564426899f}, std::array<float,2>{0.790683448f, 0.390423954f}, std::array<float,2>{0.710865796f, 0.93390882f}, std::array<float,2>{0.311522782f, 0.107149243f}, std::array<float,2>{0.331560493f, 0.67666769f}, std::array<float,2>{0.655725241f, 0.25016582f}, std::array<float,2>{0.813916385f, 0.833337784f}, std::array<float,2>{0.0237646773f, 0.200179398f}, std::array<float,2>{0.237169102f, 0.975388467f}, std::array<float,2>{0.897175908f, 0.0610900186f}, std::array<float,2>{0.557942092f, 0.53930074f}, std::array<float,2>{0.467584819f, 0.451416254f}, std::array<float,2>{0.2716389f, 0.883221865f}, std::array<float,2>{0.739221632f, 0.0869182125f}, std::array<float,2>{0.755705893f, 0.615826786f}, std::array<float,2>{0.0773420632f, 0.422981024f}, std::array<float,2>{0.167293504f, 0.712981701f}, std::array<float,2>{0.956208169f, 0.335035741f}, std::array<float,2>{0.613061786f, 0.79700315f}, std::array<float,2>{0.399444699f, 0.14371191f}, std::array<float,2>{0.469294608f, 0.525910378f}, std::array<float,2>{0.520195425f, 0.472843766f}, std::array<float,2>{0.934955239f, 0.960244358f}, std::array<float,2>{0.202827811f, 0.0116242478f}, std::array<float,2>{0.0317158476f, 0.852835178f}, std::array<float,2>{0.859906554f, 0.246392861f}, std::array<float,2>{0.674344838f, 0.648980856f}, std::array<float,2>{0.367164314f, 0.308493525f}, std::array<float,2>{0.352034301f, 0.812753141f}, std::array<float,2>{0.661375284f, 0.216585323f}, std::array<float,2>{0.845551729f, 0.662082016f}, std::array<float,2>{0.057105083f, 0.272797048f}, std::array<float,2>{0.204946026f, 0.559838593f}, std::array<float,2>{0.916944325f, 0.457639337f}, std::array<float,2>{0.511520386f, 0.985687912f}, std::array<float,2>{0.495754063f, 0.0396431684f}, std::array<float,2>{0.385419488f, 0.745191038f}, std::array<float,2>{0.599899948f, 0.366017997f}, std::array<float,2>{0.938885152f, 0.771273494f}, std::array<float,2>{0.17565462f, 0.167718843f}, std::array<float,2>{0.0791095942f, 0.91246897f}, std::array<float,2>{0.769352555f, 0.122084863f}, std::array<float,2>{0.723193407f, 0.588828027f}, std::array<float,2>{0.255664974f, 0.405032516f}, std::array<float,2>{0.44724068f, 0.940943062f}, std::array<float,2>{0.537890673f, 0.0172485691f}, std::array<float,2>{0.879791439f, 0.513354599f}, std::array<float,2>{0.230307773f, 0.499916732f}, std::array<float,2>{0.002296953f, 0.632202625f}, std::array<float,2>{0.84351182f, 0.291025639f}, std::array<float,2>{0.629050314f, 0.859601319f}, std::array<float,2>{0.320667893f, 0.232347444f}, std::array<float,2>{0.292474151f, 0.603896201f}, std::array<float,2>{0.692491651f, 0.408342242f}, std::array<float,2>{0.797989309f, 0.896861434f}, std::array<float,2>{0.112567335f, 0.0735147893f}, std::array<float,2>{0.14188914f, 0.782068253f}, std::array<float,2>{0.998840213f, 0.125993699f}, std::array<float,2>{0.571130991f, 0.69648695f}, std::array<float,2>{0.436048239f, 0.313588411f}, std::array<float,2>{0.492029071f, 0.868828833f}, std::array<float,2>{0.50554955f, 0.226310596f}, std::array<float,2>{0.908193052f, 0.639488399f}, std::array<float,2>{0.218289122f, 0.282734543f}, std::array<float,2>{0.0544329025f, 0.507713795f}, std::array<float,2>{0.853968441f, 0.492156476f}, std::array<float,2>{0.670057595f, 0.952657998f}, std::array<float,2>{0.344423473f, 0.0267154425f}, std::array<float,2>{0.259390503f, 0.690139234f}, std::array<float,2>{0.731698513f, 0.321738333f}, std::array<float,2>{0.77918154f, 0.79275322f}, std::array<float,2>{0.0898703709f, 0.134836718f}, std::array<float,2>{0.182872355f, 0.899580359f}, std::array<float,2>{0.951861203f, 0.0637301654f}, std::array<float,2>{0.607347131f, 0.597582459f}, std::array<float,2>{0.375999004f, 0.418671548f}, std::array<float,2>{0.315951198f, 0.994051695f}, std::array<float,2>{0.63930732f, 0.0316412225f}, std::array<float,2>{0.832983792f, 0.551009655f}, std::array<float,2>{0.0101194698f, 0.467376888f}, std::array<float,2>{0.219162986f, 0.665602803f}, std::array<float,2>{0.886580527f, 0.277940452f}, std::array<float,2>{0.542884767f, 0.825640619f}, std::array<float,2>{0.442530334f, 0.210024968f}, std::array<float,2>{0.42410171f, 0.581745088f}, std::array<float,2>{0.568785369f, 0.397764325f}, std::array<float,2>{0.988419473f, 0.917628706f}, std::array<float,2>{0.150465503f, 0.111396611f}, std::array<float,2>{0.120354675f, 0.776370943f}, std::array<float,2>{0.807308257f, 0.162887201f}, std::array<float,2>{0.698993504f, 0.741952062f}, std::array<float,2>{0.282706082f, 0.374713928f}, std::array<float,2>{0.298321784f, 0.805726647f}, std::array<float,2>{0.711795866f, 0.149243489f}, std::array<float,2>{0.784991562f, 0.707282603f}, std::array<float,2>{0.10185241f, 0.337442547f}, std::array<float,2>{0.132365078f, 0.620784223f}, std::array<float,2>{0.976615906f, 0.430026531f}, std::array<float,2>{0.588484228f, 0.875133157f}, std::array<float,2>{0.409088522f, 0.0788330808f}, std::array<float,2>{0.453561395f, 0.646443248f}, std::array<float,2>{0.54987222f, 0.297959745f}, std::array<float,2>{0.903772414f, 0.846766353f}, std::array<float,2>{0.248622298f, 0.237912908f}, std::array<float,2>{0.0157421175f, 0.963525057f}, std::array<float,2>{0.822423995f, 0.00591851771f}, std::array<float,2>{0.644958496f, 0.520005047f}, std::array<float,2>{0.34368062f, 0.483644247f}, std::array<float,2>{0.391357213f, 0.922840297f}, std::array<float,2>{0.617605805f, 0.0966167077f}, std::array<float,2>{0.965389967f, 0.573963821f}, std::array<float,2>{0.161335602f, 0.380204737f}, std::array<float,2>{0.0654303208f, 0.728118122f}, std::array<float,2>{0.761490464f, 0.346377045f}, std::array<float,2>{0.745396554f, 0.758221745f}, std::array<float,2>{0.275319576f, 0.174306765f}, std::array<float,2>{0.373892725f, 0.537116885f}, std::array<float,2>{0.687236845f, 0.439299017f}, std::array<float,2>{0.870657742f, 0.982350647f}, std::array<float,2>{0.0421062857f, 0.0469038524f}, std::array<float,2>{0.189382434f, 0.839034736f}, std::array<float,2>{0.925047755f, 0.190765977f}, std::array<float,2>{0.52811265f, 0.687105119f}, std::array<float,2>{0.479605436f, 0.259285808f}, std::array<float,2>{0.395483702f, 0.863883197f}, std::array<float,2>{0.624594688f, 0.228800505f}, std::array<float,2>{0.963486552f, 0.626744807f}, std::array<float,2>{0.156423792f, 0.293475419f}, std::array<float,2>{0.068730399f, 0.508359551f}, std::array<float,2>{0.762461841f, 0.49608928f}, std::array<float,2>{0.749292016f, 0.94286418f}, std::array<float,2>{0.280336559f, 0.0211066213f}, std::array<float,2>{0.369014859f, 0.701517105f}, std::array<float,2>{0.682940483f, 0.317239165f}, std::array<float,2>{0.872348905f, 0.785457432f}, std::array<float,2>{0.0467051938f, 0.132208198f}, std::array<float,2>{0.19460687f, 0.890643656f}, std::array<float,2>{0.92936182f, 0.075430125f}, std::array<float,2>{0.523646533f, 0.605751991f}, std::array<float,2>{0.483250409f, 0.411500812f}, std::array<float,2>{0.302797258f, 0.989693284f}, std::array<float,2>{0.71718961f, 0.0434936471f}, std::array<float,2>{0.785552323f, 0.557991922f}, std::array<float,2>{0.1072478f, 0.45540458f}, std::array<float,2>{0.125171497f, 0.659397721f}, std::array<float,2>{0.983223975f, 0.26776123f}, std::array<float,2>{0.590077937f, 0.816700697f}, std::array<float,2>{0.411453217f, 0.21169883f}, std::array<float,2>{0.45899421f, 0.593443751f}, std::array<float,2>{0.554586291f, 0.399345577f}, std::array<float,2>{0.899802983f, 0.906659186f}, std::array<float,2>{0.243394852f, 0.119149901f}, std::array<float,2>{0.0206396487f, 0.766546547f}, std::array<float,2>{0.824284375f, 0.168166235f}, std::array<float,2>{0.642452776f, 0.746326685f}, std::array<float,2>{0.339618564f, 0.36256364f}, std::array<float,2>{0.316705436f, 0.801922858f}, std::array<float,2>{0.63408047f, 0.144762516f}, std::array<float,2>{0.83192414f, 0.718294144f}, std::array<float,2>{0.0149632469f, 0.330177337f}, std::array<float,2>{0.223749205f, 0.610129178f}, std::array<float,2>{0.889503896f, 0.429428577f}, std::array<float,2>{0.545347273f, 0.889000058f}, std::array<float,2>{0.440192938f, 0.0921988785f}, std::array<float,2>{0.429679036f, 0.652478576f}, std::array<float,2>{0.564427614f, 0.310751796f}, std::array<float,2>{0.985823452f, 0.855765522f}, std::array<float,2>{0.155853286f, 0.244925708f}, std::array<float,2>{0.123099834f, 0.953581154f}, std::array<float,2>{0.80916065f, 0.0150241954f}, std::array<float,2>{0.702453673f, 0.529559255f}, std::array<float,2>{0.285814613f, 0.472366631f}, std::array<float,2>{0.48512736f, 0.93194145f}, std::array<float,2>{0.50077188f, 0.103753358f}, std::array<float,2>{0.91321975f, 0.566582084f}, std::array<float,2>{0.212704986f, 0.385111064f}, std::array<float,2>{0.0503021739f, 0.724955201f}, std::array<float,2>{0.857806027f, 0.352000773f}, std::array<float,2>{0.664523482f, 0.7562024f}, std::array<float,2>{0.348383427f, 0.179961577f}, std::array<float,2>{0.264337152f, 0.545269012f}, std::array<float,2>{0.726868272f, 0.44855395f}, std::array<float,2>{0.774099708f, 0.97254318f}, std::array<float,2>{0.0877190158f, 0.0583856963f}, std::array<float,2>{0.187331915f, 0.830218196f}, std::array<float,2>{0.948673308f, 0.19754754f}, std::array<float,2>{0.605111003f, 0.672649205f}, std::array<float,2>{0.382423699f, 0.254836023f}, std::array<float,2>{0.452250183f, 0.762845278f}, std::array<float,2>{0.531876683f, 0.178699389f}, std::array<float,2>{0.876074374f, 0.733673632f}, std::array<float,2>{0.232012749f, 0.349097401f}, std::array<float,2>{0.00502374023f, 0.574278951f}, std::array<float,2>{0.836325884f, 0.378102213f}, std::array<float,2>{0.627574146f, 0.928872108f}, std::array<float,2>{0.324907213f, 0.0994309634f}, std::array<float,2>{0.295032322f, 0.681439102f}, std::array<float,2>{0.687749982f, 0.265158027f}, std::array<float,2>{0.80330801f, 0.840918243f}, std::array<float,2>{0.116068006f, 0.193092898f}, std::array<float,2>{0.147474915f, 0.977556884f}, std::array<float,2>{0.992404938f, 0.0520928167f}, std::array<float,2>{0.577525914f, 0.53156209f}, std::array<float,2>{0.430915117f, 0.442426085f}, std::array<float,2>{0.359188527f, 0.880422711f}, std::array<float,2>{0.658829212f, 0.0848377571f}, std::array<float,2>{0.851099193f, 0.623576045f}, std::array<float,2>{0.058917705f, 0.436628014f}, std::array<float,2>{0.210776389f, 0.705889225f}, std::array<float,2>{0.919864714f, 0.34201932f}, std::array<float,2>{0.514506698f, 0.810812294f}, std::array<float,2>{0.499180526f, 0.15363355f}, std::array<float,2>{0.388986051f, 0.519394338f}, std::array<float,2>{0.595921695f, 0.479548514f}, std::array<float,2>{0.943466067f, 0.96823138f}, std::array<float,2>{0.179253861f, 0.000381717226f}, std::array<float,2>{0.0859122351f, 0.851234615f}, std::array<float,2>{0.770475745f, 0.240499422f}, std::array<float,2>{0.722425938f, 0.641049981f}, std::array<float,2>{0.25116688f, 0.303615928f}, std::array<float,2>{0.267645985f, 0.823104441f}, std::array<float,2>{0.736368775f, 0.203980893f}, std::array<float,2>{0.750831306f, 0.67072463f}, std::array<float,2>{0.0718821511f, 0.2743527f}, std::array<float,2>{0.170076355f, 0.550312579f}, std::array<float,2>{0.959430516f, 0.462254792f}, std::array<float,2>{0.61552f, 0.999863744f}, std::array<float,2>{0.403599143f, 0.0370328277f}, std::array<float,2>{0.473214865f, 0.736157775f}, std::array<float,2>{0.518971264f, 0.369349718f}, std::array<float,2>{0.929763675f, 0.779806674f}, std::array<float,2>{0.195415735f, 0.158877701f}, std::array<float,2>{0.0358537398f, 0.921796203f}, std::array<float,2>{0.866939127f, 0.116214834f}, std::array<float,2>{0.677949667f, 0.582878649f}, std::array<float,2>{0.360868424f, 0.390820146f}, std::array<float,2>{0.4195126f, 0.948965132f}, std::array<float,2>{0.585889459f, 0.0273634531f}, std::array<float,2>{0.973249316f, 0.501228094f}, std::array<float,2>{0.132933065f, 0.486971021f}, std::array<float,2>{0.0978096575f, 0.635249913f}, std::array<float,2>{0.79352963f, 0.288009971f}, std::array<float,2>{0.703644633f, 0.872878075f}, std::array<float,2>{0.308354616f, 0.220647633f}, std::array<float,2>{0.335370272f, 0.597676218f}, std::array<float,2>{0.650747597f, 0.414774179f}, std::array<float,2>{0.81916064f, 0.905194283f}, std::array<float,2>{0.0282349102f, 0.0691218898f}, std::array<float,2>{0.239201233f, 0.795846343f}, std::array<float,2>{0.892037094f, 0.139192909f}, std::array<float,2>{0.558877468f, 0.69244051f}, std::array<float,2>{0.463630646f, 0.326946527f}, std::array<float,2>{0.436720699f, 0.784326971f}, std::array<float,2>{0.571676552f, 0.128446728f}, std::array<float,2>{0.999578655f, 0.698250055f}, std::array<float,2>{0.141513661f, 0.315798491f}, std::array<float,2>{0.112299025f, 0.602392793f}, std::array<float,2>{0.797614455f, 0.407438874f}, std::array<float,2>{0.69217211f, 0.895696342f}, std::array<float,2>{0.291239172f, 0.0717325732f}, std::array<float,2>{0.321334124f, 0.630419672f}, std::array<float,2>{0.630481958f, 0.289199263f}, std::array<float,2>{0.84201628f, 0.862680435f}, std::array<float,2>{0.00382983452f, 0.233615398f}, std::array<float,2>{0.228759408f, 0.937871575f}, std::array<float,2>{0.880063832f, 0.0191791151f}, std::array<float,2>{0.538369536f, 0.514717758f}, std::array<float,2>{0.445565909f, 0.496299654f}, std::array<float,2>{0.254386753f, 0.91072768f}, std::array<float,2>{0.724031687f, 0.123211339f}, std::array<float,2>{0.767839789f, 0.586699307f}, std::array<float,2>{0.0783141628f, 0.403225183f}, std::array<float,2>{0.17394796f, 0.74340409f}, std::array<float,2>{0.938081622f, 0.363417953f}, std::array<float,2>{0.600736439f, 0.77216953f}, std::array<float,2>{0.385829031f, 0.164506838f}, std::array<float,2>{0.494907975f, 0.561092615f}, std::array<float,2>{0.510143697f, 0.460178465f}, std::array<float,2>{0.917657852f, 0.987225294f}, std::array<float,2>{0.203937903f, 0.0416217893f}, std::array<float,2>{0.0579147525f, 0.815539837f}, std::array<float,2>{0.844353676f, 0.218341425f}, std::array<float,2>{0.660196602f, 0.663114786f}, std::array<float,2>{0.353459895f, 0.270058334f}, std::array<float,2>{0.365832686f, 0.85361892f}, std::array<float,2>{0.675546288f, 0.248303533f}, std::array<float,2>{0.861180663f, 0.652248859f}, std::array<float,2>{0.0330201127f, 0.305219233f}, std::array<float,2>{0.201575547f, 0.523741186f}, std::array<float,2>{0.934049785f, 0.47502625f}, std::array<float,2>{0.520675659f, 0.958499253f}, std::array<float,2>{0.470404565f, 0.00815539621f}, std::array<float,2>{0.398823291f, 0.711040735f}, std::array<float,2>{0.611738801f, 0.332853496f}, std::array<float,2>{0.955711663f, 0.800393283f}, std::array<float,2>{0.166165039f, 0.14077881f}, std::array<float,2>{0.076208733f, 0.886525035f}, std::array<float,2>{0.754712939f, 0.0881382376f}, std::array<float,2>{0.73934114f, 0.614178121f}, std::array<float,2>{0.272734612f, 0.425136209f}, std::array<float,2>{0.468573362f, 0.973971009f}, std::array<float,2>{0.557214618f, 0.0599621534f}, std::array<float,2>{0.898433626f, 0.541436136f}, std::array<float,2>{0.238001198f, 0.449743658f}, std::array<float,2>{0.0246225838f, 0.679521263f}, std::array<float,2>{0.81331569f, 0.252387285f}, std::array<float,2>{0.654864311f, 0.835012853f}, std::array<float,2>{0.330292344f, 0.202455431f}, std::array<float,2>{0.311843842f, 0.566013455f}, std::array<float,2>{0.709717989f, 0.387204558f}, std::array<float,2>{0.789304495f, 0.936302185f}, std::array<float,2>{0.0955414996f, 0.107955143f}, std::array<float,2>{0.138026506f, 0.753802836f}, std::array<float,2>{0.971267462f, 0.185856745f}, std::array<float,2>{0.579625964f, 0.720495224f}, std::array<float,2>{0.41541642f, 0.355683982f}, std::array<float,2>{0.479415566f, 0.836595118f}, std::array<float,2>{0.528967798f, 0.188672036f}, std::array<float,2>{0.924503803f, 0.684638381f}, std::array<float,2>{0.188169792f, 0.261178732f}, std::array<float,2>{0.0416950732f, 0.53681314f}, std::array<float,2>{0.86938262f, 0.440035909f}, std::array<float,2>{0.686161041f, 0.983532906f}, std::array<float,2>{0.374086797f, 0.049000185f}, std::array<float,2>{0.273613036f, 0.729247212f}, std::array<float,2>{0.745091259f, 0.344939083f}, std::array<float,2>{0.760572195f, 0.761576533f}, std::array<float,2>{0.0653455183f, 0.172906414f}, std::array<float,2>{0.160853028f, 0.925753117f}, std::array<float,2>{0.966000736f, 0.0947791114f}, std::array<float,2>{0.618644536f, 0.571000397f}, std::array<float,2>{0.392491579f, 0.382210672f}, std::array<float,2>{0.341834277f, 0.960979223f}, std::array<float,2>{0.646159947f, 0.00476366561f}, std::array<float,2>{0.824152052f, 0.521963894f}, std::array<float,2>{0.0167356636f, 0.481019825f}, std::array<float,2>{0.249142498f, 0.647931278f}, std::array<float,2>{0.90237242f, 0.299614072f}, std::array<float,2>{0.549366951f, 0.845370591f}, std::array<float,2>{0.454460412f, 0.235049188f}, std::array<float,2>{0.409363329f, 0.617437005f}, std::array<float,2>{0.589274883f, 0.433440685f}, std::array<float,2>{0.978336394f, 0.878617585f}, std::array<float,2>{0.13097471f, 0.0803843886f}, std::array<float,2>{0.103016056f, 0.80808413f}, std::array<float,2>{0.78372848f, 0.150607005f}, std::array<float,2>{0.712319136f, 0.710658014f}, std::array<float,2>{0.297544032f, 0.338298142f}, std::array<float,2>{0.281681776f, 0.77351743f}, std::array<float,2>{0.697547734f, 0.161115885f}, std::array<float,2>{0.808367908f, 0.738405943f}, std::array<float,2>{0.119487956f, 0.372342348f}, std::array<float,2>{0.151819289f, 0.578293502f}, std::array<float,2>{0.989822865f, 0.395139694f}, std::array<float,2>{0.569895208f, 0.915242195f}, std::array<float,2>{0.424892992f, 0.110556364f}, std::array<float,2>{0.441468447f, 0.666396916f}, std::array<float,2>{0.541334033f, 0.279928952f}, std::array<float,2>{0.885230601f, 0.827407837f}, std::array<float,2>{0.220085219f, 0.208868146f}, std::array<float,2>{0.01106284f, 0.995273948f}, std::array<float,2>{0.833484352f, 0.035075102f}, std::array<float,2>{0.639980912f, 0.553453088f}, std::array<float,2>{0.315070629f, 0.466393054f}, std::array<float,2>{0.375618935f, 0.90050441f}, std::array<float,2>{0.605881155f, 0.0646582469f}, std::array<float,2>{0.952610791f, 0.594590843f}, std::array<float,2>{0.182603836f, 0.421043515f}, std::array<float,2>{0.0916456133f, 0.689171612f}, std::array<float,2>{0.778280854f, 0.32369107f}, std::array<float,2>{0.730838299f, 0.790884256f}, std::array<float,2>{0.258414954f, 0.133726269f}, std::array<float,2>{0.345183104f, 0.505594492f}, std::array<float,2>{0.671056926f, 0.489257127f}, std::array<float,2>{0.854614854f, 0.950934589f}, std::array<float,2>{0.0529371127f, 0.024631571f}, std::array<float,2>{0.216911867f, 0.870936096f}, std::array<float,2>{0.906882584f, 0.223758966f}, std::array<float,2>{0.504133403f, 0.636787772f}, std::array<float,2>{0.490935504f, 0.284210235f}, std::array<float,2>{0.412200838f, 0.818851888f}, std::array<float,2>{0.593491137f, 0.212902039f}, std::array<float,2>{0.980687022f, 0.658125818f}, std::array<float,2>{0.128698915f, 0.266140282f}, std::array<float,2>{0.107579015f, 0.555194855f}, std::array<float,2>{0.788384259f, 0.453471243f}, std::array<float,2>{0.7149809f, 0.991669714f}, std::array<float,2>{0.302426904f, 0.0465502478f}, std::array<float,2>{0.33650285f, 0.748211265f}, std::array<float,2>{0.643758476f, 0.360241503f}, std::array<float,2>{0.827553749f, 0.768278122f}, std::array<float,2>{0.0223970171f, 0.171240196f}, std::array<float,2>{0.244417906f, 0.909350216f}, std::array<float,2>{0.900728285f, 0.11796163f}, std::array<float,2>{0.551897824f, 0.590091944f}, std::array<float,2>{0.457346588f, 0.401629359f}, std::array<float,2>{0.278847903f, 0.943386555f}, std::array<float,2>{0.746422648f, 0.0224461276f}, std::array<float,2>{0.764216661f, 0.510892391f}, std::array<float,2>{0.0665290207f, 0.492420316f}, std::array<float,2>{0.158899426f, 0.627121985f}, std::array<float,2>{0.961443841f, 0.296867549f}, std::array<float,2>{0.621284246f, 0.866277874f}, std::array<float,2>{0.398101777f, 0.228327185f}, std::array<float,2>{0.48179698f, 0.608093679f}, std::array<float,2>{0.52662009f, 0.413080454f}, std::array<float,2>{0.926324129f, 0.893376827f}, std::array<float,2>{0.19254972f, 0.0761782676f}, std::array<float,2>{0.0444051474f, 0.788058877f}, std::array<float,2>{0.8743788f, 0.12978898f}, std::array<float,2>{0.681079209f, 0.699779153f}, std::array<float,2>{0.369704306f, 0.318679333f}, std::array<float,2>{0.350817144f, 0.754056752f}, std::array<float,2>{0.667405069f, 0.181822956f}, std::array<float,2>{0.855527401f, 0.723959386f}, std::array<float,2>{0.0474753641f, 0.35512045f}, std::array<float,2>{0.214520991f, 0.56941098f}, std::array<float,2>{0.911339164f, 0.383226156f}, std::array<float,2>{0.502139747f, 0.930414498f}, std::array<float,2>{0.486673862f, 0.10208644f}, std::array<float,2>{0.379554838f, 0.674993336f}, std::array<float,2>{0.601672232f, 0.257499129f}, std::array<float,2>{0.946310937f, 0.82990855f}, std::array<float,2>{0.184476793f, 0.196829766f}, std::array<float,2>{0.0888095722f, 0.969675839f}, std::array<float,2>{0.775471866f, 0.054945007f}, std::array<float,2>{0.729070365f, 0.544796407f}, std::array<float,2>{0.261816621f, 0.447251409f}, std::array<float,2>{0.437553823f, 0.88749826f}, std::array<float,2>{0.544774055f, 0.0901410505f}, std::array<float,2>{0.88832891f, 0.612887084f}, std::array<float,2>{0.225868568f, 0.426443368f}, std::array<float,2>{0.0128933135f, 0.715468109f}, std::array<float,2>{0.829569757f, 0.329078346f}, std::array<float,2>{0.636702299f, 0.804661632f}, std::array<float,2>{0.319356233f, 0.147120088f}, std::array<float,2>{0.287984639f, 0.528441668f}, std::array<float,2>{0.700186372f, 0.470501214f}, std::array<float,2>{0.811104715f, 0.95530206f}, std::array<float,2>{0.121265918f, 0.0122993691f}, std::array<float,2>{0.153598145f, 0.85804081f}, std::array<float,2>{0.987538338f, 0.243581638f}, std::array<float,2>{0.565539241f, 0.655454695f}, std::array<float,2>{0.426257879f, 0.309454471f}, std::array<float,2>{0.497478813f, 0.810492218f}, std::array<float,2>{0.513387501f, 0.15493004f}, std::array<float,2>{0.92120862f, 0.703828096f}, std::array<float,2>{0.208082065f, 0.339959621f}, std::array<float,2>{0.0614755228f, 0.622868717f}, std::array<float,2>{0.849085629f, 0.434747189f}, std::array<float,2>{0.657446623f, 0.881311953f}, std::array<float,2>{0.35715121f, 0.0838502571f}, std::array<float,2>{0.252431035f, 0.644527614f}, std::array<float,2>{0.718987107f, 0.302467436f}, std::array<float,2>{0.772316813f, 0.848442137f}, std::array<float,2>{0.0827998146f, 0.238385469f}, std::array<float,2>{0.176453263f, 0.966191947f}, std::array<float,2>{0.942405164f, 0.00322241383f}, std::array<float,2>{0.594351828f, 0.516548872f}, std::array<float,2>{0.388388872f, 0.477561325f}, std::array<float,2>{0.327671796f, 0.9275949f}, std::array<float,2>{0.626134396f, 0.100533985f}, std::array<float,2>{0.839326382f, 0.576835036f}, std::array<float,2>{0.00652248319f, 0.376873374f}, std::array<float,2>{0.233802766f, 0.731044054f}, std::array<float,2>{0.878660023f, 0.349822879f}, std::array<float,2>{0.533627629f, 0.763923585f}, std::array<float,2>{0.449528813f, 0.177537784f}, std::array<float,2>{0.433114916f, 0.533533037f}, std::array<float,2>{0.575791121f, 0.444288969f}, std::array<float,2>{0.995698392f, 0.980034709f}, std::array<float,2>{0.146140561f, 0.053876169f}, std::array<float,2>{0.114398688f, 0.842529953f}, std::array<float,2>{0.801353157f, 0.194299683f}, std::array<float,2>{0.69068408f, 0.682257414f}, std::array<float,2>{0.294575155f, 0.262613416f}, std::array<float,2>{0.306590647f, 0.873589456f}, std::array<float,2>{0.706441343f, 0.221920565f}, std::array<float,2>{0.796711326f, 0.633778453f}, std::array<float,2>{0.101018056f, 0.286470801f}, std::array<float,2>{0.135836318f, 0.503123343f}, std::array<float,2>{0.975848615f, 0.485439509f}, std::array<float,2>{0.583788335f, 0.94537884f}, std::array<float,2>{0.420761645f, 0.0302591287f}, std::array<float,2>{0.461111814f, 0.694862008f}, std::array<float,2>{0.561607659f, 0.325619161f}, std::array<float,2>{0.893128455f, 0.793694258f}, std::array<float,2>{0.240641326f, 0.137306973f}, std::array<float,2>{0.0296976846f, 0.903273523f}, std::array<float,2>{0.817678392f, 0.0666977316f}, std::array<float,2>{0.648777783f, 0.601403832f}, std::array<float,2>{0.333749473f, 0.417623073f}, std::array<float,2>{0.405028105f, 0.996703506f}, std::array<float,2>{0.614366949f, 0.0379928052f}, std::array<float,2>{0.957352638f, 0.547670841f}, std::array<float,2>{0.16877611f, 0.463914186f}, std::array<float,2>{0.0725876838f, 0.669021249f}, std::array<float,2>{0.752728164f, 0.276626289f}, std::array<float,2>{0.735510647f, 0.820393085f}, std::array<float,2>{0.267192274f, 0.206310377f}, std::array<float,2>{0.36246559f, 0.58568418f}, std::array<float,2>{0.677403808f, 0.393213779f}, std::array<float,2>{0.863932312f, 0.917982101f}, std::array<float,2>{0.0380633585f, 0.113586567f}, std::array<float,2>{0.197799221f, 0.778398931f}, std::array<float,2>{0.932937622f, 0.156466752f}, std::array<float,2>{0.516404867f, 0.736828864f}, std::array<float,2>{0.475817144f, 0.367336869f}, std::array<float,2>{0.384538889f, 0.76961112f}, std::array<float,2>{0.598764777f, 0.166551843f}, std::array<float,2>{0.941115737f, 0.744241416f}, std::array<float,2>{0.173715115f, 0.366794109f}, std::array<float,2>{0.0818772167f, 0.58887291f}, std::array<float,2>{0.765670478f, 0.406128734f}, std::array<float,2>{0.726163685f, 0.913197637f}, std::array<float,2>{0.256424457f, 0.121259779f}, std::array<float,2>{0.354592234f, 0.660537183f}, std::array<float,2>{0.664021611f, 0.271627188f}, std::array<float,2>{0.84746325f, 0.813782096f}, std::array<float,2>{0.0550211854f, 0.214983687f}, std::array<float,2>{0.206709385f, 0.984587967f}, std::array<float,2>{0.914241135f, 0.0405671038f}, std::array<float,2>{0.508546114f, 0.559375286f}, std::array<float,2>{0.493443549f, 0.458030343f}, std::array<float,2>{0.290203482f, 0.897909999f}, std::array<float,2>{0.694418907f, 0.0729010478f}, std::array<float,2>{0.799683213f, 0.604536116f}, std::array<float,2>{0.110802703f, 0.409968674f}, std::array<float,2>{0.144251212f, 0.695573509f}, std::array<float,2>{0.997930229f, 0.312799871f}, std::array<float,2>{0.572774649f, 0.782858014f}, std::array<float,2>{0.43385601f, 0.125623569f}, std::array<float,2>{0.448921591f, 0.512350619f}, std::array<float,2>{0.536278129f, 0.498872727f}, std::array<float,2>{0.882009506f, 0.939565063f}, std::array<float,2>{0.227746263f, 0.0163097531f}, std::array<float,2>{0.00189035281f, 0.861184835f}, std::array<float,2>{0.84094888f, 0.230925158f}, std::array<float,2>{0.631462097f, 0.631656647f}, std::array<float,2>{0.323392004f, 0.292480707f}, std::array<float,2>{0.32844159f, 0.832742393f}, std::array<float,2>{0.654063225f, 0.200502753f}, std::array<float,2>{0.815662086f, 0.677662969f}, std::array<float,2>{0.026230149f, 0.251607537f}, std::array<float,2>{0.23485966f, 0.540784955f}, std::array<float,2>{0.895278811f, 0.452752739f}, std::array<float,2>{0.556323469f, 0.975746095f}, std::array<float,2>{0.466447115f, 0.0624607243f}, std::array<float,2>{0.417373478f, 0.721960008f}, std::array<float,2>{0.580501318f, 0.358514756f}, std::array<float,2>{0.969885588f, 0.751140714f}, std::array<float,2>{0.13960509f, 0.184898779f}, std::array<float,2>{0.0976536348f, 0.935384691f}, std::array<float,2>{0.791042089f, 0.106231242f}, std::array<float,2>{0.707222819f, 0.563218236f}, std::array<float,2>{0.310305506f, 0.38886717f}, std::array<float,2>{0.471097976f, 0.959272325f}, std::array<float,2>{0.522848964f, 0.0100175152f}, std::array<float,2>{0.937465906f, 0.526386499f}, std::array<float,2>{0.201062351f, 0.473651588f}, std::array<float,2>{0.0335000902f, 0.649883747f}, std::array<float,2>{0.861422658f, 0.306988239f}, std::array<float,2>{0.672160268f, 0.851811111f}, std::array<float,2>{0.36330542f, 0.247737333f}, std::array<float,2>{0.270524561f, 0.616956592f}, std::array<float,2>{0.741499364f, 0.422352105f}, std::array<float,2>{0.757476926f, 0.884384453f}, std::array<float,2>{0.0752856135f, 0.0865098983f}, std::array<float,2>{0.164638638f, 0.798295438f}, std::array<float,2>{0.953445911f, 0.142982394f}, std::array<float,2>{0.611236751f, 0.7140522f}, std::array<float,2>{0.401912212f, 0.334770769f}, std::array<float,2>{0.456785679f, 0.845959127f}, std::array<float,2>{0.548774183f, 0.236742005f}, std::array<float,2>{0.906124949f, 0.645016372f}, std::array<float,2>{0.247216299f, 0.297121167f}, std::array<float,2>{0.0186332762f, 0.521455884f}, std::array<float,2>{0.820503414f, 0.483213782f}, std::array<float,2>{0.647969484f, 0.964614511f}, std::array<float,2>{0.341244221f, 0.00703766989f}, std::array<float,2>{0.300442606f, 0.708853126f}, std::array<float,2>{0.714171648f, 0.336683929f}, std::array<float,2>{0.782289684f, 0.805131078f}, std::array<float,2>{0.10378255f, 0.150175452f}, std::array<float,2>{0.130413309f, 0.876098931f}, std::array<float,2>{0.978906691f, 0.0796626657f}, std::array<float,2>{0.587666929f, 0.619848907f}, std::array<float,2>{0.408110738f, 0.430996746f}, std::array<float,2>{0.372881621f, 0.981215894f}, std::array<float,2>{0.685108542f, 0.0485782996f}, std::array<float,2>{0.86902684f, 0.538853586f}, std::array<float,2>{0.0409852378f, 0.437981874f}, std::array<float,2>{0.191103056f, 0.685959399f}, std::array<float,2>{0.923702836f, 0.25822252f}, std::array<float,2>{0.531000912f, 0.838466465f}, std::array<float,2>{0.476581991f, 0.189940855f}, std::array<float,2>{0.394038647f, 0.57244885f}, std::array<float,2>{0.619686127f, 0.379205346f}, std::array<float,2>{0.968229949f, 0.923694015f}, std::array<float,2>{0.163026437f, 0.0972186103f}, std::array<float,2>{0.0633258596f, 0.759691834f}, std::array<float,2>{0.758160889f, 0.175669417f}, std::array<float,2>{0.743734419f, 0.727475345f}, std::array<float,2>{0.276968956f, 0.347549707f}, std::array<float,2>{0.260632962f, 0.791410863f}, std::array<float,2>{0.732619941f, 0.136104107f}, std::array<float,2>{0.779884219f, 0.690717041f}, std::array<float,2>{0.0922437757f, 0.321078092f}, std::array<float,2>{0.180165425f, 0.595752835f}, std::array<float,2>{0.950308859f, 0.419149637f}, std::array<float,2>{0.608852983f, 0.898931324f}, std::array<float,2>{0.378378928f, 0.0626559779f}, std::array<float,2>{0.489046544f, 0.640266478f}, std::array<float,2>{0.505960226f, 0.281565964f}, std::array<float,2>{0.909430146f, 0.867456853f}, std::array<float,2>{0.215183735f, 0.225080028f}, std::array<float,2>{0.0512568913f, 0.952142835f}, std::array<float,2>{0.852584362f, 0.0261850972f}, std::array<float,2>{0.669379473f, 0.506190658f}, std::array<float,2>{0.346361876f, 0.490257144f}, std::array<float,2>{0.422562838f, 0.916755021f}, std::array<float,2>{0.567850173f, 0.112469055f}, std::array<float,2>{0.990312338f, 0.580261409f}, std::array<float,2>{0.148441046f, 0.396834403f}, std::array<float,2>{0.117510639f, 0.740338445f}, std::array<float,2>{0.8050403f, 0.373200983f}, std::array<float,2>{0.695531726f, 0.77555865f}, std::array<float,2>{0.28504777f, 0.16322124f}, std::array<float,2>{0.312905639f, 0.55196476f}, std::array<float,2>{0.637534022f, 0.468462765f}, std::array<float,2>{0.834197521f, 0.99291271f}, std::array<float,2>{0.00935503468f, 0.0322534032f}, std::array<float,2>{0.222379774f, 0.824861526f}, std::array<float,2>{0.883929372f, 0.209078386f}, std::array<float,2>{0.540908754f, 0.664360583f}, std::array<float,2>{0.445280045f, 0.278517634f}, std::array<float,2>{0.419933856f, 0.872077525f}, std::array<float,2>{0.583411694f, 0.220103204f}, std::array<float,2>{0.976506412f, 0.635271728f}, std::array<float,2>{0.136235133f, 0.287481606f}, std::array<float,2>{0.101267755f, 0.501594901f}, std::array<float,2>{0.795985937f, 0.486474723f}, std::array<float,2>{0.706806123f, 0.948436439f}, std::array<float,2>{0.306047618f, 0.027985448f}, std::array<float,2>{0.333037674f, 0.69289583f}, std::array<float,2>{0.649003327f, 0.326423645f}, std::array<float,2>{0.818323553f, 0.79513377f}, std::array<float,2>{0.0301029757f, 0.138700619f}, std::array<float,2>{0.24117361f, 0.904692948f}, std::array<float,2>{0.892600358f, 0.0684049651f}, std::array<float,2>{0.562230349f, 0.59847635f}, std::array<float,2>{0.461802751f, 0.414188385f}, std::array<float,2>{0.26676023f, 0.99917978f}, std::array<float,2>{0.736239433f, 0.0365125872f}, std::array<float,2>{0.752402008f, 0.550041258f}, std::array<float,2>{0.0729930103f, 0.46284011f}, std::array<float,2>{0.16844593f, 0.669926584f}, std::array<float,2>{0.957750201f, 0.273631871f}, std::array<float,2>{0.615014374f, 0.822633624f}, std::array<float,2>{0.404354304f, 0.203353375f}, std::array<float,2>{0.476449668f, 0.582190335f}, std::array<float,2>{0.515876174f, 0.391273677f}, std::array<float,2>{0.933466971f, 0.921081901f}, std::array<float,2>{0.197520509f, 0.117073998f}, std::array<float,2>{0.0375053585f, 0.779318631f}, std::array<float,2>{0.863580704f, 0.158409312f}, std::array<float,2>{0.677223861f, 0.735497594f}, std::array<float,2>{0.363264382f, 0.369916946f}, std::array<float,2>{0.356669188f, 0.811058462f}, std::array<float,2>{0.658103824f, 0.154146075f}, std::array<float,2>{0.849123538f, 0.705216348f}, std::array<float,2>{0.0607155599f, 0.342667818f}, std::array<float,2>{0.208855093f, 0.623430669f}, std::array<float,2>{0.921558678f, 0.437359065f}, std::array<float,2>{0.51282239f, 0.880126894f}, std::array<float,2>{0.497568905f, 0.0843525901f}, std::array<float,2>{0.387857497f, 0.641146302f}, std::array<float,2>{0.593793035f, 0.303152919f}, std::array<float,2>{0.943304002f, 0.851056755f}, std::array<float,2>{0.176166356f, 0.241048992f}, std::array<float,2>{0.0823335499f, 0.968306065f}, std::array<float,2>{0.771966517f, 0.000499712361f}, std::array<float,2>{0.719528794f, 0.518684864f}, std::array<float,2>{0.252854466f, 0.480051339f}, std::array<float,2>{0.450187355f, 0.929620385f}, std::array<float,2>{0.533837676f, 0.0988567024f}, std::array<float,2>{0.878109932f, 0.575158656f}, std::array<float,2>{0.233924493f, 0.378825456f}, std::array<float,2>{0.00622655917f, 0.734175324f}, std::array<float,2>{0.839832723f, 0.349382013f}, std::array<float,2>{0.626664639f, 0.763363779f}, std::array<float,2>{0.327299207f, 0.178221658f}, std::array<float,2>{0.294166505f, 0.532191157f}, std::array<float,2>{0.691368639f, 0.443079531f}, std::array<float,2>{0.801068723f, 0.978314519f}, std::array<float,2>{0.115207925f, 0.0525341071f}, std::array<float,2>{0.145549566f, 0.841652274f}, std::array<float,2>{0.995151758f, 0.192844719f}, std::array<float,2>{0.575293243f, 0.680742025f}, std::array<float,2>{0.432790965f, 0.264670312f}, std::array<float,2>{0.48713398f, 0.756800413f}, std::array<float,2>{0.502816021f, 0.180264443f}, std::array<float,2>{0.911757827f, 0.725534141f}, std::array<float,2>{0.21401459f, 0.352505326f}, std::array<float,2>{0.0470804572f, 0.567166507f}, std::array<float,2>{0.856018066f, 0.385393292f}, std::array<float,2>{0.667665422f, 0.932548523f}, std::array<float,2>{0.351182848f, 0.104015902f}, std::array<float,2>{0.262398154f, 0.672114134f}, std::array<float,2>{0.728810012f, 0.253922284f}, std::array<float,2>{0.775889218f, 0.831051886f}, std::array<float,2>{0.087978825f, 0.19806461f}, std::array<float,2>{0.183606818f, 0.971968055f}, std::array<float,2>{0.946840763f, 0.0578945689f}, std::array<float,2>{0.602394402f, 0.545432508f}, std::array<float,2>{0.378922731f, 0.449032396f}, std::array<float,2>{0.320281029f, 0.889206409f}, std::array<float,2>{0.636117816f, 0.0926540941f}, std::array<float,2>{0.829740226f, 0.609613538f}, std::array<float,2>{0.013431685f, 0.428760529f}, std::array<float,2>{0.226336971f, 0.718098342f}, std::array<float,2>{0.888167441f, 0.330669552f}, std::array<float,2>{0.544079542f, 0.802525878f}, std::array<float,2>{0.438449234f, 0.145396054f}, std::array<float,2>{0.426527292f, 0.530081868f}, std::array<float,2>{0.565995216f, 0.471871167f}, std::array<float,2>{0.988183677f, 0.953769505f}, std::array<float,2>{0.154075906f, 0.0152695794f}, std::array<float,2>{0.122020103f, 0.856199801f}, std::array<float,2>{0.810954928f, 0.244288951f}, std::array<float,2>{0.699288428f, 0.652952313f}, std::array<float,2>{0.287190288f, 0.311337322f}, std::array<float,2>{0.30205375f, 0.816899002f}, std::array<float,2>{0.715417206f, 0.211100787f}, std::array<float,2>{0.788841844f, 0.659972787f}, std::array<float,2>{0.108305089f, 0.268463641f}, std::array<float,2>{0.128248945f, 0.558215678f}, std::array<float,2>{0.981210351f, 0.45584169f}, std::array<float,2>{0.592986941f, 0.989897013f}, std::array<float,2>{0.412608236f, 0.0432427004f}, std::array<float,2>{0.457676172f, 0.747030318f}, std::array<float,2>{0.552435815f, 0.362836719f}, std::array<float,2>{0.9011935f, 0.765975177f}, std::array<float,2>{0.244730368f, 0.168833092f}, std::array<float,2>{0.0215433259f, 0.907008886f}, std::array<float,2>{0.828122854f, 0.119796984f}, std::array<float,2>{0.644228816f, 0.592827022f}, std::array<float,2>{0.336289823f, 0.398789138f}, std::array<float,2>{0.397709638f, 0.943271518f}, std::array<float,2>{0.621740937f, 0.0206059571f}, std::array<float,2>{0.961049139f, 0.508057058f}, std::array<float,2>{0.158241421f, 0.495462596f}, std::array<float,2>{0.0670877099f, 0.626090586f}, std::array<float,2>{0.763817847f, 0.293207794f}, std::array<float,2>{0.746701598f, 0.86361903f}, std::array<float,2>{0.278777629f, 0.229350567f}, std::array<float,2>{0.369435728f, 0.606182694f}, std::array<float,2>{0.681493163f, 0.412095457f}, std::array<float,2>{0.874961913f, 0.891430676f}, std::array<float,2>{0.0445710458f, 0.0758327171f}, std::array<float,2>{0.193268493f, 0.785918653f}, std::array<float,2>{0.925913692f, 0.132461205f}, std::array<float,2>{0.52708143f, 0.701910496f}, std::array<float,2>{0.482254952f, 0.316703349f}, std::array<float,2>{0.378850937f, 0.790362537f}, std::array<float,2>{0.60929817f, 0.133150533f}, std::array<float,2>{0.950847745f, 0.688808322f}, std::array<float,2>{0.180329844f, 0.323990017f}, std::array<float,2>{0.0927595124f, 0.593977332f}, std::array<float,2>{0.779599786f, 0.421773791f}, std::array<float,2>{0.733036339f, 0.900911033f}, std::array<float,2>{0.260038167f, 0.0653600097f}, std::array<float,2>{0.34596023f, 0.637474895f}, std::array<float,2>{0.669644296f, 0.285003364f}, std::array<float,2>{0.853298664f, 0.870144129f}, std::array<float,2>{0.051702641f, 0.224293664f}, std::array<float,2>{0.215467453f, 0.950615346f}, std::array<float,2>{0.910004735f, 0.0253311992f}, std::array<float,2>{0.506493688f, 0.505136013f}, std::array<float,2>{0.488569438f, 0.488592297f}, std::array<float,2>{0.28435412f, 0.915992975f}, std::array<float,2>{0.695970297f, 0.111323066f}, std::array<float,2>{0.805516303f, 0.578748703f}, std::array<float,2>{0.118159622f, 0.394839913f}, std::array<float,2>{0.149105087f, 0.738891602f}, std::array<float,2>{0.990936995f, 0.372927725f}, std::array<float,2>{0.568022966f, 0.774240851f}, std::array<float,2>{0.421923071f, 0.160282135f}, std::array<float,2>{0.444419831f, 0.553099215f}, std::array<float,2>{0.540240347f, 0.466087103f}, std::array<float,2>{0.884311795f, 0.995962739f}, std::array<float,2>{0.22183679f, 0.0342938006f}, std::array<float,2>{0.00921876077f, 0.828055143f}, std::array<float,2>{0.834930301f, 0.20814988f}, std::array<float,2>{0.637096047f, 0.666648507f}, std::array<float,2>{0.313166738f, 0.279772282f}, std::array<float,2>{0.341686338f, 0.845157564f}, std::array<float,2>{0.647707701f, 0.234700739f}, std::array<float,2>{0.820905149f, 0.648318231f}, std::array<float,2>{0.0193005335f, 0.299225658f}, std::array<float,2>{0.247725859f, 0.522096395f}, std::array<float,2>{0.905430079f, 0.480767787f}, std::array<float,2>{0.548226357f, 0.961511314f}, std::array<float,2>{0.456262678f, 0.00402234541f}, std::array<float,2>{0.407296509f, 0.710412204f}, std::array<float,2>{0.587177098f, 0.338664353f}, std::array<float,2>{0.979359806f, 0.808397233f}, std::array<float,2>{0.130084708f, 0.151096404f}, std::array<float,2>{0.104142703f, 0.878363371f}, std::array<float,2>{0.783084631f, 0.0808997154f}, std::array<float,2>{0.714408875f, 0.617765069f}, std::array<float,2>{0.300108135f, 0.433098316f}, std::array<float,2>{0.477068096f, 0.984155297f}, std::array<float,2>{0.530447662f, 0.0496076085f}, std::array<float,2>{0.923337042f, 0.536599576f}, std::array<float,2>{0.190737456f, 0.439623058f}, std::array<float,2>{0.0401771367f, 0.68516767f}, std::array<float,2>{0.868376851f, 0.261496931f}, std::array<float,2>{0.684608281f, 0.836395621f}, std::array<float,2>{0.372412354f, 0.189239398f}, std::array<float,2>{0.276786983f, 0.570713878f}, std::array<float,2>{0.743636131f, 0.382625997f}, std::array<float,2>{0.758632958f, 0.925279796f}, std::array<float,2>{0.0627870709f, 0.0956088901f}, std::array<float,2>{0.162148952f, 0.761007667f}, std::array<float,2>{0.968345046f, 0.173581287f}, std::array<float,2>{0.619593918f, 0.728726447f}, std::array<float,2>{0.394172728f, 0.345370144f}, std::array<float,2>{0.466295183f, 0.835538626f}, std::array<float,2>{0.555942178f, 0.202737167f}, std::array<float,2>{0.894737244f, 0.679136038f}, std::array<float,2>{0.234917507f, 0.252654701f}, std::array<float,2>{0.0254957452f, 0.541979313f}, std::array<float,2>{0.816356897f, 0.44939819f}, std::array<float,2>{0.653327286f, 0.974551439f}, std::array<float,2>{0.328748137f, 0.0603811257f}, std::array<float,2>{0.309755206f, 0.719750643f}, std::array<float,2>{0.70778352f, 0.356366664f}, std::array<float,2>{0.791657746f, 0.753152132f}, std::array<float,2>{0.0968813226f, 0.186362535f}, std::array<float,2>{0.138852268f, 0.935719788f}, std::array<float,2>{0.970386982f, 0.107521862f}, std::array<float,2>{0.580648661f, 0.565712094f}, std::array<float,2>{0.417814732f, 0.387681723f}, std::array<float,2>{0.3638677f, 0.958367467f}, std::array<float,2>{0.672669172f, 0.00855880231f}, std::array<float,2>{0.861994624f, 0.52400279f}, std::array<float,2>{0.0337983295f, 0.475464642f}, std::array<float,2>{0.200268283f, 0.651807368f}, std::array<float,2>{0.936646879f, 0.304824114f}, std::array<float,2>{0.523179293f, 0.854314268f}, std::array<float,2>{0.471391946f, 0.248763576f}, std::array<float,2>{0.401521415f, 0.613463342f}, std::array<float,2>{0.610830188f, 0.425327957f}, std::array<float,2>{0.954086781f, 0.886072099f}, std::array<float,2>{0.164293766f, 0.0887828469f}, std::array<float,2>{0.0757485256f, 0.799872816f}, std::array<float,2>{0.757156968f, 0.1415921f}, std::array<float,2>{0.74203974f, 0.711627245f}, std::array<float,2>{0.271071881f, 0.332484752f}, std::array<float,2>{0.256258428f, 0.771497309f}, std::array<float,2>{0.725681961f, 0.164926305f}, std::array<float,2>{0.766383648f, 0.743806303f}, std::array<float,2>{0.0813604817f, 0.364183217f}, std::array<float,2>{0.172996446f, 0.586212635f}, std::array<float,2>{0.940663278f, 0.402659357f}, std::array<float,2>{0.599287629f, 0.910583079f}, std::array<float,2>{0.384273887f, 0.123580821f}, std::array<float,2>{0.493735343f, 0.663799763f}, std::array<float,2>{0.508289993f, 0.269931853f}, std::array<float,2>{0.914775372f, 0.816318631f}, std::array<float,2>{0.206234574f, 0.217944741f}, std::array<float,2>{0.0555047505f, 0.986733556f}, std::array<float,2>{0.847056866f, 0.0414342284f}, std::array<float,2>{0.663156688f, 0.560804188f}, std::array<float,2>{0.355421662f, 0.460777789f}, std::array<float,2>{0.434372783f, 0.896062195f}, std::array<float,2>{0.57254988f, 0.072213009f}, std::array<float,2>{0.997193635f, 0.601745546f}, std::array<float,2>{0.143654704f, 0.407911032f}, std::array<float,2>{0.111079723f, 0.69918853f}, std::array<float,2>{0.799104631f, 0.316135466f}, std::array<float,2>{0.695127487f, 0.784860492f}, std::array<float,2>{0.290999144f, 0.128372103f}, std::array<float,2>{0.323840499f, 0.515574038f}, std::array<float,2>{0.631141484f, 0.49693644f}, std::array<float,2>{0.841667831f, 0.938059926f}, std::array<float,2>{0.00110281678f, 0.0187396072f}, std::array<float,2>{0.228273407f, 0.863012791f}, std::array<float,2>{0.882459581f, 0.234278783f}, std::array<float,2>{0.536785603f, 0.630215704f}, std::array<float,2>{0.448457181f, 0.28965956f}, std::array<float,2>{0.403850228f, 0.821119428f}, std::array<float,2>{0.616049588f, 0.206932425f}, std::array<float,2>{0.959491253f, 0.669883907f}, std::array<float,2>{0.170421645f, 0.277012438f}, std::array<float,2>{0.0713521168f, 0.547058225f}, std::array<float,2>{0.750264645f, 0.464781135f}, std::array<float,2>{0.737139404f, 0.996506035f}, std::array<float,2>{0.268391222f, 0.0371719673f}, std::array<float,2>{0.360772878f, 0.736353636f}, std::array<float,2>{0.678578973f, 0.367857426f}, std::array<float,2>{0.866500556f, 0.779286504f}, std::array<float,2>{0.0352348983f, 0.156892031f}, std::array<float,2>{0.196260929f, 0.918817222f}, std::array<float,2>{0.930194974f, 0.114161462f}, std::array<float,2>{0.519527614f, 0.585183978f}, std::array<float,2>{0.472798884f, 0.392803758f}, std::array<float,2>{0.307740539f, 0.946276903f}, std::array<float,2>{0.70328331f, 0.0296325218f}, std::array<float,2>{0.793164372f, 0.503532648f}, std::array<float,2>{0.0981710181f, 0.486188531f}, std::array<float,2>{0.133781075f, 0.633261919f}, std::array<float,2>{0.972926199f, 0.287059724f}, std::array<float,2>{0.585187674f, 0.873167634f}, std::array<float,2>{0.419396847f, 0.222269386f}, std::array<float,2>{0.463051766f, 0.600844145f}, std::array<float,2>{0.559138894f, 0.417102575f}, std::array<float,2>{0.892319024f, 0.902390778f}, std::array<float,2>{0.238449544f, 0.0669826642f}, std::array<float,2>{0.0277437046f, 0.793059766f}, std::array<float,2>{0.818405688f, 0.137015045f}, std::array<float,2>{0.650988877f, 0.694563568f}, std::array<float,2>{0.335508853f, 0.326089382f}, std::array<float,2>{0.324626237f, 0.764560223f}, std::array<float,2>{0.627174318f, 0.176790535f}, std::array<float,2>{0.836771131f, 0.730789721f}, std::array<float,2>{0.00560027594f, 0.350217074f}, std::array<float,2>{0.231794238f, 0.576222122f}, std::array<float,2>{0.876663864f, 0.376409501f}, std::array<float,2>{0.531464219f, 0.927006483f}, std::array<float,2>{0.452980399f, 0.0997619256f}, std::array<float,2>{0.431488425f, 0.681906581f}, std::array<float,2>{0.57777679f, 0.262063891f}, std::array<float,2>{0.993125081f, 0.841905534f}, std::array<float,2>{0.148386657f, 0.193780527f}, std::array<float,2>{0.115418859f, 0.979890764f}, std::array<float,2>{0.803109407f, 0.0542180315f}, std::array<float,2>{0.68833226f, 0.533851743f}, std::array<float,2>{0.295560122f, 0.443541914f}, std::array<float,2>{0.499906331f, 0.881572187f}, std::array<float,2>{0.513783097f, 0.083254829f}, std::array<float,2>{0.919336081f, 0.62250942f}, std::array<float,2>{0.210355565f, 0.435325772f}, std::array<float,2>{0.0591307245f, 0.703177154f}, std::array<float,2>{0.850624204f, 0.340334117f}, std::array<float,2>{0.658299327f, 0.809796393f}, std::array<float,2>{0.358645558f, 0.154650137f}, std::array<float,2>{0.251819074f, 0.51575768f}, std::array<float,2>{0.721751213f, 0.478130072f}, std::array<float,2>{0.769783556f, 0.966464639f}, std::array<float,2>{0.0853745714f, 0.00355182006f}, std::array<float,2>{0.178987816f, 0.847864091f}, std::array<float,2>{0.944268465f, 0.239051014f}, std::array<float,2>{0.596658349f, 0.644007206f}, std::array<float,2>{0.389361739f, 0.302236527f}, std::array<float,2>{0.439521819f, 0.803854823f}, std::array<float,2>{0.545661867f, 0.146860659f}, std::array<float,2>{0.889155984f, 0.714927852f}, std::array<float,2>{0.22459273f, 0.32847479f}, std::array<float,2>{0.015274819f, 0.61257565f}, std::array<float,2>{0.831136703f, 0.425888091f}, std::array<float,2>{0.63432318f, 0.886876345f}, std::array<float,2>{0.316961735f, 0.0904507264f}, std::array<float,2>{0.285637707f, 0.655798018f}, std::array<float,2>{0.702926457f, 0.308918417f}, std::array<float,2>{0.809001207f, 0.857863426f}, std::array<float,2>{0.123700388f, 0.243997052f}, std::array<float,2>{0.155529916f, 0.95577389f}, std::array<float,2>{0.986169636f, 0.0118106399f}, std::array<float,2>{0.563669801f, 0.528891563f}, std::array<float,2>{0.428821564f, 0.470187664f}, std::array<float,2>{0.347974271f, 0.93009001f}, std::array<float,2>{0.664858758f, 0.101579174f}, std::array<float,2>{0.857995391f, 0.569884717f}, std::array<float,2>{0.0500170216f, 0.383568734f}, std::array<float,2>{0.21237047f, 0.724568307f}, std::array<float,2>{0.913944542f, 0.354549438f}, std::array<float,2>{0.500466049f, 0.754640996f}, std::array<float,2>{0.484790325f, 0.182282835f}, std::array<float,2>{0.382080883f, 0.54417491f}, std::array<float,2>{0.604900837f, 0.446435571f}, std::array<float,2>{0.94880569f, 0.968832433f}, std::array<float,2>{0.186855763f, 0.0553635545f}, std::array<float,2>{0.0871851519f, 0.829432845f}, std::array<float,2>{0.773723364f, 0.196559891f}, std::array<float,2>{0.727122664f, 0.675403416f}, std::array<float,2>{0.26368323f, 0.257318765f}, std::array<float,2>{0.281145215f, 0.866869867f}, std::array<float,2>{0.749967992f, 0.227648944f}, std::array<float,2>{0.762115777f, 0.627809644f}, std::array<float,2>{0.0690959543f, 0.296079755f}, std::array<float,2>{0.156801507f, 0.51167357f}, std::array<float,2>{0.963058531f, 0.492690355f}, std::array<float,2>{0.624281883f, 0.944124341f}, std::array<float,2>{0.394541711f, 0.0214890093f}, std::array<float,2>{0.482877284f, 0.699568033f}, std::array<float,2>{0.524041831f, 0.318980485f}, std::array<float,2>{0.929043233f, 0.78729713f}, std::array<float,2>{0.195237115f, 0.12921907f}, std::array<float,2>{0.046238035f, 0.892609477f}, std::array<float,2>{0.872938752f, 0.0770472363f}, std::array<float,2>{0.683465958f, 0.60781616f}, std::array<float,2>{0.368482679f, 0.412364572f}, std::array<float,2>{0.411866426f, 0.99202919f}, std::array<float,2>{0.590462863f, 0.0463270172f}, std::array<float,2>{0.982852817f, 0.55473578f}, std::array<float,2>{0.125937998f, 0.453865558f}, std::array<float,2>{0.106770918f, 0.65764451f}, std::array<float,2>{0.786016285f, 0.265802652f}, std::array<float,2>{0.717642069f, 0.818422794f}, std::array<float,2>{0.303310573f, 0.213725388f}, std::array<float,2>{0.338947564f, 0.590786636f}, std::array<float,2>{0.641962886f, 0.401963472f}, std::array<float,2>{0.825192809f, 0.909962356f}, std::array<float,2>{0.0211889651f, 0.117224567f}, std::array<float,2>{0.243993297f, 0.76797992f}, std::array<float,2>{0.900352836f, 0.17159231f}, std::array<float,2>{0.554007709f, 0.748848081f}, std::array<float,2>{0.459546387f, 0.35953021f}, std::array<float,2>{0.425477833f, 0.775994062f}, std::array<float,2>{0.569503665f, 0.163688883f}, std::array<float,2>{0.989646673f, 0.740912139f}, std::array<float,2>{0.151961848f, 0.373600453f}, std::array<float,2>{0.120100781f, 0.580705106f}, std::array<float,2>{0.807621777f, 0.397449613f}, std::array<float,2>{0.697779238f, 0.916201413f}, std::array<float,2>{0.2818425f, 0.113028511f}, std::array<float,2>{0.31451115f, 0.664911568f}, std::array<float,2>{0.640217304f, 0.27884227f}, std::array<float,2>{0.833508968f, 0.824463665f}, std::array<float,2>{0.011504868f, 0.209624335f}, std::array<float,2>{0.220496431f, 0.992412508f}, std::array<float,2>{0.885386586f, 0.0331671275f}, std::array<float,2>{0.541740239f, 0.552400768f}, std::array<float,2>{0.442015141f, 0.468143284f}, std::array<float,2>{0.257885844f, 0.898670912f}, std::array<float,2>{0.731381714f, 0.0634494796f}, std::array<float,2>{0.777604342f, 0.596300066f}, std::array<float,2>{0.091081731f, 0.419715434f}, std::array<float,2>{0.181753442f, 0.691275954f}, std::array<float,2>{0.952975333f, 0.320337802f}, std::array<float,2>{0.606252015f, 0.79186815f}, std::array<float,2>{0.375254124f, 0.136608377f}, std::array<float,2>{0.490534037f, 0.506579995f}, std::array<float,2>{0.504533887f, 0.49102819f}, std::array<float,2>{0.906480551f, 0.951416135f}, std::array<float,2>{0.21743992f, 0.0255964585f}, std::array<float,2>{0.0533746369f, 0.867845118f}, std::array<float,2>{0.855319798f, 0.225512102f}, std::array<float,2>{0.671391845f, 0.639696062f}, std::array<float,2>{0.345531613f, 0.282209873f}, std::array<float,2>{0.374823868f, 0.838288188f}, std::array<float,2>{0.6858899f, 0.190158471f}, std::array<float,2>{0.86994046f, 0.686273456f}, std::array<float,2>{0.0414038338f, 0.258555353f}, std::array<float,2>{0.187677965f, 0.538308203f}, std::array<float,2>{0.924170196f, 0.438256174f}, std::array<float,2>{0.528449178f, 0.980813146f}, std::array<float,2>{0.478680581f, 0.0478859618f}, std::array<float,2>{0.391775936f, 0.726705015f}, std::array<float,2>{0.618706286f, 0.346895754f}, std::array<float,2>{0.966769934f, 0.75891614f}, std::array<float,2>{0.160434738f, 0.175041631f}, std::array<float,2>{0.0646419004f, 0.92287004f}, std::array<float,2>{0.759977877f, 0.0969254002f}, std::array<float,2>{0.744585991f, 0.573168933f}, std::array<float,2>{0.27440235f, 0.379690737f}, std::array<float,2>{0.454834163f, 0.963964581f}, std::array<float,2>{0.549278975f, 0.00753859105f}, std::array<float,2>{0.903238177f, 0.520605564f}, std::array<float,2>{0.249816522f, 0.482465863f}, std::array<float,2>{0.0172228236f, 0.645401537f}, std::array<float,2>{0.823673368f, 0.297695965f}, std::array<float,2>{0.645728171f, 0.84619844f}, std::array<float,2>{0.342622727f, 0.236822888f}, std::array<float,2>{0.297126859f, 0.619271755f}, std::array<float,2>{0.712886095f, 0.431208134f}, std::array<float,2>{0.783203781f, 0.876560509f}, std::array<float,2>{0.103283465f, 0.079583995f}, std::array<float,2>{0.131785065f, 0.805333197f}, std::array<float,2>{0.977592051f, 0.149804145f}, std::array<float,2>{0.589431226f, 0.708185554f}, std::array<float,2>{0.409692258f, 0.336221725f}, std::array<float,2>{0.470170856f, 0.852446318f}, std::array<float,2>{0.521260083f, 0.247470096f}, std::array<float,2>{0.934459925f, 0.650369227f}, std::array<float,2>{0.201733321f, 0.307147086f}, std::array<float,2>{0.0325707197f, 0.527048409f}, std::array<float,2>{0.860729992f, 0.474395305f}, std::array<float,2>{0.675111175f, 0.95963335f}, std::array<float,2>{0.365423977f, 0.0104455324f}, std::array<float,2>{0.273330152f, 0.714462817f}, std::array<float,2>{0.740177214f, 0.334217459f}, std::array<float,2>{0.754070103f, 0.79864198f}, std::array<float,2>{0.0768844932f, 0.143131629f}, std::array<float,2>{0.16685456f, 0.883866727f}, std::array<float,2>{0.955545306f, 0.0862141997f}, std::array<float,2>{0.612103701f, 0.616665184f}, std::array<float,2>{0.399402291f, 0.422838062f}, std::array<float,2>{0.330831707f, 0.976090491f}, std::array<float,2>{0.654514194f, 0.0615309179f}, std::array<float,2>{0.812983274f, 0.540175736f}, std::array<float,2>{0.0251521599f, 0.452401012f}, std::array<float,2>{0.237663165f, 0.676796138f}, std::array<float,2>{0.897848368f, 0.251401454f}, std::array<float,2>{0.556662977f, 0.832143247f}, std::array<float,2>{0.46815896f, 0.201130062f}, std::array<float,2>{0.415822208f, 0.562979817f}, std::array<float,2>{0.579529762f, 0.389484882f}, std::array<float,2>{0.971089005f, 0.934681833f}, std::array<float,2>{0.138429418f, 0.105654269f}, std::array<float,2>{0.0950267762f, 0.751803756f}, std::array<float,2>{0.789573133f, 0.185071751f}, std::array<float,2>{0.709367871f, 0.722558618f}, std::array<float,2>{0.312294543f, 0.358964026f}, std::array<float,2>{0.291875273f, 0.782690167f}, std::array<float,2>{0.691766858f, 0.125374466f}, std::array<float,2>{0.797203183f, 0.696053147f}, std::array<float,2>{0.111537285f, 0.313051522f}, std::array<float,2>{0.141047597f, 0.605078936f}, std::array<float,2>{0.999276698f, 0.409468055f}, std::array<float,2>{0.572204471f, 0.898358405f}, std::array<float,2>{0.437375754f, 0.0726688802f}, std::array<float,2>{0.446247339f, 0.631320655f}, std::array<float,2>{0.538727939f, 0.292034656f}, std::array<float,2>{0.880714834f, 0.860595942f}, std::array<float,2>{0.229197159f, 0.231378615f}, std::array<float,2>{0.00298855361f, 0.940421343f}, std::array<float,2>{0.842499495f, 0.0159182306f}, std::array<float,2>{0.630254805f, 0.511929989f}, std::array<float,2>{0.322112978f, 0.498396337f}, std::array<float,2>{0.386508644f, 0.913596213f}, std::array<float,2>{0.601125419f, 0.121888638f}, std::array<float,2>{0.937906623f, 0.589751899f}, std::array<float,2>{0.174792081f, 0.405503154f}, std::array<float,2>{0.0789716542f, 0.745087206f}, std::array<float,2>{0.76832968f, 0.366603166f}, std::array<float,2>{0.724151969f, 0.770256996f}, std::array<float,2>{0.254637748f, 0.166096076f}, std::array<float,2>{0.352758765f, 0.559072256f}, std::array<float,2>{0.660648942f, 0.458933085f}, std::array<float,2>{0.843922198f, 0.985217333f}, std::array<float,2>{0.0585144721f, 0.040460173f}, std::array<float,2>{0.203162938f, 0.814444125f}, std::array<float,2>{0.917029083f, 0.215588182f}, std::array<float,2>{0.510443389f, 0.66073662f}, std::array<float,2>{0.494281173f, 0.272004366f}, std::array<float,2>{0.389658123f, 0.850231111f}, std::array<float,2>{0.597402155f, 0.241485104f}, std::array<float,2>{0.944676995f, 0.642121732f}, std::array<float,2>{0.178433552f, 0.304427534f}, std::array<float,2>{0.0849258304f, 0.517691195f}, std::array<float,2>{0.770588815f, 0.479079694f}, std::array<float,2>{0.720943451f, 0.96737963f}, std::array<float,2>{0.250396103f, 0.00166133582f}, std::array<float,2>{0.358091652f, 0.706145465f}, std::array<float,2>{0.659846544f, 0.34325552f}, std::array<float,2>{0.849812627f, 0.812494099f}, std::array<float,2>{0.0598543882f, 0.153196707f}, std::array<float,2>{0.209756896f, 0.879797161f}, std::array<float,2>{0.918660641f, 0.0855960846f}, std::array<float,2>{0.514801264f, 0.624480665f}, std::array<float,2>{0.498890996f, 0.435654312f}, std::array<float,2>{0.296813756f, 0.976734638f}, std::array<float,2>{0.688859582f, 0.0517518669f}, std::array<float,2>{0.804295838f, 0.533172309f}, std::array<float,2>{0.116844505f, 0.441765815f}, std::array<float,2>{0.146960989f, 0.679880202f}, std::array<float,2>{0.993843019f, 0.264255792f}, std::array<float,2>{0.576753438f, 0.840420306f}, std::array<float,2>{0.429911315f, 0.19163847f}, std::array<float,2>{0.451436162f, 0.575748682f}, std::array<float,2>{0.532495201f, 0.377210557f}, std::array<float,2>{0.875197291f, 0.927951813f}, std::array<float,2>{0.230921254f, 0.0985286087f}, std::array<float,2>{0.00405143527f, 0.762690485f}, std::array<float,2>{0.837195456f, 0.179062843f}, std::array<float,2>{0.628375769f, 0.732574582f}, std::array<float,2>{0.326145321f, 0.347857386f}, std::array<float,2>{0.334215492f, 0.796111703f}, std::array<float,2>{0.651896536f, 0.14026162f}, std::array<float,2>{0.819698036f, 0.692304015f}, std::array<float,2>{0.0289969407f, 0.327814728f}, std::array<float,2>{0.239555955f, 0.599588037f}, std::array<float,2>{0.891345263f, 0.415864944f}, std::array<float,2>{0.560465276f, 0.905346096f}, std::array<float,2>{0.464332461f, 0.0702067241f}, std::array<float,2>{0.418668181f, 0.635760188f}, std::array<float,2>{0.58405292f, 0.288302571f}, std::array<float,2>{0.973861814f, 0.871196866f}, std::array<float,2>{0.133896589f, 0.219103888f}, std::array<float,2>{0.0990633443f, 0.947925508f}, std::array<float,2>{0.794568598f, 0.0289363526f}, std::array<float,2>{0.704239905f, 0.500894487f}, std::array<float,2>{0.307373285f, 0.488082439f}, std::array<float,2>{0.474317014f, 0.920696735f}, std::array<float,2>{0.51803565f, 0.115710102f}, std::array<float,2>{0.931139588f, 0.583477736f}, std::array<float,2>{0.196607724f, 0.392001629f}, std::array<float,2>{0.0367599875f, 0.734595239f}, std::array<float,2>{0.865429878f, 0.370542645f}, std::array<float,2>{0.679192066f, 0.780359089f}, std::array<float,2>{0.360078365f, 0.159521386f}, std::array<float,2>{0.269049764f, 0.549705029f}, std::array<float,2>{0.737885177f, 0.461237371f}, std::array<float,2>{0.75099349f, 0.998722553f}, std::array<float,2>{0.0703311488f, 0.0355375186f}, std::array<float,2>{0.171159953f, 0.823920727f}, std::array<float,2>{0.960278511f, 0.204634607f}, std::array<float,2>{0.61690414f, 0.670956314f}, std::array<float,2>{0.402633965f, 0.275307626f}, std::array<float,2>{0.460508734f, 0.767347157f}, std::array<float,2>{0.553284287f, 0.169838592f}, std::array<float,2>{0.898883641f, 0.747972906f}, std::array<float,2>{0.242837399f, 0.361744702f}, std::array<float,2>{0.020109864f, 0.592214286f}, std::array<float,2>{0.825978339f, 0.400000632f}, std::array<float,2>{0.641169131f, 0.907957852f}, std::array<float,2>{0.338389069f, 0.120753251f}, std::array<float,2>{0.304224432f, 0.658327699f}, std::array<float,2>{0.718384624f, 0.268789887f}, std::array<float,2>{0.786804318f, 0.818213046f}, std::array<float,2>{0.105584458f, 0.211919844f}, std::array<float,2>{0.126405969f, 0.988664865f}, std::array<float,2>{0.984186053f, 0.0441602021f}, std::array<float,2>{0.591079473f, 0.557421148f}, std::array<float,2>{0.410847664f, 0.456826061f}, std::array<float,2>{0.367342472f, 0.891691446f}, std::array<float,2>{0.681674421f, 0.0742577985f}, std::array<float,2>{0.871178269f, 0.607119024f}, std::array<float,2>{0.0451921523f, 0.410568416f}, std::array<float,2>{0.193712875f, 0.70241183f}, std::array<float,2>{0.928512275f, 0.317787528f}, std::array<float,2>{0.525297701f, 0.786999345f}, std::array<float,2>{0.484244853f, 0.130868495f}, std::array<float,2>{0.396461457f, 0.509276032f}, std::array<float,2>{0.623287976f, 0.494598389f}, std::array<float,2>{0.964082897f, 0.941571832f}, std::array<float,2>{0.158075899f, 0.0199701898f}, std::array<float,2>{0.0698464662f, 0.86491698f}, std::array<float,2>{0.76353848f, 0.2303859f}, std::array<float,2>{0.748867869f, 0.62545836f}, std::array<float,2>{0.279554754f, 0.29463926f}, std::array<float,2>{0.264651209f, 0.831514955f}, std::array<float,2>{0.727549016f, 0.198613122f}, std::array<float,2>{0.774636447f, 0.673717916f}, std::array<float,2>{0.0862419903f, 0.255529583f}, std::array<float,2>{0.186307624f, 0.546760261f}, std::array<float,2>{0.947301626f, 0.44773677f}, std::array<float,2>{0.604035556f, 0.971630096f}, std::array<float,2>{0.381102294f, 0.0572090186f}, std::array<float,2>{0.485887617f, 0.725654483f}, std::array<float,2>{0.501226723f, 0.352716446f}, std::array<float,2>{0.91220963f, 0.757316709f}, std::array<float,2>{0.211354703f, 0.180761799f}, std::array<float,2>{0.0493744537f, 0.933120251f}, std::array<float,2>{0.85928905f, 0.104709566f}, std::array<float,2>{0.665451765f, 0.567606032f}, std::array<float,2>{0.349337071f, 0.386220604f}, std::array<float,2>{0.428266406f, 0.954907656f}, std::array<float,2>{0.562573254f, 0.0138804009f}, std::array<float,2>{0.984694242f, 0.530667663f}, std::array<float,2>{0.15501155f, 0.47121951f}, std::array<float,2>{0.124854296f, 0.65396893f}, std::array<float,2>{0.810066462f, 0.311923683f}, std::array<float,2>{0.701197624f, 0.85740298f}, std::array<float,2>{0.286919534f, 0.245463073f}, std::array<float,2>{0.318200797f, 0.610485256f}, std::array<float,2>{0.633490801f, 0.428332597f}, std::array<float,2>{0.830783606f, 0.889798343f}, std::array<float,2>{0.0142585272f, 0.0929040834f}, std::array<float,2>{0.222728401f, 0.801641524f}, std::array<float,2>{0.890334487f, 0.145801038f}, std::array<float,2>{0.546371639f, 0.717639565f}, std::array<float,2>{0.441330999f, 0.331793129f}, std::array<float,2>{0.408313543f, 0.807496965f}, std::array<float,2>{0.588174939f, 0.15173997f}, std::array<float,2>{0.977411389f, 0.709938884f}, std::array<float,2>{0.13184464f, 0.339600027f}, std::array<float,2>{0.102380551f, 0.618583739f}, std::array<float,2>{0.784325004f, 0.431737155f}, std::array<float,2>{0.711120725f, 0.877203941f}, std::array<float,2>{0.298820674f, 0.0812735111f}, std::array<float,2>{0.34282431f, 0.646565259f}, std::array<float,2>{0.645421565f, 0.300713956f}, std::array<float,2>{0.823117137f, 0.844503939f}, std::array<float,2>{0.01612233f, 0.235623196f}, std::array<float,2>{0.248229399f, 0.96244812f}, std::array<float,2>{0.904260218f, 0.00531441532f}, std::array<float,2>{0.550636172f, 0.522517443f}, std::array<float,2>{0.454081684f, 0.481713027f}, std::array<float,2>{0.274805248f, 0.924239218f}, std::array<float,2>{0.746059179f, 0.0945355818f}, std::array<float,2>{0.761021852f, 0.572173953f}, std::array<float,2>{0.0661041215f, 0.380863279f}, std::array<float,2>{0.161739036f, 0.730189502f}, std::array<float,2>{0.965245545f, 0.344266862f}, std::array<float,2>{0.618030667f, 0.759864509f}, std::array<float,2>{0.390953213f, 0.172317266f}, std::array<float,2>{0.480030894f, 0.535433888f}, std::array<float,2>{0.527410209f, 0.441294074f}, std::array<float,2>{0.925355375f, 0.982480049f}, std::array<float,2>{0.188745528f, 0.049943056f}, std::array<float,2>{0.042523209f, 0.837571561f}, std::array<float,2>{0.870565057f, 0.18840532f}, std::array<float,2>{0.686630905f, 0.684368432f}, std::array<float,2>{0.373066932f, 0.260244429f}, std::array<float,2>{0.344169647f, 0.869583249f}, std::array<float,2>{0.670511782f, 0.223104954f}, std::array<float,2>{0.854348361f, 0.638121426f}, std::array<float,2>{0.0539767221f, 0.283248127f}, std::array<float,2>{0.217966557f, 0.504079282f}, std::array<float,2>{0.907533526f, 0.489364356f}, std::array<float,2>{0.505183756f, 0.949689448f}, std::array<float,2>{0.491545856f, 0.0238004792f}, std::array<float,2>{0.37657693f, 0.687957346f}, std::array<float,2>{0.606722116f, 0.322975218f}, std::array<float,2>{0.951300144f, 0.789741457f}, std::array<float,2>{0.183118567f, 0.13463971f}, std::array<float,2>{0.0905439332f, 0.901910603f}, std::array<float,2>{0.778589785f, 0.0658864379f}, std::array<float,2>{0.732284188f, 0.595582962f}, std::array<float,2>{0.259225309f, 0.420154363f}, std::array<float,2>{0.443262994f, 0.994144201f}, std::array<float,2>{0.542149246f, 0.0340421237f}, std::array<float,2>{0.885818899f, 0.554585516f}, std::array<float,2>{0.219546646f, 0.4652147f}, std::array<float,2>{0.0104943439f, 0.66701138f}, std::array<float,2>{0.832277238f, 0.280827492f}, std::array<float,2>{0.639040351f, 0.826775312f}, std::array<float,2>{0.315617174f, 0.207846642f}, std::array<float,2>{0.282740712f, 0.579623461f}, std::array<float,2>{0.698351085f, 0.395860672f}, std::array<float,2>{0.806834996f, 0.914440811f}, std::array<float,2>{0.120997936f, 0.109925926f}, std::array<float,2>{0.150987774f, 0.775096416f}, std::array<float,2>{0.989002168f, 0.161979526f}, std::array<float,2>{0.568921506f, 0.739679039f}, std::array<float,2>{0.424762696f, 0.372016519f}, std::array<float,2>{0.495315373f, 0.814735889f}, std::array<float,2>{0.510780752f, 0.217585593f}, std::array<float,2>{0.916455388f, 0.662729025f}, std::array<float,2>{0.204339057f, 0.271125525f}, std::array<float,2>{0.0575501844f, 0.56206274f}, std::array<float,2>{0.845073402f, 0.45965147f}, std::array<float,2>{0.661668658f, 0.987887204f}, std::array<float,2>{0.352392167f, 0.0423837863f}, std::array<float,2>{0.255326957f, 0.743100584f}, std::array<float,2>{0.723082066f, 0.364912182f}, std::array<float,2>{0.768623829f, 0.773227274f}, std::array<float,2>{0.0799219161f, 0.165252209f}, std::array<float,2>{0.175281823f, 0.911273837f}, std::array<float,2>{0.939232111f, 0.124942362f}, std::array<float,2>{0.600392878f, 0.587219477f}, std::array<float,2>{0.384778559f, 0.40402627f}, std::array<float,2>{0.320987761f, 0.939052761f}, std::array<float,2>{0.629823983f, 0.0182402041f}, std::array<float,2>{0.84319675f, 0.514451802f}, std::array<float,2>{0.00280778063f, 0.497558594f}, std::array<float,2>{0.229902878f, 0.62965858f}, std::array<float,2>{0.87926966f, 0.290852726f}, std::array<float,2>{0.537235439f, 0.861890376f}, std::array<float,2>{0.446671307f, 0.232769579f}, std::array<float,2>{0.435684741f, 0.603318214f}, std::array<float,2>{0.570667624f, 0.407086462f}, std::array<float,2>{0.998182595f, 0.895146132f}, std::array<float,2>{0.142434463f, 0.0704170689f}, std::array<float,2>{0.113228723f, 0.783447087f}, std::array<float,2>{0.798729241f, 0.127422988f}, std::array<float,2>{0.692883551f, 0.697469354f}, std::array<float,2>{0.29258737f, 0.315378696f}, std::array<float,2>{0.31089139f, 0.75218606f}, std::array<float,2>{0.710238099f, 0.187406346f}, std::array<float,2>{0.790383339f, 0.718969643f}, std::array<float,2>{0.0941190347f, 0.356580973f}, std::array<float,2>{0.137164518f, 0.565262377f}, std::array<float,2>{0.97192955f, 0.388366371f}, std::array<float,2>{0.578302801f, 0.936893165f}, std::array<float,2>{0.414548934f, 0.10842973f}, std::array<float,2>{0.466852844f, 0.678225517f}, std::array<float,2>{0.55831778f, 0.253055453f}, std::array<float,2>{0.896835268f, 0.834346533f}, std::array<float,2>{0.236373484f, 0.201298118f}, std::array<float,2>{0.0239528958f, 0.973473907f}, std::array<float,2>{0.814046502f, 0.0593678616f}, std::array<float,2>{0.656199217f, 0.542828381f}, std::array<float,2>{0.331385016f, 0.450331807f}, std::array<float,2>{0.400104493f, 0.885331988f}, std::array<float,2>{0.612646043f, 0.0889476016f}, std::array<float,2>{0.956905007f, 0.61471504f}, std::array<float,2>{0.167967901f, 0.424786359f}, std::array<float,2>{0.0779289678f, 0.711937666f}, std::array<float,2>{0.75506562f, 0.333100438f}, std::array<float,2>{0.738632023f, 0.798879683f}, std::array<float,2>{0.272358805f, 0.142196298f}, std::array<float,2>{0.366694659f, 0.524802685f}, std::array<float,2>{0.67419976f, 0.476016313f}, std::array<float,2>{0.859767973f, 0.957613766f}, std::array<float,2>{0.0319541432f, 0.00949833728f}, std::array<float,2>{0.20251675f, 0.854949594f}, std::array<float,2>{0.935220242f, 0.249536306f}, std::array<float,2>{0.519920766f, 0.651003659f}, std::array<float,2>{0.469016373f, 0.306267351f}, std::array<float,2>{0.431893528f, 0.84303534f}, std::array<float,2>{0.574488163f, 0.19511655f}, std::array<float,2>{0.994472742f, 0.683241367f}, std::array<float,2>{0.145323426f, 0.263209403f}, std::array<float,2>{0.113679551f, 0.534366846f}, std::array<float,2>{0.802688539f, 0.444409758f}, std::array<float,2>{0.689529419f, 0.979463935f}, std::array<float,2>{0.293560863f, 0.0529296026f}, std::array<float,2>{0.326399714f, 0.732195556f}, std::array<float,2>{0.625711799f, 0.351348966f}, std::array<float,2>{0.838037729f, 0.765330136f}, std::array<float,2>{0.00766497944f, 0.1763293f}, std::array<float,2>{0.232501775f, 0.926323175f}, std::array<float,2>{0.877000391f, 0.101289779f}, std::array<float,2>{0.534378529f, 0.577462316f}, std::array<float,2>{0.451153964f, 0.375522345f}, std::array<float,2>{0.25385052f, 0.964892328f}, std::array<float,2>{0.719763041f, 0.00203259452f}, std::array<float,2>{0.772541404f, 0.516986787f}, std::array<float,2>{0.0838040486f, 0.477050245f}, std::array<float,2>{0.176996112f, 0.643315911f}, std::array<float,2>{0.942036092f, 0.30124414f}, std::array<float,2>{0.594816625f, 0.848947108f}, std::array<float,2>{0.387545437f, 0.239636987f}, std::array<float,2>{0.496590585f, 0.621590734f}, std::array<float,2>{0.51269412f, 0.434066653f}, std::array<float,2>{0.920871496f, 0.882615089f}, std::array<float,2>{0.207784846f, 0.0821063593f}, std::array<float,2>{0.0620933063f, 0.809179366f}, std::array<float,2>{0.8483513f, 0.156143472f}, std::array<float,2>{0.656649888f, 0.704276979f}, std::array<float,2>{0.356379658f, 0.340893388f}, std::array<float,2>{0.361847997f, 0.777512193f}, std::array<float,2>{0.676086783f, 0.157739282f}, std::array<float,2>{0.864738643f, 0.738080561f}, std::array<float,2>{0.0389008857f, 0.368809015f}, std::array<float,2>{0.198501855f, 0.58412993f}, std::array<float,2>{0.932431042f, 0.394269615f}, std::array<float,2>{0.517438471f, 0.919331729f}, std::array<float,2>{0.475232601f, 0.114298426f}, std::array<float,2>{0.405715048f, 0.668854773f}, std::array<float,2>{0.613960922f, 0.276344925f}, std::array<float,2>{0.958323658f, 0.821301937f}, std::array<float,2>{0.169432744f, 0.205607951f}, std::array<float,2>{0.07420066f, 0.997756958f}, std::array<float,2>{0.753714621f, 0.0388533771f}, std::array<float,2>{0.734925091f, 0.548770308f}, std::array<float,2>{0.266512752f, 0.463367343f}, std::array<float,2>{0.462454647f, 0.903802395f}, std::array<float,2>{0.561323524f, 0.0682739466f}, std::array<float,2>{0.89428246f, 0.600013494f}, std::array<float,2>{0.241373107f, 0.416052669f}, std::array<float,2>{0.0309173521f, 0.693426371f}, std::array<float,2>{0.816516399f, 0.325108886f}, std::array<float,2>{0.650036335f, 0.794245362f}, std::array<float,2>{0.332497805f, 0.13795948f}, std::array<float,2>{0.305008262f, 0.502345502f}, std::array<float,2>{0.705753088f, 0.485310823f}, std::array<float,2>{0.795371056f, 0.946624279f}, std::array<float,2>{0.0999370068f, 0.0308481976f}, std::array<float,2>{0.135384202f, 0.874824882f}, std::array<float,2>{0.975065887f, 0.221597537f}, std::array<float,2>{0.582721472f, 0.634201348f}, std::array<float,2>{0.421603769f, 0.285169184f}, std::array<float,2>{0.481379122f, 0.788141131f}, std::array<float,2>{0.525799453f, 0.130581334f}, std::array<float,2>{0.927231371f, 0.70065403f}, std::array<float,2>{0.192216441f, 0.320240468f}, std::array<float,2>{0.0437896587f, 0.609248817f}, std::array<float,2>{0.874019682f, 0.413163364f}, std::array<float,2>{0.679774642f, 0.894099295f}, std::array<float,2>{0.370740861f, 0.0774086416f}, std::array<float,2>{0.277864248f, 0.628020823f}, std::array<float,2>{0.747541666f, 0.295747548f}, std::array<float,2>{0.765019834f, 0.866005838f}, std::array<float,2>{0.0679436028f, 0.226970911f}, std::array<float,2>{0.159423068f, 0.944930136f}, std::array<float,2>{0.962380707f, 0.022803193f}, std::array<float,2>{0.622223258f, 0.509984016f}, std::array<float,2>{0.397001445f, 0.493384004f}, std::array<float,2>{0.337547153f, 0.908848464f}, std::array<float,2>{0.642719269f, 0.118584655f}, std::array<float,2>{0.826847494f, 0.591222048f}, std::array<float,2>{0.0230418872f, 0.401286781f}, std::array<float,2>{0.245804191f, 0.749181628f}, std::array<float,2>{0.902316809f, 0.360858619f}, std::array<float,2>{0.551057339f, 0.768942714f}, std::array<float,2>{0.458525449f, 0.170575082f}, std::array<float,2>{0.413203984f, 0.556516767f}, std::array<float,2>{0.592729151f, 0.454637289f}, std::array<float,2>{0.98179549f, 0.990763485f}, std::array<float,2>{0.127101973f, 0.0457284674f}, std::array<float,2>{0.108483583f, 0.820075095f}, std::array<float,2>{0.787363112f, 0.214504197f}, std::array<float,2>{0.715934217f, 0.656334698f}, std::array<float,2>{0.301701456f, 0.267211348f}, std::array<float,2>{0.288283587f, 0.859234929f}, std::array<float,2>{0.700766325f, 0.242834374f}, std::array<float,2>{0.811552644f, 0.655181646f}, std::array<float,2>{0.122880101f, 0.310191602f}, std::array<float,2>{0.152613655f, 0.52780515f}, std::array<float,2>{0.986617565f, 0.468921125f}, std::array<float,2>{0.564770877f, 0.956129432f}, std::array<float,2>{0.427685142f, 0.0127791492f}, std::array<float,2>{0.438770324f, 0.716731787f}, std::array<float,2>{0.543034792f, 0.329321414f}, std::array<float,2>{0.887491405f, 0.803433597f}, std::array<float,2>{0.224723458f, 0.147611767f}, std::array<float,2>{0.0125314975f, 0.888538718f}, std::array<float,2>{0.828488171f, 0.0914451629f}, std::array<float,2>{0.6350227f, 0.612102866f}, std::array<float,2>{0.3185727f, 0.427342445f}, std::array<float,2>{0.380687892f, 0.970373809f}, std::array<float,2>{0.602720857f, 0.0562855937f}, std::array<float,2>{0.946052909f, 0.543598831f}, std::array<float,2>{0.185465813f, 0.445483446f}, std::array<float,2>{0.0889889672f, 0.674784958f}, std::array<float,2>{0.776984036f, 0.256630361f}, std::array<float,2>{0.730171919f, 0.828941941f}, std::array<float,2>{0.263482511f, 0.19593358f}, std::array<float,2>{0.350383282f, 0.569254816f}, std::array<float,2>{0.666885078f, 0.384536088f}, std::array<float,2>{0.856630981f, 0.931080043f}, std::array<float,2>{0.0484970286f, 0.102783501f}, std::array<float,2>{0.213109821f, 0.755273819f}, std::array<float,2>{0.910926044f, 0.183078542f}, std::array<float,2>{0.503188789f, 0.722662926f}, std::array<float,2>{0.487633616f, 0.354286462f}, std::array<float,2>{0.392963767f, 0.758478642f}, std::array<float,2>{0.62100327f, 0.174324006f}, std::array<float,2>{0.967209756f, 0.727678239f}, std::array<float,2>{0.163459599f, 0.346135557f}, std::array<float,2>{0.0640544444f, 0.573661745f}, std::array<float,2>{0.759039462f, 0.380764127f}, std::array<float,2>{0.742651641f, 0.921921015f}, std::array<float,2>{0.275970757f, 0.0959455818f}, std::array<float,2>{0.371285349f, 0.686601877f}, std::array<float,2>{0.683625102f, 0.258908361f}, std::array<float,2>{0.867949367f, 0.839382112f}, std::array<float,2>{0.0394759849f, 0.191319078f}, std::array<float,2>{0.190137938f, 0.981585801f}, std::array<float,2>{0.921922386f, 0.0476316884f}, std::array<float,2>{0.52980423f, 0.538014889f}, std::array<float,2>{0.478118151f, 0.43894574f}, std::array<float,2>{0.299307853f, 0.875792086f}, std::array<float,2>{0.71373409f, 0.0781665891f}, std::array<float,2>{0.781802952f, 0.620604038f}, std::array<float,2>{0.104969606f, 0.430193484f}, std::array<float,2>{0.129495412f, 0.707542658f}, std::array<float,2>{0.979883671f, 0.337006509f}, std::array<float,2>{0.586863756f, 0.806612909f}, std::array<float,2>{0.406490266f, 0.148683012f}, std::array<float,2>{0.456021667f, 0.520471156f}, std::array<float,2>{0.547751307f, 0.484305054f}, std::array<float,2>{0.90512687f, 0.963278472f}, std::array<float,2>{0.246704742f, 0.00667117722f}, std::array<float,2>{0.0180723909f, 0.847625971f}, std::array<float,2>{0.821733117f, 0.237655252f}, std::array<float,2>{0.646802187f, 0.645800173f}, std::array<float,2>{0.340561658f, 0.29875949f}, std::array<float,2>{0.313714623f, 0.825974643f}, std::array<float,2>{0.638294518f, 0.210664615f}, std::array<float,2>{0.835040867f, 0.665191293f}, std::array<float,2>{0.00855642278f, 0.277401179f}, std::array<float,2>{0.221063837f, 0.551338911f}, std::array<float,2>{0.883177221f, 0.466885298f}, std::array<float,2>{0.539307714f, 0.99341476f}, std::array<float,2>{0.443431258f, 0.0321873426f}, std::array<float,2>{0.423138022f, 0.741447806f}, std::array<float,2>{0.567139983f, 0.374124229f}, std::array<float,2>{0.99171108f, 0.77723074f}, std::array<float,2>{0.150121823f, 0.162229016f}, std::array<float,2>{0.118529759f, 0.917436957f}, std::array<float,2>{0.806106031f, 0.112202436f}, std::array<float,2>{0.69683212f, 0.581237316f}, std::array<float,2>{0.283376515f, 0.398288637f}, std::array<float,2>{0.490107536f, 0.952600658f}, std::array<float,2>{0.507113993f, 0.026937779f}, std::array<float,2>{0.908851683f, 0.507128298f}, std::array<float,2>{0.21602793f, 0.491575032f}, std::array<float,2>{0.0522372983f, 0.638748109f}, std::array<float,2>{0.851749599f, 0.282386214f}, std::array<float,2>{0.667997777f, 0.868321717f}, std::array<float,2>{0.346898168f, 0.225687757f}, std::array<float,2>{0.261611968f, 0.596848369f}, std::array<float,2>{0.73414433f, 0.418123543f}, std::array<float,2>{0.781115055f, 0.900331318f}, std::array<float,2>{0.093295902f, 0.0641842112f}, std::array<float,2>{0.180690169f, 0.792435467f}, std::array<float,2>{0.949932516f, 0.135623023f}, std::array<float,2>{0.607915521f, 0.689680159f}, std::array<float,2>{0.377427846f, 0.322155356f}, std::array<float,2>{0.447753131f, 0.860022902f}, std::array<float,2>{0.535184443f, 0.231692702f}, std::array<float,2>{0.881603479f, 0.632484078f}, std::array<float,2>{0.226691589f, 0.291740268f}, std::array<float,2>{0.000370884605f, 0.5127545f}, std::array<float,2>{0.840553463f, 0.499308407f}, std::array<float,2>{0.632302821f, 0.94048214f}, std::array<float,2>{0.323186129f, 0.0170011651f}, std::array<float,2>{0.289489895f, 0.697196841f}, std::array<float,2>{0.693827331f, 0.314235836f}, std::array<float,2>{0.800329506f, 0.781408191f}, std::array<float,2>{0.109588124f, 0.126737133f}, std::array<float,2>{0.142955676f, 0.897396743f}, std::array<float,2>{0.996101618f, 0.0739929453f}, std::array<float,2>{0.574115396f, 0.604478419f}, std::array<float,2>{0.434720725f, 0.408972919f}, std::array<float,2>{0.353975743f, 0.986008048f}, std::array<float,2>{0.662354648f, 0.0395469405f}, std::array<float,2>{0.845856786f, 0.560233176f}, std::array<float,2>{0.0556917451f, 0.457083076f}, std::array<float,2>{0.205255151f, 0.661179662f}, std::array<float,2>{0.915353537f, 0.273012012f}, std::array<float,2>{0.509259999f, 0.81342262f}, std::array<float,2>{0.492432594f, 0.216023371f}, std::array<float,2>{0.383761495f, 0.587902248f}, std::array<float,2>{0.597772956f, 0.404593438f}, std::array<float,2>{0.940387845f, 0.913030744f}, std::array<float,2>{0.172063813f, 0.122950569f}, std::array<float,2>{0.0808824524f, 0.770782769f}, std::array<float,2>{0.766876638f, 0.167362213f}, std::array<float,2>{0.725536287f, 0.745843649f}, std::array<float,2>{0.257352769f, 0.365554661f}, std::array<float,2>{0.269785047f, 0.797463536f}, std::array<float,2>{0.740984261f, 0.144070804f}, std::array<float,2>{0.756677449f, 0.713508904f}, std::array<float,2>{0.0749332905f, 0.33589384f}, std::array<float,2>{0.165997028f, 0.615666151f}, std::array<float,2>{0.954616129f, 0.423597008f}, std::array<float,2>{0.609913111f, 0.883545101f}, std::array<float,2>{0.400723934f, 0.0874790177f}, std::array<float,2>{0.472297162f, 0.648561001f}, std::array<float,2>{0.522265017f, 0.307907641f}, std::array<float,2>{0.935745358f, 0.853369415f}, std::array<float,2>{0.19934319f, 0.246876791f}, std::array<float,2>{0.0345808268f, 0.960715711f}, std::array<float,2>{0.862619042f, 0.0109427599f}, std::array<float,2>{0.673530996f, 0.525599718f}, std::array<float,2>{0.365111172f, 0.473147482f}, std::array<float,2>{0.416992158f, 0.934325576f}, std::array<float,2>{0.581542492f, 0.106640384f}, std::array<float,2>{0.96940583f, 0.563605368f}, std::array<float,2>{0.140212789f, 0.390095264f}, std::array<float,2>{0.096392706f, 0.721104443f}, std::array<float,2>{0.79268688f, 0.357698679f}, std::array<float,2>{0.708065033f, 0.750505567f}, std::array<float,2>{0.30928424f, 0.184020296f}, std::array<float,2>{0.329709262f, 0.539556623f}, std::array<float,2>{0.65301764f, 0.451826185f}, std::array<float,2>{0.814564943f, 0.975010157f}, std::array<float,2>{0.0267291255f, 0.0610029921f}, std::array<float,2>{0.235713214f, 0.833980739f}, std::array<float,2>{0.895558238f, 0.199434459f}, std::array<float,2>{0.555389762f, 0.676100671f}, std::array<float,2>{0.465560883f, 0.250514925f}}
49.006592
51
0.734725
st-ario
2542029350b0b404fbb1ac81123e1b99e37bef78
1,206
hpp
C++
src/utils/io.hpp
aligungr/ue-ran-sim
564f9d228723f03adfa2b02df2ea019bdf305085
[ "MIT" ]
16
2020-04-16T02:07:37.000Z
2020-07-23T10:48:27.000Z
src/utils/io.hpp
aligungr/ue-ran-sim
564f9d228723f03adfa2b02df2ea019bdf305085
[ "MIT" ]
8
2020-07-13T17:11:35.000Z
2020-08-03T16:46:31.000Z
src/utils/io.hpp
aligungr/ue-ran-sim
564f9d228723f03adfa2b02df2ea019bdf305085
[ "MIT" ]
9
2020-03-04T15:05:08.000Z
2020-07-30T06:18:18.000Z
// // This file is a part of UERANSIM open source project. // Copyright (c) 2021 ALİ GÜNGÖR. // // The software and all associated files are licensed under GPL-3.0 // and subject to the terms and conditions defined in LICENSE file. // #pragma once #include <string> #include <vector> namespace io { void CreateDirectory(const std::string &path); bool Exists(const std::string &path); std::string ReadAllText(const std::string &file); void WriteAllText(const std::string &path, const std::string &content); void RelaxPermissions(const std::string &path); bool Remove(const std::string &path); std::vector<std::string> GetEntries(const std::string &path); std::vector<std::string> GetAllEntries(const std::string &path); void PreOrderEntries(const std::string &root, std::vector<std::string> &visitor); bool IsDirectory(const std::string &path); bool IsRegularFile(const std::string &path); std::string GetStem(const std::string &path); void AppendPath(std::string &source, const std::string &target); std::string GetIp4OfInterface(const std::string &ifName); std::string GetIp6OfInterface(const std::string &ifName); std::string GetHostByName(const std::string& name); } // namespace io
24.12
81
0.740464
aligungr
25434081e9cb5acc2e145d1a614574615f6f255f
136
cpp
C++
cpp/pb_large_map/LargeMap.cpp
patrit/playground
6ace43f81123a06e9b5820e1f75e5a9af0cb37b9
[ "MIT" ]
null
null
null
cpp/pb_large_map/LargeMap.cpp
patrit/playground
6ace43f81123a06e9b5820e1f75e5a9af0cb37b9
[ "MIT" ]
null
null
null
cpp/pb_large_map/LargeMap.cpp
patrit/playground
6ace43f81123a06e9b5820e1f75e5a9af0cb37b9
[ "MIT" ]
null
null
null
#include "LargeMap.hpp" LargeMap::Map LargeMap::_map{ {"foo", {{"bar42", 42}, {"bar43", 43}, } }, };
13.6
29
0.426471
patrit
25448e6a51424ada9805a6c032e1ec65fdbb7890
1,183
hh
C++
trick_source/data_products/Apps/trkConvert/TRK_DataLog.hh
gilbertguoze/trick
f0537efb0fa3cb5c0c84e36b60f055c1d1c60d21
[ "NASA-1.3" ]
647
2015-05-07T16:08:16.000Z
2022-03-30T02:33:21.000Z
trick_source/data_products/Apps/trkConvert/TRK_DataLog.hh
gilbertguoze/trick
f0537efb0fa3cb5c0c84e36b60f055c1d1c60d21
[ "NASA-1.3" ]
995
2015-04-30T19:44:31.000Z
2022-03-31T20:14:44.000Z
trick_source/data_products/Apps/trkConvert/TRK_DataLog.hh
gilbertguoze/trick
f0537efb0fa3cb5c0c84e36b60f055c1d1c60d21
[ "NASA-1.3" ]
251
2015-05-15T09:24:34.000Z
2022-03-22T20:39:05.000Z
#ifndef TRK_DATA_LOG_HH #define TRK_DATA_LOG_HH #include <stdio.h> // FILE #include <stdint.h> // Requires C99 #include <string> #include <vector> #include "LogFormatter.hh" #include "ParamDescription.hh" class TRK_DataLog { public: static const int LittleEndian; static const int BigEndian; std::vector<ParamDescription*> paramDescriptions; std::vector<int> paramOffsets; std::vector<bool> paramSelected; // Constructors TRK_DataLog(){} TRK_DataLog(std::string fileName); std::string getFileName() const; int parameterCount() const; const char* parameterName(unsigned int n) const; const char* parameterUnits(unsigned int n) const; const char* parameterType(unsigned int n) const; void selectAllParameters(); void selectParameter(unsigned int index); void selectParameter(const char * paramName); void deselectParameter(unsigned int index); void formattedWrite(FILE* out_fp, LogFormatter* formatter); private: std::string fileName; FILE* in_fp; int version; int endianness; uint32_t N_params; fpos_t dataPosition; int dataRecordSize; char* dataRecord; }; #endif
23.66
63
0.71175
gilbertguoze
25452d7b66752b9252960b9985a8b6186e1030b4
1,095
hpp
C++
src/engine/mapset.hpp
eXl-Nic/eXl
a5a0f77f47db3179365c107a184bb38b80280279
[ "MIT" ]
null
null
null
src/engine/mapset.hpp
eXl-Nic/eXl
a5a0f77f47db3179365c107a184bb38b80280279
[ "MIT" ]
null
null
null
src/engine/mapset.hpp
eXl-Nic/eXl
a5a0f77f47db3179365c107a184bb38b80280279
[ "MIT" ]
null
null
null
#pragma once #include <dunatk/map/map.hpp> #include <dunatk/map/tile.hpp> #include <dunatk/map/tileblock.hpp> namespace eXl { class MapSet : public HeapObject { MapSet(); public: IntrusivePtr<SpriteDesc const> texFloor; IntrusivePtr<SpriteDesc const> texFloorBorder; IntrusivePtr<SpriteDesc const> texFloorIntCorner; IntrusivePtr<SpriteDesc const> texFloorExtCorner; IntrusivePtr<SpriteDesc const> texWall; IntrusivePtr<SpriteDesc const> texFill; IntrusivePtr<SpriteDesc const> texIntCorner; IntrusivePtr<SpriteDesc const> texExtCorner; TileLoc locFloor; TileLoc locFloorBorder; TileLoc locFloorIntCorner; TileLoc locFloorExtCorner; TileLoc locWall; TileLoc locWallIntCorner; TileLoc locWallExtCorner; TileLoc locFill; Tile_OLD tileFloor; Tile_OLD tileFloorBorder; Tile_OLD tileFloorIntCorner; Tile_OLD tileFloorExtCorner; Tile_OLD tileWall; Tile_OLD tileWallIntCorner; Tile_OLD tileWallExtCorner; Tile_OLD tileFill; public: Old::TileSet mapSet; static MapSet& Get(); }; }
24.886364
53
0.742466
eXl-Nic
8584124fdaa67095b42aa00325694a65e9782bcb
5,735
cpp
C++
cocos2dx_playground/Classes/step_rain_of_chaos_game_test_ActorMoveScene.cpp
R2Road/cocos2dx_playground
6e6f349b5c9fc702558fe8720ba9253a8ba00164
[ "Apache-2.0" ]
9
2020-06-11T17:09:44.000Z
2021-12-25T00:34:33.000Z
cocos2dx_playground/Classes/step_rain_of_chaos_game_test_ActorMoveScene.cpp
R2Road/cocos2dx_playground
6e6f349b5c9fc702558fe8720ba9253a8ba00164
[ "Apache-2.0" ]
9
2019-12-21T15:01:01.000Z
2020-12-05T15:42:43.000Z
cocos2dx_playground/Classes/step_rain_of_chaos_game_test_ActorMoveScene.cpp
R2Road/cocos2dx_playground
6e6f349b5c9fc702558fe8720ba9253a8ba00164
[ "Apache-2.0" ]
1
2020-09-07T01:32:16.000Z
2020-09-07T01:32:16.000Z
#include "step_rain_of_chaos_game_test_ActorMoveScene.h" #include <new> #include <numeric> #include "2d/CCLabel.h" #include "2d/CCLayer.h" #include "base/CCDirector.h" #include "base/CCEventDispatcher.h" #include "base/CCEventListenerKeyboard.h" #include "base/ccUTF8.h" #include "cpg_SStream.h" #include "cpg_StringTable.h" #include "step_mole_CircleCollisionComponentConfig.h" #include "step_rain_of_chaos_game_PlayerNode.h" USING_NS_CC; namespace { const int TAG_PlayerNode = 20140416; const int TAG_MoveSpeedNode = 20160528; } namespace step_rain_of_chaos { namespace game_test { ActorMoveScene::ActorMoveScene( const helper::FuncSceneMover& back_to_the_previous_scene_callback ) : helper::BackToThePreviousScene( back_to_the_previous_scene_callback ) , mKeyboardListener( nullptr ) , mKeyCodeCollector() , mMoveSpeed( 150.f ) {} Scene* ActorMoveScene::create( const helper::FuncSceneMover& back_to_the_previous_scene_callback ) { auto ret = new ( std::nothrow ) ActorMoveScene( back_to_the_previous_scene_callback ); if( !ret || !ret->init() ) { delete ret; ret = nullptr; } else { ret->autorelease(); } return ret; } bool ActorMoveScene::init() { if( !Scene::init() ) { return false; } schedule( schedule_selector( ActorMoveScene::UpdateForInput ) ); const auto visibleSize = _director->getVisibleSize(); const auto visibleOrigin = _director->getVisibleOrigin(); // // Summury // { std::stringstream ss; ss << "+ " << getTitle(); ss << cpg::linefeed; ss << cpg::linefeed; ss << "[ESC] : Return to Root"; ss << cpg::linefeed; ss << cpg::linefeed; ss << "[1] : Move Speed Up"; ss << cpg::linefeed; ss << "[2] : Move Speed Down"; ss << cpg::linefeed; ss << cpg::linefeed; ss << "[Arrow Key] : Move"; auto label = Label::createWithTTF( ss.str(), cpg::StringTable::GetFontPath(), 9, Size::ZERO, TextHAlignment::LEFT ); label->setAnchorPoint( Vec2( 0.f, 1.f ) ); label->setPosition( Vec2( visibleOrigin.x , visibleOrigin.y + visibleSize.height ) ); addChild( label, std::numeric_limits<int>::max() ); } // // Background // { auto background_layer = LayerColor::create( Color4B( 63, 23, 14, 255 ) ); addChild( background_layer, std::numeric_limits<int>::min() ); } // // Current Life Time // { auto label = Label::createWithTTF( "", cpg::StringTable::GetFontPath(), 12, Size::ZERO, TextHAlignment::LEFT ); label->setTag( TAG_MoveSpeedNode ); label->setAnchorPoint( Vec2( 1.f, 1.f ) ); label->setColor( Color3B::GREEN ); label->setPosition( Vec2( visibleOrigin.x + visibleSize.width , visibleOrigin.y + visibleSize.height ) ); addChild( label, std::numeric_limits<int>::max() ); updateMoveSpeedView(); } // // Player Node // { auto player_node = game::PlayerNode::create( 5.f, game::PlayerNode::DebugConfig{ true }, step_mole::CircleCollisionComponentConfig{ true, true, true } ); player_node->setTag( TAG_PlayerNode ); player_node->setPosition( Vec2( static_cast<int>( visibleOrigin.x + ( visibleSize.width * 0.5f ) ) , static_cast<int>( visibleOrigin.y + ( visibleSize.height * 0.5f ) ) ) ); addChild( player_node ); } return true; } void ActorMoveScene::onEnter() { Scene::onEnter(); assert( !mKeyboardListener ); mKeyboardListener = EventListenerKeyboard::create(); mKeyboardListener->onKeyPressed = CC_CALLBACK_2( ActorMoveScene::onKeyPressed, this ); mKeyboardListener->onKeyReleased = CC_CALLBACK_2( ActorMoveScene::onKeyReleased, this ); getEventDispatcher()->addEventListenerWithSceneGraphPriority( mKeyboardListener, this ); } void ActorMoveScene::onExit() { assert( mKeyboardListener ); getEventDispatcher()->removeEventListener( mKeyboardListener ); mKeyboardListener = nullptr; Scene::onExit(); } void ActorMoveScene::UpdateForInput( float delta_time ) { Vec2 move_vector; if( mKeyCodeCollector.isActiveKey( EventKeyboard::KeyCode::KEY_UP_ARROW ) ) { move_vector.y += 1.f; } if( mKeyCodeCollector.isActiveKey( EventKeyboard::KeyCode::KEY_DOWN_ARROW ) ) { move_vector.y -= 1.f; } if( mKeyCodeCollector.isActiveKey( EventKeyboard::KeyCode::KEY_RIGHT_ARROW ) ) { move_vector.x += 1.f; } if( mKeyCodeCollector.isActiveKey( EventKeyboard::KeyCode::KEY_LEFT_ARROW ) ) { move_vector.x -= 1.f; } if( 0.f != move_vector.x || 0.f != move_vector.y ) { move_vector.normalize(); move_vector.scale( mMoveSpeed * delta_time ); auto animation_node = getChildByTag( TAG_PlayerNode ); animation_node->setPosition( animation_node->getPosition() + move_vector ); updateMoveSpeedView(); } } void ActorMoveScene::onKeyPressed( EventKeyboard::KeyCode keycode, Event* /*event*/ ) { if( EventKeyboard::KeyCode::KEY_ESCAPE == keycode ) { helper::BackToThePreviousScene::MoveBack(); return; } if( EventKeyboard::KeyCode::KEY_1 == keycode ) { mMoveSpeed += 1.f; updateMoveSpeedView(); } if( EventKeyboard::KeyCode::KEY_2 == keycode ) { mMoveSpeed = std::max( 1.f, mMoveSpeed - 1.f ); updateMoveSpeedView(); } mKeyCodeCollector.onKeyPressed( keycode ); } void ActorMoveScene::onKeyReleased( EventKeyboard::KeyCode keycode, Event* /*event*/ ) { mKeyCodeCollector.onKeyReleased( keycode ); } void ActorMoveScene::updateMoveSpeedView() { auto label = static_cast<Label*>( getChildByTag( TAG_MoveSpeedNode ) ); label->setString( StringUtils::format( "Move Speed : %.2f", mMoveSpeed ) ); } } }
26.068182
157
0.668178
R2Road
8584f961bca75835df6fe42b8072af2f58d87d2d
451
cpp
C++
src/cmcandy/C_Language_Answers/_0026.cpp
ch98road/leetcode
a9b4be54a169b30f6711809b892dd1f79f2a17e7
[ "MIT" ]
null
null
null
src/cmcandy/C_Language_Answers/_0026.cpp
ch98road/leetcode
a9b4be54a169b30f6711809b892dd1f79f2a17e7
[ "MIT" ]
null
null
null
src/cmcandy/C_Language_Answers/_0026.cpp
ch98road/leetcode
a9b4be54a169b30f6711809b892dd1f79f2a17e7
[ "MIT" ]
1
2020-11-26T03:01:12.000Z
2020-11-26T03:01:12.000Z
#include <iostream> #include <map> #include <vector> using namespace::std; class Solution { public: int removeDuplicates(vector<int>& nums) { int cur=0; map<int,int>m; for (int i = 0; i < nums.size(); i++) { if (m.find(nums[i])==m.end()) { //如果找不到,则加入 m[nums[i]]=1; nums[cur++] = nums[i]; } } return cur; } };
19.608696
45
0.427938
ch98road
8587631e041c8479eaedc531b415d9a88ae52421
2,957
cpp
C++
src/io/serialPort.cpp
oblaser/omw
3206f5faf8ec26c63004de358235ba7efbd10c4f
[ "MIT" ]
null
null
null
src/io/serialPort.cpp
oblaser/omw
3206f5faf8ec26c63004de358235ba7efbd10c4f
[ "MIT" ]
null
null
null
src/io/serialPort.cpp
oblaser/omw
3206f5faf8ec26c63004de358235ba7efbd10c4f
[ "MIT" ]
null
null
null
/* author Oliver Blaser date 17.12.2021 copyright MIT - Copyright (c) 2021 Oliver Blaser */ #include <algorithm> #include <string> #include <vector> #include "omw/defs.h" #include "omw/io/serialPort.h" #include "omw/string.h" #include "omw/windows/windows.h" namespace { #ifdef OMW_PLAT_WIN bool isCom0com(const std::string& device) { const omw::string tmpDevice = (omw::string(device)).toLower_asciiExt(); const std::vector<omw::string> info = omw::windows::queryDosDevice(device); for (size_t i = 0; i < info.size(); ++i) { const omw::string tmpInfo = info[i].toLower_asciiExt(); if (tmpInfo.contains("com0com") && !tmpDevice.contains("com0com#port#")) { return true; } } return false; } #endif // OMW_PLAT_WIN } #ifndef OMWi_SERIAL_PORT_PREVIEW omw::SerialPort::SerialPort() { } #endif std::vector<omw::string> omw::getSerialPortList(bool onlyCOMx) { std::vector<omw::string> serialPorts; #ifdef OMW_PLAT_WIN const std::vector<omw::string> devices = omw::windows::getAllDosDevices(); for (size_t i = 0; i < devices.size(); ++i) { bool isC0C = false; if (!onlyCOMx) isC0C = ::isCom0com(devices[i]); if ((devices[i].compare(0, 3, "COM") == 0) || (!onlyCOMx && isC0C)) { serialPorts.push_back(devices[i]); } } #endif // OMW_PLAT_WIN return serialPorts; } void omw::sortSerialPortList(std::vector<omw::string>& ports) { #ifdef OMW_PLAT_WIN #if /*simple*/ 0 std::sort(ports.begin(), ports.end()); #else const char* const comStr = "COM"; std::vector<int> comPorts; std::vector<omw::string> otherPorts; for (size_t i = 0; i < ports.size(); ++i) { try { omw::string port = ports[i]; if (port.compare(0, 3, comStr) == 0) { const omw::string intStr = port.substr(3); if (omw::isUInteger(intStr)) comPorts.push_back(std::stoi(intStr)); else throw (-1); } else throw (-1); } catch (...) { otherPorts.push_back(ports[i]); } } std::sort(comPorts.begin(), comPorts.end()); std::sort(otherPorts.begin(), otherPorts.end()); ports.clear(); ports.reserve(comPorts.size() + otherPorts.size()); for (size_t i = 0; i < comPorts.size(); ++i) { ports.push_back(comStr + std::to_string(comPorts[i])); } for (size_t i = 0; i < otherPorts.size(); ++i) { ports.push_back(otherPorts[i]); } #endif #else // OMW_PLAT_WIN std::sort(ports.begin(), ports.end()); #endif // OMW_PLAT_WIN } void omw::sortSerialPortList(std::vector<std::string>& ports) { omw::stringVector_t tmpPorts = omw::stringVector(ports); omw::sortSerialPortList(tmpPorts); ports = omw::stdStringVector(tmpPorts); }
22.233083
84
0.578627
oblaser
858b3f66f848eea4e5fe243506ea4b0584394681
531
cpp
C++
Source/URoboViz/Private/Controllers/RobotController.cpp
HoangGiang93/URoboViz
dcaab223c30827977d15300f7ae4b19ba0ddfa4f
[ "MIT" ]
null
null
null
Source/URoboViz/Private/Controllers/RobotController.cpp
HoangGiang93/URoboViz
dcaab223c30827977d15300f7ae4b19ba0ddfa4f
[ "MIT" ]
null
null
null
Source/URoboViz/Private/Controllers/RobotController.cpp
HoangGiang93/URoboViz
dcaab223c30827977d15300f7ae4b19ba0ddfa4f
[ "MIT" ]
null
null
null
// Copyright (c) 2022, Hoang Giang Nguyen - Institute for Artificial Intelligence, University Bremen #include "Controllers/RobotController.h" #include "Animation/SkeletalMeshActor.h" DEFINE_LOG_CATEGORY_STATIC(LogRobotController, Log, All); URobotController::URobotController() { } void URobotController::Init(ASkeletalMeshActor *InOwner) { if (InOwner == nullptr) { UE_LOG(LogRobotController, Error, TEXT("Owner of %s is nullptr"), *GetName()) return; } SetOwner(InOwner); Init(); }
22.125
101
0.709981
HoangGiang93
858d1219e9e1be331ca432ebb6a99d65c36bf1a1
2,023
cpp
C++
android/app/src/cpp/src/base/tools/Timer.cpp
FlameSalamander/react-native-xmrig
6a6e3b301bd78b88459989f334d759f65e434082
[ "MIT" ]
28
2021-05-11T03:28:57.000Z
2022-03-09T14:34:57.000Z
android/app/src/cpp/src/base/tools/Timer.cpp
FlameSalamander/react-native-xmrig
6a6e3b301bd78b88459989f334d759f65e434082
[ "MIT" ]
10
2021-05-16T19:50:31.000Z
2022-01-30T03:56:45.000Z
android/app/src/cpp/src/base/tools/Timer.cpp
FlameSalamander/react-native-xmrig
6a6e3b301bd78b88459989f334d759f65e434082
[ "MIT" ]
12
2021-07-19T22:14:58.000Z
2022-02-08T02:24:05.000Z
/* XMRig * Copyright 2018-2020 SChernykh <https://github.com/SChernykh> * Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "base/tools/Timer.h" #include "base/kernel/interfaces/ITimerListener.h" #include "base/tools/Handle.h" xmrig::Timer::Timer(ITimerListener *listener) : m_listener(listener) { init(); } xmrig::Timer::Timer(ITimerListener *listener, uint64_t timeout, uint64_t repeat) : m_listener(listener) { init(); start(timeout, repeat); } xmrig::Timer::~Timer() { Handle::close(m_timer); } uint64_t xmrig::Timer::repeat() const { return uv_timer_get_repeat(m_timer); } void xmrig::Timer::setRepeat(uint64_t repeat) { uv_timer_set_repeat(m_timer, repeat); } void xmrig::Timer::singleShot(uint64_t timeout, int id) { m_id = id; stop(); start(timeout, 0); } void xmrig::Timer::start(uint64_t timeout, uint64_t repeat) { uv_timer_start(m_timer, onTimer, timeout, repeat); } void xmrig::Timer::stop() { setRepeat(0); uv_timer_stop(m_timer); } void xmrig::Timer::init() { m_timer = new uv_timer_t; m_timer->data = this; uv_timer_init(uv_default_loop(), m_timer); } void xmrig::Timer::onTimer(uv_timer_t *handle) { const auto timer = static_cast<Timer *>(handle->data); timer->m_listener->onTimer(timer); }
21.521277
82
0.695502
FlameSalamander
858d21f8b3654fc3784454fa510505c5cdb008ed
527
cc
C++
ui/display/chromeos/ozone/display_configurator_ozone.cc
domenic/mojo
53dda76fed90a47c35ed6e06baf833a0d44495b8
[ "BSD-3-Clause" ]
27
2016-04-27T01:02:03.000Z
2021-12-13T08:53:19.000Z
ui/display/chromeos/ozone/display_configurator_ozone.cc
domenic/mojo
53dda76fed90a47c35ed6e06baf833a0d44495b8
[ "BSD-3-Clause" ]
2
2017-03-09T09:00:50.000Z
2017-09-21T15:48:20.000Z
ui/display/chromeos/ozone/display_configurator_ozone.cc
domenic/mojo
53dda76fed90a47c35ed6e06baf833a0d44495b8
[ "BSD-3-Clause" ]
17
2016-04-27T02:06:39.000Z
2019-12-18T08:07:00.000Z
// Copyright 2014 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "ui/display/chromeos/display_configurator.h" #include "ui/display/types/native_display_delegate.h" #include "ui/ozone/public/ozone_platform.h" namespace ui { scoped_ptr<NativeDisplayDelegate> DisplayConfigurator::CreatePlatformNativeDisplayDelegate() { return ui::OzonePlatform::GetInstance()->CreateNativeDisplayDelegate(); } } // namespace ui
29.277778
73
0.789374
domenic
859144fe3502ca1d0a582301f21ac43a1abcc4b9
4,268
hpp
C++
include/codegen/include/System/DateTimeResult.hpp
Futuremappermydud/Naluluna-Modifier-Quest
bfda34370764b275d90324b3879f1a429a10a873
[ "MIT" ]
1
2021-11-12T09:29:31.000Z
2021-11-12T09:29:31.000Z
include/codegen/include/System/DateTimeResult.hpp
Futuremappermydud/Naluluna-Modifier-Quest
bfda34370764b275d90324b3879f1a429a10a873
[ "MIT" ]
null
null
null
include/codegen/include/System/DateTimeResult.hpp
Futuremappermydud/Naluluna-Modifier-Quest
bfda34370764b275d90324b3879f1a429a10a873
[ "MIT" ]
2
2021-10-03T02:14:20.000Z
2021-11-12T09:29:36.000Z
// Autogenerated from CppHeaderCreator // Created by Sc2ad // ========================================================================= #pragma once #pragma pack(push, 8) // Begin includes #include "extern/beatsaber-hook/shared/utils/typedefs.h" // Including type: System.ValueType #include "System/ValueType.hpp" // Including type: System.ParseFlags #include "System/ParseFlags.hpp" // Including type: System.TimeSpan #include "System/TimeSpan.hpp" // Including type: System.DateTime #include "System/DateTime.hpp" // Including type: System.ParseFailureKind #include "System/ParseFailureKind.hpp" // Completed includes // Begin forward declares // Forward declaring namespace: System::Globalization namespace System::Globalization { // Forward declaring type: Calendar class Calendar; } // Completed forward declares // Type namespace: System namespace System { // Autogenerated type: System.DateTimeResult struct DateTimeResult : public System::ValueType { public: // System.Int32 Year // Offset: 0x0 int Year; // System.Int32 Month // Offset: 0x4 int Month; // System.Int32 Day // Offset: 0x8 int Day; // System.Int32 Hour // Offset: 0xC int Hour; // System.Int32 Minute // Offset: 0x10 int Minute; // System.Int32 Second // Offset: 0x14 int Second; // System.Double fraction // Offset: 0x18 double fraction; // System.Int32 era // Offset: 0x20 int era; // System.ParseFlags flags // Offset: 0x24 System::ParseFlags flags; // System.TimeSpan timeZoneOffset // Offset: 0x28 System::TimeSpan timeZoneOffset; // System.Globalization.Calendar calendar // Offset: 0x30 System::Globalization::Calendar* calendar; // System.DateTime parsedDate // Offset: 0x38 System::DateTime parsedDate; // System.ParseFailureKind failure // Offset: 0x40 System::ParseFailureKind failure; // System.String failureMessageID // Offset: 0x48 ::Il2CppString* failureMessageID; // System.Object failureMessageFormatArgument // Offset: 0x50 ::Il2CppObject* failureMessageFormatArgument; // System.String failureArgumentName // Offset: 0x58 ::Il2CppString* failureArgumentName; // Creating value type constructor for type: DateTimeResult DateTimeResult(int Year_ = {}, int Month_ = {}, int Day_ = {}, int Hour_ = {}, int Minute_ = {}, int Second_ = {}, double fraction_ = {}, int era_ = {}, System::ParseFlags flags_ = {}, System::TimeSpan timeZoneOffset_ = {}, System::Globalization::Calendar* calendar_ = {}, System::DateTime parsedDate_ = {}, System::ParseFailureKind failure_ = {}, ::Il2CppString* failureMessageID_ = {}, ::Il2CppObject* failureMessageFormatArgument_ = {}, ::Il2CppString* failureArgumentName_ = {}) : Year{Year_}, Month{Month_}, Day{Day_}, Hour{Hour_}, Minute{Minute_}, Second{Second_}, fraction{fraction_}, era{era_}, flags{flags_}, timeZoneOffset{timeZoneOffset_}, calendar{calendar_}, parsedDate{parsedDate_}, failure{failure_}, failureMessageID{failureMessageID_}, failureMessageFormatArgument{failureMessageFormatArgument_}, failureArgumentName{failureArgumentName_} {} // System.Void Init() // Offset: 0xA2CEB0 void Init(); // System.Void SetDate(System.Int32 year, System.Int32 month, System.Int32 day) // Offset: 0xA2CED0 void SetDate(int year, int month, int day); // System.Void SetFailure(System.ParseFailureKind failure, System.String failureMessageID, System.Object failureMessageFormatArgument) // Offset: 0xA2CEDC void SetFailure(System::ParseFailureKind failure, ::Il2CppString* failureMessageID, ::Il2CppObject* failureMessageFormatArgument); // System.Void SetFailure(System.ParseFailureKind failure, System.String failureMessageID, System.Object failureMessageFormatArgument, System.String failureArgumentName) // Offset: 0xA2CF18 void SetFailure(System::ParseFailureKind failure, ::Il2CppString* failureMessageID, ::Il2CppObject* failureMessageFormatArgument, ::Il2CppString* failureArgumentName); }; // System.DateTimeResult } #include "extern/beatsaber-hook/shared/utils/il2cpp-type-check.hpp" DEFINE_IL2CPP_ARG_TYPE(System::DateTimeResult, "System", "DateTimeResult"); #pragma pack(pop)
43.55102
862
0.714855
Futuremappermydud
85930680ecaf000349ed02a841828353c188a384
10,830
cc
C++
Third-party/Sokol/src/d3d11/imgui-d3d11.cc
VLiance/Demos
fa8435c2fa0f46e1324a71501fdf646326936148
[ "Unlicense" ]
null
null
null
Third-party/Sokol/src/d3d11/imgui-d3d11.cc
VLiance/Demos
fa8435c2fa0f46e1324a71501fdf646326936148
[ "Unlicense" ]
null
null
null
Third-party/Sokol/src/d3d11/imgui-d3d11.cc
VLiance/Demos
fa8435c2fa0f46e1324a71501fdf646326936148
[ "Unlicense" ]
null
null
null
//------------------------------------------------------------------------------ // imgui-d3d11.cc // Dear ImGui integration sample with D3D11 backend. //------------------------------------------------------------------------------ #include "d3d11entry.h" #define SOKOL_IMPL #define SOKOL_D3D11 #define SOKOL_D3D11_SHADER_COMPILER #define SOKOL_LOG(s) OutputDebugStringA(s) #include "sokol_gfx.h" #include "sokol_time.h" #include "imgui.h" const int Width = 1024; const int Height = 768; const int MaxVertices = (1<<16); const int MaxIndices = MaxVertices * 3; uint64_t last_time = 0; bool show_test_window = true; bool show_another_window = false; sg_draw_state draw_state = { }; sg_pass_action pass_action = { }; ImDrawVert vertices[MaxVertices]; uint16_t indices[MaxIndices]; typedef struct { ImVec2 disp_size; } vs_params_t; void imgui_draw_cb(ImDrawData*); int WINAPI WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPSTR lpCmdLine, _In_ int nCmdShow) { // setup d3d11 app wrapper, sokol_gfx, sokol_time d3d11_init(Width, Height, 1, L"Sokol Dear ImGui D3D11"); sg_desc desc = { }; desc.d3d11_device = d3d11_device(); desc.d3d11_device_context = d3d11_device_context(); desc.d3d11_render_target_view_cb = d3d11_render_target_view; desc.d3d11_depth_stencil_view_cb = d3d11_depth_stencil_view; sg_setup(&desc); stm_setup(); // input forwarding d3d11_mouse_pos([] (float x, float y) { ImGui::GetIO().MousePos = ImVec2(x, y); }); d3d11_mouse_btn_down([] (int btn) { ImGui::GetIO().MouseDown[btn] = true; }); d3d11_mouse_btn_up([] (int btn) { ImGui::GetIO().MouseDown[btn] = false; }); d3d11_mouse_wheel([](float v) { ImGui::GetIO().MouseWheel = v; }); d3d11_char([] (wchar_t c) { ImGui::GetIO().AddInputCharacter(c); }); d3d11_key_down([] (int key) { if (key < 512) ImGui::GetIO().KeysDown[key] = true; }); d3d11_key_up([] (int key) { if (key < 512) ImGui::GetIO().KeysDown[key] = false; }); // setup Dear Imgui ImGui::CreateContext(); ImGui::StyleColorsDark(); ImGuiIO& io = ImGui::GetIO(); io.IniFilename = nullptr; io.RenderDrawListsFn = imgui_draw_cb; io.Fonts->AddFontDefault(); io.KeyMap[ImGuiKey_Tab] = VK_TAB; io.KeyMap[ImGuiKey_LeftArrow] = VK_LEFT; io.KeyMap[ImGuiKey_RightArrow] = VK_RIGHT; io.KeyMap[ImGuiKey_UpArrow] = VK_UP; io.KeyMap[ImGuiKey_DownArrow] = VK_DOWN; io.KeyMap[ImGuiKey_Home] = VK_HOME; io.KeyMap[ImGuiKey_End] = VK_END; io.KeyMap[ImGuiKey_Delete] = VK_DELETE; io.KeyMap[ImGuiKey_Backspace] = VK_BACK; io.KeyMap[ImGuiKey_Enter] = VK_RETURN; io.KeyMap[ImGuiKey_Escape] = VK_ESCAPE; io.KeyMap[ImGuiKey_A] = 'A'; io.KeyMap[ImGuiKey_C] = 'C'; io.KeyMap[ImGuiKey_V] = 'V'; io.KeyMap[ImGuiKey_X] = 'X'; io.KeyMap[ImGuiKey_Y] = 'Y'; io.KeyMap[ImGuiKey_Z] = 'Z'; // dynamic vertex- and index-buffers for imgui-generated geometry sg_buffer_desc vbuf_desc = { }; vbuf_desc.usage = SG_USAGE_STREAM; vbuf_desc.size = sizeof(vertices); draw_state.vertex_buffers[0] = sg_make_buffer(&vbuf_desc); sg_buffer_desc ibuf_desc = { }; ibuf_desc.type = SG_BUFFERTYPE_INDEXBUFFER; ibuf_desc.usage = SG_USAGE_STREAM; ibuf_desc.size = sizeof(indices); draw_state.index_buffer = sg_make_buffer(&ibuf_desc); // font texture for imgui's default font unsigned char* font_pixels; int font_width, font_height; io.Fonts->GetTexDataAsRGBA32(&font_pixels, &font_width, &font_height); sg_image_desc img_desc = { }; img_desc.width = font_width; img_desc.height = font_height; img_desc.pixel_format = SG_PIXELFORMAT_RGBA8; img_desc.wrap_u = SG_WRAP_CLAMP_TO_EDGE; img_desc.wrap_v = SG_WRAP_CLAMP_TO_EDGE; img_desc.content.subimage[0][0].ptr = font_pixels; img_desc.content.subimage[0][0].size = font_width * font_height * 4; draw_state.fs_images[0] = sg_make_image(&img_desc); // shader object for imgui rendering sg_shader_desc shd_desc = { }; auto& ub = shd_desc.vs.uniform_blocks[0]; ub.size = sizeof(vs_params_t); shd_desc.vs.source = "cbuffer params {\n" " float2 disp_size;\n" "};\n" "struct vs_in {\n" " float2 pos: POSITION;\n" " float2 uv: TEXCOORD0;\n" " float4 color: COLOR0;\n" "};\n" "struct vs_out {\n" " float2 uv: TEXCOORD0;\n" " float4 color: COLOR0;\n" " float4 pos: SV_Position;\n" "};\n" "vs_out main(vs_in inp) {\n" " vs_out outp;\n" " outp.pos = float4(((inp.pos/disp_size)-0.5)*float2(2.0,-2.0), 0.5, 1.0);\n" " outp.uv = inp.uv;\n" " outp.color = inp.color;\n" " return outp;\n" "}\n"; shd_desc.fs.images[0].type = SG_IMAGETYPE_2D; shd_desc.fs.source = "Texture2D<float4> tex: register(t0);\n" "sampler smp: register(s0);\n" "float4 main(float2 uv: TEXCOORD0, float4 color: COLOR0): SV_Target0 {\n" " return tex.Sample(smp, uv) * color;\n" "}\n"; sg_shader shd = sg_make_shader(&shd_desc); // pipeline object for imgui rendering sg_pipeline_desc pip_desc = { }; pip_desc.layout.buffers[0].stride = sizeof(ImDrawVert); auto& attrs = pip_desc.layout.attrs; attrs[0].sem_name="POSITION"; attrs[0].offset=offsetof(ImDrawVert, pos); attrs[0].format=SG_VERTEXFORMAT_FLOAT2; attrs[1].sem_name="TEXCOORD"; attrs[1].offset=offsetof(ImDrawVert, uv); attrs[1].format=SG_VERTEXFORMAT_FLOAT2; attrs[2].sem_name="COLOR"; attrs[2].offset=offsetof(ImDrawVert, col); attrs[2].format=SG_VERTEXFORMAT_UBYTE4N; pip_desc.shader = shd; pip_desc.index_type = SG_INDEXTYPE_UINT16; pip_desc.blend.enabled = true; pip_desc.blend.src_factor_rgb = SG_BLENDFACTOR_SRC_ALPHA; pip_desc.blend.dst_factor_rgb = SG_BLENDFACTOR_ONE_MINUS_SRC_ALPHA; pip_desc.blend.color_write_mask = SG_COLORMASK_RGB; draw_state.pipeline = sg_make_pipeline(&pip_desc); // initial clear color pass_action.colors[0].action = SG_ACTION_CLEAR; pass_action.colors[0].val[0] = 0.0f; pass_action.colors[0].val[1] = 0.5f; pass_action.colors[0].val[2] = 0.7f; pass_action.colors[0].val[3] = 1.0f; // draw loop while (d3d11_process_events()) { const int cur_width = d3d11_width(); const int cur_height = d3d11_height(); // this is standard ImGui demo code ImGuiIO& io = ImGui::GetIO(); io.DisplaySize = ImVec2(float(cur_width), float(cur_height)); io.DeltaTime = (float) stm_sec(stm_laptime(&last_time)); ImGui::NewFrame(); // 1. Show a simple window // Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets appears in a window automatically called "Debug" static float f = 0.0f; ImGui::Text("Hello, world!"); ImGui::SliderFloat("float", &f, 0.0f, 1.0f); ImGui::ColorEdit3("clear color", &pass_action.colors[0].val[0]); if (ImGui::Button("Test Window")) show_test_window ^= 1; if (ImGui::Button("Another Window")) show_another_window ^= 1; ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate); // 2. Show another simple window, this time using an explicit Begin/End pair if (show_another_window) { ImGui::SetNextWindowSize(ImVec2(200,100), ImGuiSetCond_FirstUseEver); ImGui::Begin("Another Window", &show_another_window); ImGui::Text("Hello"); ImGui::End(); } // 3. Show the ImGui test window. Most of the sample code is in ImGui::ShowTestWindow() if (show_test_window) { ImGui::SetNextWindowPos(ImVec2(460, 20), ImGuiSetCond_FirstUseEver); ImGui::ShowTestWindow(); } // the sokol_gfx draw pass sg_begin_default_pass(&pass_action, cur_width, cur_height); ImGui::Render(); sg_end_pass(); sg_commit(); d3d11_present(); } ImGui::DestroyContext(); sg_shutdown(); d3d11_shutdown(); } // imgui draw callback void imgui_draw_cb(ImDrawData* draw_data) { assert(draw_data); if (draw_data->CmdListsCount == 0) { return; } // copy vertices and indices int num_vertices = 0; int num_indices = 0; int num_cmdlists = 0; for (num_cmdlists = 0; num_cmdlists < draw_data->CmdListsCount; num_cmdlists++) { const ImDrawList* cl = draw_data->CmdLists[num_cmdlists]; const int cl_num_vertices = cl->VtxBuffer.size(); const int cl_num_indices = cl->IdxBuffer.size(); // overflow check if ((num_vertices + cl_num_vertices) > MaxVertices) { break; } if ((num_indices + cl_num_indices) > MaxIndices) { break; } // copy vertices memcpy(&vertices[num_vertices], &cl->VtxBuffer.front(), cl_num_vertices*sizeof(ImDrawVert)); // copy indices, need to 'rebase' indices to start of global vertex buffer const ImDrawIdx* src_index_ptr = &cl->IdxBuffer.front(); const uint16_t base_vertex_index = num_vertices; for (int i = 0; i < cl_num_indices; i++) { indices[num_indices++] = src_index_ptr[i] + base_vertex_index; } num_vertices += cl_num_vertices; } // update vertex and index buffers const int vertex_data_size = num_vertices * sizeof(ImDrawVert); const int index_data_size = num_indices * sizeof(uint16_t); sg_update_buffer(draw_state.vertex_buffers[0], vertices, vertex_data_size); sg_update_buffer(draw_state.index_buffer, indices, index_data_size); // render the command list vs_params_t vs_params; vs_params.disp_size = ImGui::GetIO().DisplaySize; sg_apply_draw_state(&draw_state); sg_apply_uniform_block(SG_SHADERSTAGE_VS, 0, &vs_params, sizeof(vs_params)); int base_element = 0; for (int cl_index=0; cl_index<num_cmdlists; cl_index++) { const ImDrawList* cmd_list = draw_data->CmdLists[cl_index]; for (const ImDrawCmd& pcmd : cmd_list->CmdBuffer) { if (pcmd.UserCallback) { pcmd.UserCallback(cmd_list, &pcmd); } else { const int sx = (int) pcmd.ClipRect.x; const int sy = (int) pcmd.ClipRect.y; const int sw = (int) (pcmd.ClipRect.z - pcmd.ClipRect.x); const int sh = (int) (pcmd.ClipRect.w - pcmd.ClipRect.y); sg_apply_scissor_rect(sx, sy, sw, sh, true); sg_draw(base_element, pcmd.ElemCount, 1); } base_element += pcmd.ElemCount; } } }
39.525547
130
0.637027
VLiance
8594dcfafda4d2bda1e07bb9eb18ee8bd8228b10
2,771
cpp
C++
engine/RenderPipelineManager.cpp
shanysheng/orange3d
9ee081a98e14fdeb3aaafd6bbb49fe027d4cd3c0
[ "BSD-2-Clause" ]
11
2017-06-06T17:22:30.000Z
2022-03-23T11:56:49.000Z
engine/RenderPipelineManager.cpp
shanysheng/orange3d
9ee081a98e14fdeb3aaafd6bbb49fe027d4cd3c0
[ "BSD-2-Clause" ]
null
null
null
engine/RenderPipelineManager.cpp
shanysheng/orange3d
9ee081a98e14fdeb3aaafd6bbb49fe027d4cd3c0
[ "BSD-2-Clause" ]
5
2018-02-07T02:48:59.000Z
2021-08-23T05:16:59.000Z
#include "RenderPipelineManager.h" namespace pipeline{ CRenderPipelineManager::CRenderPipelineManager():m_pRenderingEngine(NULL) { } CRenderPipelineManager::~CRenderPipelineManager() { ClearRenderPipeline(); ClearPrototypes(); } IRenderPipeline*CRenderPipelineManager::Give( const std::string& Name, const std::string& PrototypeName ) { std::unordered_map< std::string, IRenderPipeline *>::iterator pos; pos = m_RenderPipelines.find(Name); if (pos!=m_RenderPipelines.end()) { return pos->second; } pos = m_Prototypes.find(PrototypeName); if (pos!=m_Prototypes.end()) { IRenderPipeline* pRenderPipeline = pos->second->Clone(); pRenderPipeline->SetContext(this->m_pRenderingEngine); m_RenderPipelines.insert(std::make_pair(Name, pRenderPipeline)); return pRenderPipeline; } return NULL; } void CRenderPipelineManager::Register(const std::string& PrototypeName, IRenderPipeline * pPrototype ) { std::unordered_map< std::string, IRenderPipeline *>::iterator pos; pos = m_Prototypes.find(PrototypeName); if (pos!=m_Prototypes.end()) { if (pos->second) delete pos->second; pos->second = pPrototype; return ; } m_Prototypes.insert(std::make_pair(PrototypeName, pPrototype)); } IRenderPipeline * CRenderPipelineManager::operator [](const std::string& Name) { std::unordered_map< std::string, IRenderPipeline *>::iterator pos; pos = m_RenderPipelines.find(Name); if(pos == m_RenderPipelines.end()) return NULL; return pos->second; } void CRenderPipelineManager::ClearPrototypes() { std::unordered_map< std::string, IRenderPipeline *>::iterator pos; pos = m_Prototypes.begin(); while (pos!=m_Prototypes.end()) { if (pos->second) delete pos->second; ++pos; } m_Prototypes.clear(); } void CRenderPipelineManager::ClearRenderPipeline() { std::unordered_map< std::string, IRenderPipeline *>::iterator pos; pos = m_RenderPipelines.begin(); while (pos!=m_RenderPipelines.end()) { if (pos->second) delete pos->second; ++pos; } m_RenderPipelines.clear(); } CRenderModuleManager& CRenderPipelineManager::GetRenderModuleManager() { return m_RenderModuleMgr; } }
27.71
109
0.568748
shanysheng
859d147d58d8cc6943a7c3f9494e518edaee6312
369
cpp
C++
Algorithms/1759.Count_Number_of_Homogenous_Substrings.cpp
metehkaya/LeetCode
52f4a1497758c6f996d515ced151e8783ae4d4d2
[ "MIT" ]
2
2020-07-20T06:40:22.000Z
2021-11-20T01:23:26.000Z
Problems/LeetCode/Problems/1759.Count_Number_of_Homogenous_Substrings.cpp
metehkaya/Algo-Archive
03b5fdcf06f84a03125c57762c36a4e03ca6e756
[ "MIT" ]
null
null
null
Problems/LeetCode/Problems/1759.Count_Number_of_Homogenous_Substrings.cpp
metehkaya/Algo-Archive
03b5fdcf06f84a03125c57762c36a4e03ca6e756
[ "MIT" ]
null
null
null
class Solution { public: const int MOD = (int) 1e9 + 7; int countHomogenous(string s) { long long ans = 0; int n = s.length(); for( int i = 0 , j = 0 ; i < n ; i = j ) { while(j < n && s[i] == s[j]) j++; long long k = j-i; ans += k*(k+1)/2; } return ans % MOD; } };
24.6
50
0.382114
metehkaya
859ed42fd82392c56c62d3d4b1c29d87fb390c43
24,351
cpp
C++
ugene/src/plugins_3rdparty/primer3/src/Primer3Task.cpp
iganna/lspec
c75cba3e4fa9a46abeecbf31b5d467827cf4fec0
[ "MIT" ]
null
null
null
ugene/src/plugins_3rdparty/primer3/src/Primer3Task.cpp
iganna/lspec
c75cba3e4fa9a46abeecbf31b5d467827cf4fec0
[ "MIT" ]
null
null
null
ugene/src/plugins_3rdparty/primer3/src/Primer3Task.cpp
iganna/lspec
c75cba3e4fa9a46abeecbf31b5d467827cf4fec0
[ "MIT" ]
null
null
null
/** * UGENE - Integrated Bioinformatics Tools. * Copyright (C) 2008-2012 UniPro <ugene@unipro.ru> * http://ugene.unipro.ru * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. */ #include <cstdlib> #include <U2Core/AppContext.h> #include <U2Core/Counter.h> #include <U2Core/SequenceWalkerTask.h> #include <U2Core/CreateAnnotationTask.h> #include "primer3_main.h" #include "boulder_input.h" #include "Primer3Task.h" namespace U2 { // Primer Primer::Primer(): start(0), length(0), meltingTemperature(0), gcContent(0), selfAny(0), selfEnd(0), endStability(0) { } Primer::Primer(const primer_rec &primerRec): start(primerRec.start), length(primerRec.length), meltingTemperature(primerRec.temp), gcContent(primerRec.gc_content), selfAny(primerRec.self_any), selfEnd(primerRec.self_end), endStability(primerRec.end_stability) { } int Primer::getStart()const { return start; } int Primer::getLength()const { return length; } double Primer::getMeltingTemperature()const { return meltingTemperature; } double Primer::getGcContent()const { return gcContent; } short Primer::getSelfAny()const { return selfAny; } short Primer::getSelfEnd()const { return selfEnd; } double Primer::getEndStabilyty()const { return endStability; } void Primer::setStart(int start) { this->start = start; } void Primer::setLength(int length) { this->length = length; } void Primer::setMeltingTemperature(double meltingTemperature) { this->meltingTemperature = meltingTemperature; } void Primer::setGcContent(double gcContent) { this->gcContent = gcContent; } void Primer::setSelfAny(short selfAny) { this->selfAny = selfAny; } void Primer::setSelfEnd(short selfEnd) { this->selfEnd = selfEnd; } void Primer::setEndStability(double endStability) { this->endStability = endStability; } // PrimerPair PrimerPair::PrimerPair(): leftPrimer(NULL), rightPrimer(NULL), internalOligo(NULL), complAny(0), complEnd(0), productSize(0), quality(0), complMeasure(0) { } PrimerPair::PrimerPair(const primer_pair &primerPair, int offset): leftPrimer((NULL == primerPair.left)? NULL:new Primer(*primerPair.left)), rightPrimer((NULL == primerPair.right)? NULL:new Primer(*primerPair.right)), internalOligo((NULL == primerPair.intl)? NULL:new Primer(*primerPair.intl)), complAny(primerPair.compl_any), complEnd(primerPair.compl_end), productSize(primerPair.product_size), quality(primerPair.pair_quality), complMeasure(primerPair.compl_measure) { if(NULL != leftPrimer.get()) { leftPrimer->setStart(leftPrimer->getStart() + offset); } if(NULL != rightPrimer.get()) { rightPrimer->setStart(rightPrimer->getStart() + offset); } if(NULL != internalOligo.get()) { internalOligo->setStart(internalOligo->getStart() + offset); } } PrimerPair::PrimerPair(const PrimerPair &primerPair): leftPrimer((NULL == primerPair.leftPrimer.get())? NULL:new Primer(*primerPair.leftPrimer)), rightPrimer((NULL == primerPair.rightPrimer.get())? NULL:new Primer(*primerPair.rightPrimer)), internalOligo((NULL == primerPair.internalOligo.get())? NULL:new Primer(*primerPair.internalOligo)), complAny(primerPair.complAny), complEnd(primerPair.complEnd), productSize(primerPair.productSize), quality(primerPair.quality), complMeasure(primerPair.complMeasure) { } const PrimerPair &PrimerPair::operator=(const PrimerPair &primerPair) { leftPrimer.reset((NULL == primerPair.leftPrimer.get())? NULL:new Primer(*primerPair.leftPrimer)); rightPrimer.reset((NULL == primerPair.rightPrimer.get())? NULL:new Primer(*primerPair.rightPrimer)); internalOligo.reset((NULL == primerPair.internalOligo.get())? NULL:new Primer(*primerPair.internalOligo)); complAny = primerPair.complAny; complEnd = primerPair.complEnd; productSize = primerPair.productSize; quality = primerPair.quality; complMeasure = primerPair.complMeasure; return *this; } Primer *PrimerPair::getLeftPrimer()const { return leftPrimer.get(); } Primer *PrimerPair::getRightPrimer()const { return rightPrimer.get(); } Primer *PrimerPair::getInternalOligo()const { return internalOligo.get(); } short PrimerPair::getComplAny()const { return complAny; } short PrimerPair::getComplEnd()const { return complEnd; } int PrimerPair::getProductSize()const { return productSize; } void PrimerPair::setLeftPrimer(Primer *leftPrimer) { this->leftPrimer.reset((NULL == leftPrimer)? NULL:new Primer(*leftPrimer)); } void PrimerPair::setRightPrimer(Primer *rightPrimer) { this->rightPrimer.reset((NULL == rightPrimer)? NULL:new Primer(*rightPrimer)); } void PrimerPair::setInternalOligo(Primer *internalOligo) { this->internalOligo.reset((NULL == internalOligo)? NULL:new Primer(*internalOligo)); } void PrimerPair::setComplAny(short complAny) { this->complAny = complAny; } void PrimerPair::setComplEnd(short complEnd) { this->complEnd = complEnd; } void PrimerPair::setProductSize(int productSize) { this->productSize = productSize; } bool PrimerPair::operator<(const PrimerPair &pair)const { if(quality < pair.quality) { return true; } if(quality > pair.quality) { return false; } if (complMeasure < pair.complMeasure) { return true; } if (complMeasure > pair.complMeasure) { return false; } if(leftPrimer->getStart() > pair.leftPrimer->getStart()) { return true; } if(leftPrimer->getStart() < pair.leftPrimer->getStart()) { return false; } if(rightPrimer->getStart() < pair.rightPrimer->getStart()) { return true; } if(rightPrimer->getStart() > pair.rightPrimer->getStart()) { return false; } if(leftPrimer->getLength() < pair.leftPrimer->getLength()) { return true; } if(leftPrimer->getLength() > pair.leftPrimer->getLength()) { return false; } if(rightPrimer->getLength() < pair.rightPrimer->getLength()) { return true; } if(rightPrimer->getLength() > pair.rightPrimer->getLength()) { return false; } return false; } // Primer3Task namespace { bool clipRegion(QPair<int, int> &region, const QPair<int, int> &clippingRegion) { int start = region.first; int end = region.first + region.second; start = qMax(start, clippingRegion.first); end = qMin(end, clippingRegion.first + clippingRegion.second); if(start > end) { return false; } region.first = start; region.second = end - start; return true; } } Primer3Task::Primer3Task(const Primer3TaskSettings &settingsArg): Task(tr("Pick primers task"), TaskFlag_ReportingIsEnabled), settings(settingsArg) { GCOUNTER( cvar, tvar, "Primer3Task" ); { QPair<int, int> region = settings.getIncludedRegion(); region.first -= settings.getFirstBaseIndex(); settings.setIncludedRegion(region); } offset = settings.getIncludedRegion().first; settings.setSequence(settings.getSequence().mid( settings.getIncludedRegion().first, settings.getIncludedRegion().second)); settings.setSequenceQuality(settings.getSequenceQuality().mid( settings.getIncludedRegion().first, settings.getIncludedRegion().second)); settings.setIncludedRegion(qMakePair(0, settings.getIncludedRegion().second)); if(!PR_START_CODON_POS_IS_NULL(settings.getSeqArgs())) { int startCodonPosition = PR_DEFAULT_START_CODON_POS; if(settings.getIntProperty("PRIMER_START_CODON_POSITION", &startCodonPosition)) { settings.setIntProperty("PRIMER_START_CODON_POSITION", startCodonPosition - settings.getFirstBaseIndex()); } } { QList<QPair<int, int> > regionList; QPair<int, int> region; foreach(region, settings.getTarget()) { region.first -= settings.getFirstBaseIndex(); region.first -= offset; if(clipRegion(region, settings.getIncludedRegion())) { regionList.append(region); } } settings.setTarget(regionList); } { QList<QPair<int, int> > regionList; QPair<int, int> region; foreach(region, settings.getExcludedRegion()) { region.first -= settings.getFirstBaseIndex(); region.first -= offset; if(clipRegion(region, settings.getIncludedRegion())) { regionList.append(region); } } settings.setExcludedRegion(regionList); } { QList<QPair<int, int> > regionList; QPair<int, int> region; foreach(region, settings.getInternalOligoExcludedRegion()) { region.first -= settings.getFirstBaseIndex(); region.first -= offset; if(clipRegion(region, settings.getIncludedRegion())) { regionList.append(region); } } settings.setInternalOligoExcludedRegion(regionList); } } void Primer3Task::run() { if(!settings.getRepeatLibrary().isEmpty()) { read_seq_lib(&settings.getPrimerArgs()->repeat_lib, settings.getRepeatLibrary().constData(), "mispriming library"); if(NULL != settings.getPrimerArgs()->repeat_lib.error.data) { pr_append_new_chunk(&settings.getPrimerArgs()->glob_err, settings.getPrimerArgs()->repeat_lib.error.data); pr_append_new_chunk(&settings.getSeqArgs()->error, settings.getPrimerArgs()->repeat_lib.error.data); return; } } if(!settings.getMishybLibrary().isEmpty()) { read_seq_lib(&settings.getPrimerArgs()->io_mishyb_library, settings.getMishybLibrary().constData(), "internal oligo mishyb library"); if(NULL != settings.getPrimerArgs()->io_mishyb_library.error.data) { pr_append_new_chunk(&settings.getPrimerArgs()->glob_err, settings.getPrimerArgs()->io_mishyb_library.error.data); pr_append_new_chunk(&settings.getSeqArgs()->error, settings.getPrimerArgs()->io_mishyb_library.error.data); return; } } primers_t primers = runPrimer3(settings.getPrimerArgs(), settings.getSeqArgs(), &stateInfo.cancelFlag, &stateInfo.progress); bestPairs.clear(); for(int index = 0;index < primers.best_pairs.num_pairs;index++) { bestPairs.append(PrimerPair(primers.best_pairs.pairs[index], offset)); } if(primers.best_pairs.num_pairs > 0) { std::free(primers.best_pairs.pairs); primers.best_pairs.pairs = NULL; } if(NULL != primers.left) { std::free(primers.left); primers.left = NULL; } if(NULL != primers.right) { std::free(primers.right); primers.right = NULL; } if(NULL != primers.intl) { std::free(primers.intl); primers.intl = NULL; } } Task::ReportResult Primer3Task::report() { if(!settings.getError().isEmpty()) { stateInfo.setError(settings.getError()); } return Task::ReportResult_Finished; } void Primer3Task::sumStat(Primer3TaskSettings *st) { st->getSeqArgs()->left_expl.considered += settings.getSeqArgs()->left_expl.considered; st->getSeqArgs()->left_expl.ns += settings.getSeqArgs()->left_expl.ns; st->getSeqArgs()->left_expl.target += settings.getSeqArgs()->left_expl.target; st->getSeqArgs()->left_expl.excluded += settings.getSeqArgs()->left_expl.excluded; st->getSeqArgs()->left_expl.gc += settings.getSeqArgs()->left_expl.gc; st->getSeqArgs()->left_expl.gc_clamp += settings.getSeqArgs()->left_expl.gc_clamp; st->getSeqArgs()->left_expl.temp_min += settings.getSeqArgs()->left_expl.temp_min; st->getSeqArgs()->left_expl.temp_max += settings.getSeqArgs()->left_expl.temp_max; st->getSeqArgs()->left_expl.compl_any += settings.getSeqArgs()->left_expl.compl_any; st->getSeqArgs()->left_expl.compl_end += settings.getSeqArgs()->left_expl.compl_end; st->getSeqArgs()->left_expl.poly_x += settings.getSeqArgs()->left_expl.poly_x; st->getSeqArgs()->left_expl.stability += settings.getSeqArgs()->left_expl.stability; st->getSeqArgs()->left_expl.ok += settings.getSeqArgs()->left_expl.ok; st->getSeqArgs()->right_expl.considered += settings.getSeqArgs()->right_expl.considered; st->getSeqArgs()->right_expl.ns += settings.getSeqArgs()->right_expl.ns; st->getSeqArgs()->right_expl.target += settings.getSeqArgs()->right_expl.target; st->getSeqArgs()->right_expl.excluded += settings.getSeqArgs()->right_expl.excluded; st->getSeqArgs()->right_expl.gc += settings.getSeqArgs()->right_expl.gc; st->getSeqArgs()->right_expl.gc_clamp += settings.getSeqArgs()->right_expl.gc_clamp; st->getSeqArgs()->right_expl.temp_min += settings.getSeqArgs()->right_expl.temp_min; st->getSeqArgs()->right_expl.temp_max += settings.getSeqArgs()->right_expl.temp_max; st->getSeqArgs()->right_expl.compl_any += settings.getSeqArgs()->right_expl.compl_any; st->getSeqArgs()->right_expl.compl_end += settings.getSeqArgs()->right_expl.compl_end; st->getSeqArgs()->right_expl.poly_x += settings.getSeqArgs()->right_expl.poly_x; st->getSeqArgs()->right_expl.stability += settings.getSeqArgs()->right_expl.stability; st->getSeqArgs()->right_expl.ok += settings.getSeqArgs()->right_expl.ok; st->getSeqArgs()->pair_expl.considered += settings.getSeqArgs()->pair_expl.considered; st->getSeqArgs()->pair_expl.product += settings.getSeqArgs()->pair_expl.product; st->getSeqArgs()->pair_expl.compl_end += settings.getSeqArgs()->pair_expl.compl_end; st->getSeqArgs()->pair_expl.ok += settings.getSeqArgs()->pair_expl.ok; } QList<PrimerPair> Primer3Task::getBestPairs()const { return bestPairs; } // Primer3SWTask Primer3SWTask::Primer3SWTask(const Primer3TaskSettings &settingsArg): Task("Pick primers SW task", TaskFlags_NR_FOSCOE), settings(settingsArg) { setMaxParallelSubtasks(MAX_PARALLEL_SUBTASKS_AUTO); } void Primer3SWTask::prepare() { if((settings.getIncludedRegion().first < settings.getFirstBaseIndex()) || (settings.getIncludedRegion().second <= 0) || (settings.getIncludedRegion().first + settings.getIncludedRegion().second > settings.getSequence().size() + settings.getFirstBaseIndex())) { setError("invalid included region"); return; } QVector<U2Region> regions = SequenceWalkerTask::splitRange( U2Region(settings.getIncludedRegion().first, settings.getIncludedRegion().second), CHUNK_SIZE, 0, CHUNK_SIZE/2, false); foreach(U2Region region, regions) { Primer3TaskSettings regionSettings = settings; regionSettings.setIncludedRegion(qMakePair((int)region.startPos, (int)region.length)); Primer3Task *task = new Primer3Task(regionSettings); regionTasks.append(task); addSubTask(task); } } Task::ReportResult Primer3SWTask::report() { foreach(Primer3Task *task, regionTasks) { bestPairs.append(task->getBestPairs()); } if(regionTasks.size() > 1) { qStableSort(bestPairs); int pairsCount = 0; if(!settings.getIntProperty("PRIMER_NUM_RETURN", &pairsCount)) { setError("can't get PRIMER_NUM_RETURN property"); return Task::ReportResult_Finished; } bestPairs = bestPairs.mid(0, pairsCount); } return Task::ReportResult_Finished; } QList<PrimerPair> Primer3SWTask::getBestPairs()const { return bestPairs; } ////////////////////////////////////////////////////////////////////////// ////Primer3ToAnnotationsTask Primer3ToAnnotationsTask::Primer3ToAnnotationsTask( const Primer3TaskSettings &settings, U2SequenceObject* so_, AnnotationTableObject * aobj_, const QString & groupName_, const QString & annName_ ) : Task(tr("Search primers to annotations"), /*TaskFlags_NR_FOSCOE*/TaskFlags(TaskFlag_NoRun) | TaskFlag_ReportingIsSupported | TaskFlag_ReportingIsEnabled | TaskFlag_FailOnSubtaskError), settings(settings), seqObj(so_), aobj(aobj_), groupName(groupName_), annName(annName_), searchTask(NULL), findExonsTask(NULL) { } void Primer3ToAnnotationsTask::prepare() { if (settings.getSpanIntronExonBoundarySettings().enabled) { findExonsTask = new FindExonRegionsTask(seqObj,settings.getSpanIntronExonBoundarySettings().mRnaSeqId); addSubTask(findExonsTask); } else { searchTask = new Primer3SWTask(settings); addSubTask(searchTask); } } QList<Task *> Primer3ToAnnotationsTask::onSubTaskFinished(Task *subTask) { QList<Task*> res; if (isCanceled() || hasError()) { return res; } if (!subTask->isFinished()) { return res; } if (subTask == findExonsTask) { QList<U2Region> regions = findExonsTask->getRegions(); if (regions.isEmpty()) { setError(tr("No exons are found in the sequence. Please, make sure corresponding RNA sequence id (%1) is selected correctly.")); return res; } // TODO: think how to include other regions const U2Region& firstRegion = regions.first(); int intronStart = firstRegion.endPos() - settings.getSpanIntronExonBoundarySettings().minLeftOverlap; int intronEnd = firstRegion.endPos() + settings.getSpanIntronExonBoundarySettings().minRightOverlap; if (regions.size() > 1 || settings.getSpanIntronExonBoundarySettings().spanIntron) { const U2Region& secondRegion = regions.at(1); intronEnd = secondRegion.startPos + settings.getSpanIntronExonBoundarySettings().minRightOverlap; } QList<QPair<int,int> > targets = settings.getTarget(); targets.append(QPair<int,int>(intronStart,intronEnd)); settings.setTarget(targets); searchTask = new Primer3SWTask(settings); res.append(searchTask); } return res; } QString Primer3ToAnnotationsTask::generateReport() const { QString res; if (hasError() || isCanceled()) { return res; } foreach(Primer3Task *t, searchTask->regionTasks) { t->sumStat(&searchTask->settings); } oligo_stats leftStats = searchTask->settings.getSeqArgs()->left_expl; oligo_stats rightStats = searchTask->settings.getSeqArgs()->right_expl; pair_stats pairStats = searchTask->settings.getSeqArgs()->pair_expl; if(!leftStats.considered) { leftStats.considered = leftStats.ns + leftStats.target + leftStats.excluded + leftStats.gc + leftStats.gc_clamp + leftStats.temp_min + leftStats.temp_max + leftStats.compl_any + leftStats.compl_end + leftStats.poly_x + leftStats.stability + leftStats.ok; } if(!rightStats.considered) { rightStats.considered = rightStats.ns + rightStats.target + rightStats.excluded + rightStats.gc + rightStats.gc_clamp + rightStats.temp_min + rightStats.temp_max + rightStats.compl_any + rightStats.compl_end + rightStats.poly_x + rightStats.stability + rightStats.ok; } res+="<table cellspacing='7'>"; res += "<tr><th>Statistics</th></tr>\n"; res += QString("<tr><th></th> <th>con</th> <th>too</th> <th>in</th> <th>in</th> <th></th> <th>no</th> <th>tm</th> <th>tm</th> <th>high</th> <th>high</th> <th></th> <th>high</th> <th></th></tr>"); res += QString("<tr><th></th> <th>sid</th> <th>many</th> <th>tar</th> <th>excl</th> <th>bag</th> <th>GC</th> <th>too</th> <th>too</th> <th>any</th> <th>3'</th> <th>poly</th> <th>end</th> <th></th></tr>"); res += QString("<tr><th></th> <th>ered</th> <th>Ns</th> <th>get</th> <th>reg</th> <th>GC&#37;</th> <th>clamp</th> <th>low</th> <th>high</th> <th>compl</th> <th>compl</th> <th>X</th> <th>stab</th> <th>ok</th></tr>"); res += QString("<tr><th>Left</th><th> %1 </th><th> %2 </th><th> %3 </th><th> %4 </th><th> %5 </th><th> %6 </th><th> %7 </th><th> %8 </th><th> %9 </th><th> %10 </th><th> %11 </th><th> %12 </th><th> %13 </th></tr>") .arg(leftStats.considered).arg(leftStats.ns).arg(leftStats.target).arg(leftStats.excluded).arg(leftStats.gc).arg(leftStats.gc_clamp).arg(leftStats.temp_min).arg(leftStats.temp_max) .arg(leftStats.compl_any).arg(leftStats.compl_end).arg(leftStats.poly_x).arg(leftStats.stability).arg(leftStats.ok); res += QString("<tr><th>Right</th><th> %1 </th><th> %2 </th><th> %3 </th><th> %4 </th><th> %5 </th><th> %6 </th><th> %7 </th><th> %8 </th><th> %9 </th><th> %10 </th><th> %11 </th><th> %12 </th><th> %13 </th></tr>") .arg(rightStats.considered).arg(rightStats.ns).arg(rightStats.target).arg(rightStats.excluded).arg(rightStats.gc).arg(rightStats.gc_clamp).arg(rightStats.temp_min).arg(rightStats.temp_max) .arg(rightStats.compl_any).arg(rightStats.compl_end).arg(rightStats.poly_x).arg(rightStats.stability).arg(rightStats.ok); res+="</table>"; res += "<br>Pair stats:<br>"; res += QString("considered %1, unacceptable product size %2, high end compl %3, ok %4.") .arg(pairStats.considered).arg(pairStats.product).arg(pairStats.compl_end).arg(pairStats.ok); return res; } Task::ReportResult Primer3ToAnnotationsTask::report() { if (hasError() || isCanceled()) { return ReportResult_Finished; } assert( searchTask ); QList<PrimerPair> bestPairs = searchTask->getBestPairs(); int index = 0; foreach(PrimerPair pair, bestPairs) { QList<SharedAnnotationData> annotations; if(NULL != pair.getLeftPrimer()) { annotations.append(oligoToAnnotation("primer", *pair.getLeftPrimer(), pair.getProductSize(), U2Strand::Direct)); } if(NULL != pair.getInternalOligo()) { annotations.append(oligoToAnnotation("internalOligo", *pair.getInternalOligo(), pair.getProductSize(), U2Strand::Direct)); } if(NULL != pair.getRightPrimer()) { annotations.append(oligoToAnnotation("primer", *pair.getRightPrimer(), pair.getProductSize(), U2Strand::Complementary)); } AppContext::getTaskScheduler()->registerTopLevelTask( new CreateAnnotationsTask(aobj, groupName + "/pair " + QString::number(index + 1), annotations)); index++; } return ReportResult_Finished; } SharedAnnotationData Primer3ToAnnotationsTask::oligoToAnnotation(QString title, const Primer &primer, int productSize, U2Strand strand) { SharedAnnotationData annotationData(new AnnotationData()); annotationData->name = title; int start = primer.getStart(); int length = primer.getLength(); if (strand == U2Strand::Complementary) { start -= length - 1; } annotationData->setStrand(strand); annotationData->location->regions << U2Region(start, length); annotationData->qualifiers.append(U2Qualifier("tm", QString::number(primer.getMeltingTemperature()))); annotationData->qualifiers.append(U2Qualifier("gc%", QString::number(primer.getGcContent()))); annotationData->qualifiers.append(U2Qualifier("any", QString::number(0.01*primer.getSelfAny()))); annotationData->qualifiers.append(U2Qualifier("3'", QString::number(0.01*primer.getSelfEnd()))); annotationData->qualifiers.append(U2Qualifier("product_size", QString::number(productSize))); return annotationData; } } // namespace
33.727147
219
0.66909
iganna
85a18b33b0e57de1af303a5730d694bb85701870
1,751
cpp
C++
tightvnc/win-system/DynamicLibrary.cpp
jjzhang166/qmlvncviewer2
b888c416ab88b81fe802ab0559bb87361833a0b5
[ "Apache-2.0" ]
47
2016-08-17T03:18:32.000Z
2022-01-14T01:33:15.000Z
tightvnc/win-system/DynamicLibrary.cpp
jjzhang166/qmlvncviewer2
b888c416ab88b81fe802ab0559bb87361833a0b5
[ "Apache-2.0" ]
3
2018-06-29T06:13:28.000Z
2020-11-26T02:31:49.000Z
tightvnc/win-system/DynamicLibrary.cpp
jjzhang166/qmlvncviewer2
b888c416ab88b81fe802ab0559bb87361833a0b5
[ "Apache-2.0" ]
15
2016-08-17T07:03:55.000Z
2021-08-02T14:42:02.000Z
// Copyright (C) 2009,2010,2011,2012 GlavSoft LLC. // All rights reserved. // //------------------------------------------------------------------------- // This file is part of the TightVNC software. Please visit our Web site: // // http://www.tightvnc.com/ // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. //------------------------------------------------------------------------- // #include "DynamicLibrary.h" #include <crtdbg.h> DynamicLibrary::DynamicLibrary(const TCHAR *filename) : m_module(0) { init(filename); } DynamicLibrary::DynamicLibrary() : m_module(0) { } DynamicLibrary::~DynamicLibrary() { if (m_module != 0) { FreeLibrary(m_module); } } void DynamicLibrary::init(const TCHAR *filename) { m_module = LoadLibrary(filename); if (m_module == 0) { StringStorage errMsg; errMsg.format(_T("%s library not found"), filename); throw Exception(errMsg.getString()); } } FARPROC DynamicLibrary::getProcAddress(const char *procName) { _ASSERT(m_module != 0); return ::GetProcAddress(m_module, procName); }
26.530303
75
0.649343
jjzhang166
85a8a6b10f2ae79f6d883c916966b6b98a62618d
1,506
hpp
C++
include/dish2/record/global_records_finalize.hpp
mmore500/dishtiny
9fcb52c4e56c74a4e17f7d577143ed40c158c92e
[ "MIT" ]
29
2019-02-04T02:39:52.000Z
2022-01-28T10:06:26.000Z
include/dish2/record/global_records_finalize.hpp
mmore500/dishtiny
9fcb52c4e56c74a4e17f7d577143ed40c158c92e
[ "MIT" ]
95
2020-02-22T19:48:14.000Z
2021-09-14T19:17:53.000Z
include/dish2/record/global_records_finalize.hpp
mmore500/dishtiny
9fcb52c4e56c74a4e17f7d577143ed40c158c92e
[ "MIT" ]
6
2019-11-19T10:13:09.000Z
2021-03-25T17:35:32.000Z
#pragma once #ifndef DISH2_RECORD_GLOBAL_RECORDS_FINALIZE_HPP_INCLUDE #define DISH2_RECORD_GLOBAL_RECORDS_FINALIZE_HPP_INCLUDE #include <cstdlib> #include "../../../third-party/conduit/include/uitsl/debug/err_verify.hpp" #include "../../../third-party/conduit/include/uitsl/debug/list_cwd.hpp" #include "../../../third-party/conduit/include/uitsl/mpi/audited_routines.hpp" #include "../../../third-party/conduit/include/uitsl/mpi/comm_utils.hpp" #include "finalize/finalize_artifacts.hpp" #include "finalize/finalize_benchmarks.hpp" #include "finalize/finalize_data.hpp" #include "finalize/finalize_drawings.hpp" #include "finalize/finalize_videos.hpp" #include "finalize/finalize_zips.hpp" #include "finalize/try_animate_frames.hpp" #include "finalize/try_create_montage.hpp" namespace dish2 { void global_records_finalize() { UITSL_Barrier( MPI_COMM_WORLD ); if ( uitsl::is_root() ) { if ( dish2::cfg.ANIMATE_FRAMES() ) try_animate_frames(); if ( dish2::cfg.ALL_DRAWINGS_WRITE() || dish2::cfg.SELECTED_DRAWINGS().size() ) finalize_drawings(); finalize_artifacts(); finalize_benchmarks(); finalize_data(); finalize_videos(); finalize_zips(); #ifndef __EMSCRIPTEN__ // hash all files, excluding source directory uitsl::err_verify( std::system( "tree --du -h" ) ); #else uitsl::list_cwd(); #endif // #ifndef __EMSCRIPTEN__ } } } // namespace dish2 #endif // #ifndef DISH2_RECORD_GLOBAL_RECORDS_FINALIZE_HPP_INCLUDE
28.415094
78
0.731076
mmore500
85a95df74baa0d5171c000bcde253f924c623d5d
4,791
hpp
C++
contrib/autoboost/autoboost/mpl/aux_/logical_op.hpp
CaseyCarter/autowiring
48e95a71308318c8ffb7ed1348e034fd9110f70c
[ "Apache-2.0" ]
87
2015-01-18T00:43:06.000Z
2022-02-11T17:40:50.000Z
contrib/autoboost/autoboost/mpl/aux_/logical_op.hpp
CaseyCarter/autowiring
48e95a71308318c8ffb7ed1348e034fd9110f70c
[ "Apache-2.0" ]
274
2015-01-03T04:50:49.000Z
2021-03-08T09:01:09.000Z
contrib/autoboost/autoboost/mpl/aux_/logical_op.hpp
CaseyCarter/autowiring
48e95a71308318c8ffb7ed1348e034fd9110f70c
[ "Apache-2.0" ]
15
2015-09-30T20:58:43.000Z
2020-12-19T21:24:56.000Z
// Copyright Aleksey Gurtovoy 2000-2004 // // 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) // // See http://www.boost.org/libs/mpl for documentation. // $Id$ // $Date$ // $Revision$ // NO INCLUDE GUARDS, THE HEADER IS INTENDED FOR MULTIPLE INCLUSION! #if !defined(AUTOBOOST_MPL_PREPROCESSING_MODE) # include <autoboost/mpl/bool.hpp> # include <autoboost/mpl/aux_/nested_type_wknd.hpp> # include <autoboost/mpl/aux_/na_spec.hpp> # include <autoboost/mpl/aux_/lambda_support.hpp> #endif #include <autoboost/mpl/limits/arity.hpp> #include <autoboost/mpl/aux_/preprocessor/params.hpp> #include <autoboost/mpl/aux_/preprocessor/ext_params.hpp> #include <autoboost/mpl/aux_/preprocessor/def_params_tail.hpp> #include <autoboost/mpl/aux_/preprocessor/enum.hpp> #include <autoboost/mpl/aux_/preprocessor/sub.hpp> #include <autoboost/mpl/aux_/config/ctps.hpp> #include <autoboost/mpl/aux_/config/workaround.hpp> #include <autoboost/preprocessor/dec.hpp> #include <autoboost/preprocessor/inc.hpp> #include <autoboost/preprocessor/cat.hpp> namespace autoboost { namespace mpl { # define AUX778076_PARAMS(param, sub) \ AUTOBOOST_MPL_PP_PARAMS( \ AUTOBOOST_MPL_PP_SUB(AUTOBOOST_MPL_LIMIT_METAFUNCTION_ARITY, sub) \ , param \ ) \ /**/ # define AUX778076_SHIFTED_PARAMS(param, sub) \ AUTOBOOST_MPL_PP_EXT_PARAMS( \ 2, AUTOBOOST_MPL_PP_SUB(AUTOBOOST_PP_INC(AUTOBOOST_MPL_LIMIT_METAFUNCTION_ARITY), sub) \ , param \ ) \ /**/ # define AUX778076_SPEC_PARAMS(param) \ AUTOBOOST_MPL_PP_ENUM( \ AUTOBOOST_PP_DEC(AUTOBOOST_MPL_LIMIT_METAFUNCTION_ARITY) \ , param \ ) \ /**/ namespace aux { #if !defined(AUTOBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) template< bool C_, AUX778076_PARAMS(typename T, 1) > struct AUTOBOOST_PP_CAT(AUX778076_OP_NAME,impl) : AUTOBOOST_PP_CAT(AUX778076_OP_VALUE1,_) { }; template< AUX778076_PARAMS(typename T, 1) > struct AUTOBOOST_PP_CAT(AUX778076_OP_NAME,impl)< AUX778076_OP_VALUE2,AUX778076_PARAMS(T, 1) > : AUTOBOOST_PP_CAT(AUX778076_OP_NAME,impl)< AUTOBOOST_MPL_AUX_NESTED_TYPE_WKND(T1)::value , AUX778076_SHIFTED_PARAMS(T, 1) , AUTOBOOST_PP_CAT(AUX778076_OP_VALUE2,_) > { }; template<> struct AUTOBOOST_PP_CAT(AUX778076_OP_NAME,impl)< AUX778076_OP_VALUE2 , AUX778076_SPEC_PARAMS(AUTOBOOST_PP_CAT(AUX778076_OP_VALUE2,_)) > : AUTOBOOST_PP_CAT(AUX778076_OP_VALUE2,_) { }; #else template< bool C_ > struct AUTOBOOST_PP_CAT(AUX778076_OP_NAME,impl) { template< AUX778076_PARAMS(typename T, 1) > struct result_ : AUTOBOOST_PP_CAT(AUX778076_OP_VALUE1,_) { }; }; template<> struct AUTOBOOST_PP_CAT(AUX778076_OP_NAME,impl)<AUX778076_OP_VALUE2> { template< AUX778076_PARAMS(typename T, 1) > struct result_ : AUTOBOOST_PP_CAT(AUX778076_OP_NAME,impl)< AUTOBOOST_MPL_AUX_NESTED_TYPE_WKND(T1)::value >::template result_< AUX778076_SHIFTED_PARAMS(T,1),AUTOBOOST_PP_CAT(AUX778076_OP_VALUE2,_) > { }; #if AUTOBOOST_WORKAROUND(AUTOBOOST_MSVC, == 1300) template<> struct result_<AUX778076_SPEC_PARAMS(AUTOBOOST_PP_CAT(AUX778076_OP_VALUE2,_))> : AUTOBOOST_PP_CAT(AUX778076_OP_VALUE2,_) { }; }; #else }; template<> struct AUTOBOOST_PP_CAT(AUX778076_OP_NAME,impl)<AUX778076_OP_VALUE2> ::result_< AUX778076_SPEC_PARAMS(AUTOBOOST_PP_CAT(AUX778076_OP_VALUE2,_)) > : AUTOBOOST_PP_CAT(AUX778076_OP_VALUE2,_) { }; #endif // AUTOBOOST_MSVC == 1300 #endif // AUTOBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION } // namespace aux template< typename AUTOBOOST_MPL_AUX_NA_PARAM(T1) , typename AUTOBOOST_MPL_AUX_NA_PARAM(T2) AUTOBOOST_MPL_PP_DEF_PARAMS_TAIL(2, typename T, AUTOBOOST_PP_CAT(AUX778076_OP_VALUE2,_)) > struct AUX778076_OP_NAME #if !defined(AUTOBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) : aux::AUTOBOOST_PP_CAT(AUX778076_OP_NAME,impl)< AUTOBOOST_MPL_AUX_NESTED_TYPE_WKND(T1)::value , AUX778076_SHIFTED_PARAMS(T,0) > #else : aux::AUTOBOOST_PP_CAT(AUX778076_OP_NAME,impl)< AUTOBOOST_MPL_AUX_NESTED_TYPE_WKND(T1)::value >::template result_< AUX778076_SHIFTED_PARAMS(T,0) > #endif { AUTOBOOST_MPL_AUX_LAMBDA_SUPPORT( AUTOBOOST_MPL_LIMIT_METAFUNCTION_ARITY , AUX778076_OP_NAME , (AUX778076_PARAMS(T, 0)) ) }; AUTOBOOST_MPL_AUX_NA_SPEC2( 2 , AUTOBOOST_MPL_LIMIT_METAFUNCTION_ARITY , AUX778076_OP_NAME ) }} #undef AUX778076_SPEC_PARAMS #undef AUX778076_SHIFTED_PARAMS #undef AUX778076_PARAMS #undef AUX778076_OP_NAME #undef AUX778076_OP_VALUE1 #undef AUX778076_OP_VALUE2
28.861446
104
0.736798
CaseyCarter
85a9c3645576374a0825d30068d3a73f82dd6ac9
2,331
hpp
C++
Public/Expected/Details/BaseCopy.hpp
doctor-fate/expected
1cfa9a1fe6700c49a4cc5c65301559a0b373a692
[ "MIT" ]
1
2021-07-10T09:54:18.000Z
2021-07-10T09:54:18.000Z
Public/Expected/Details/BaseCopy.hpp
doctor-fate/expected
1cfa9a1fe6700c49a4cc5c65301559a0b373a692
[ "MIT" ]
null
null
null
Public/Expected/Details/BaseCopy.hpp
doctor-fate/expected
1cfa9a1fe6700c49a4cc5c65301559a0b373a692
[ "MIT" ]
null
null
null
#pragma once #include "BaseDestructor.hpp" namespace stdx::details { enum class EConstructorSelector { Disabled, Trivial, NonTrivial }; template <typename T, typename E> constexpr EConstructorSelector SelectCopyConstructor() noexcept { if constexpr (VoidOrTriviallyCopyConstructible<T>() && TriviallyCopyConstructible<E>()) { return EConstructorSelector::Trivial; } else if constexpr (VoidOrCopyConstructible<T>() && CopyConstructible<E>()) { return EConstructorSelector::NonTrivial; } else { return EConstructorSelector::Disabled; } } template <typename T, typename E, EConstructorSelector = SelectCopyConstructor<T, E>()> struct BaseCopyConstructor : BaseDestructor<T, E> { using Super = BaseDestructor<T, E>; using Super::Super; BaseCopyConstructor() = default; BaseCopyConstructor(const BaseCopyConstructor&) = delete; BaseCopyConstructor(BaseCopyConstructor&&) = default; BaseCopyConstructor& operator=(const BaseCopyConstructor&) = default; BaseCopyConstructor& operator=(BaseCopyConstructor&&) = default; }; template <typename T, typename E> struct BaseCopyConstructor<T, E, EConstructorSelector::Trivial> : BaseDestructor<T, E> { using Super = BaseDestructor<T, E>; using Super::Super; }; template <typename T, typename E> struct BaseCopyConstructor<T, E, EConstructorSelector::NonTrivial> : BaseDestructor<T, E> { using Super = BaseDestructor<T, E>; using Super::Super; BaseCopyConstructor() = default; constexpr BaseCopyConstructor(const BaseCopyConstructor& Other) noexcept( VoidOrNothrowCopyConstructible<T>() && NothrowCopyConstructible<E>()) { if (Other.HasValue()) { if constexpr (!IsVoid<T>()) { Super::ConstructValue(*Other); } } else { Super::ConstructUnexpected(Other.Error()); } Super::bHasValue = Other.bHasValue; } BaseCopyConstructor(BaseCopyConstructor&&) = default; BaseCopyConstructor& operator=(const BaseCopyConstructor&) = default; BaseCopyConstructor& operator=(BaseCopyConstructor&&) = default; }; }
34.791045
97
0.648649
doctor-fate
85b0c4fb364783a7874cf6a4da39e9523835dede
666
cpp
C++
server/memory.cpp
FaresMehanna/Monitor-And-Control-Server-Room
29caea1501a5174c63ba87c47545c889b9cf2e51
[ "MIT" ]
null
null
null
server/memory.cpp
FaresMehanna/Monitor-And-Control-Server-Room
29caea1501a5174c63ba87c47545c889b9cf2e51
[ "MIT" ]
null
null
null
server/memory.cpp
FaresMehanna/Monitor-And-Control-Server-Room
29caea1501a5174c63ba87c47545c889b9cf2e51
[ "MIT" ]
null
null
null
#include <stdio.h> #include <pthread.h> #include <unistd.h> #include <stdlib.h> #include "device.h" #include "memory.h" void acquire(DeviceData* device_data) { printf("acquire.\n"); pthread_mutex_lock(&(device_data->itmes_mutex)); (device_data->memory_pointers)++; pthread_mutex_unlock(&(device_data->itmes_mutex)); } void release(DeviceData* device_data) { printf("release.\n"); pthread_mutex_lock(&(device_data->itmes_mutex)); (device_data->memory_pointers)--; if(0 == device_data->memory_pointers) { close(device_data->sockfd); delete(device_data); printf("delete.\n"); } pthread_mutex_unlock(&(device_data->itmes_mutex)); }
26.64
54
0.71021
FaresMehanna
85b1838fdc34e86335c44941f09cd5104ecc0cf1
3,988
cpp
C++
src/loader/ImageIO.cpp
PearCoding/PearRay
8654a7dcd55cc67859c7c057c7af64901bf97c35
[ "MIT" ]
19
2016-11-07T00:01:19.000Z
2021-12-29T05:35:14.000Z
src/loader/ImageIO.cpp
PearCoding/PearRay
8654a7dcd55cc67859c7c057c7af64901bf97c35
[ "MIT" ]
33
2016-07-06T21:58:05.000Z
2020-08-01T18:18:24.000Z
src/loader/ImageIO.cpp
PearCoding/PearRay
8654a7dcd55cc67859c7c057c7af64901bf97c35
[ "MIT" ]
null
null
null
#include "ImageIO.h" #include "Logger.h" #include "config/Build.h" #include <OpenImageIO/imageio.h> namespace PR { bool ImageIO::save(const std::filesystem::path& path, const float* data, size_t width, size_t height, size_t channels, const ImageSaveOptions& opts) { OIIO::ImageSpec spec(width, height, channels, OIIO::TypeFloat); const std::string versionStr = Build::getVersionString(); spec.attribute("PixelAspectRatio", 1.0f); spec.attribute("Software", "PearRay " + versionStr); spec.attribute("IPTC:ProgramVersion", versionStr); if (opts.Parametric) { spec.attribute("oiio:ColorSpace", "PRParametric"); spec.attribute("oiio:Gamma", 1.0f); spec.attribute("PR:Parametric", "true"); spec.attribute("oiio:RawColor", 1); spec.attribute("compression", "piz"); spec.channelnames.clear(); spec.channelnames.push_back("coeff.A"); spec.channelnames.push_back("coeff.B"); spec.channelnames.push_back("coeff.C"); } else { spec.attribute("compression", "pxr24"); } if (channels > 3) { spec.channelnames.resize(channels); for (size_t i = 0; i < channels; ++i) spec.channelnames[i] = "Value_" + std::to_string(i + 1); } auto out = OIIO::ImageOutput::create(path.string()); if (!out) { PR_LOG(L_ERROR) << "[Output] Could not create output context for file " << path << ", error = " << OIIO::geterror() << std::endl; return false; } if (!out->open(path.generic_string(), spec)) { PR_LOG(L_ERROR) << "[Output] Could not open file " << path << ", error = " << out->geterror() << std::endl; #if OIIO_PLUGIN_VERSION < 22 OIIO::ImageOutput::destroy(out); #endif return false; } if (!out->write_image(OIIO::TypeUnknown, data)) { PR_LOG(L_ERROR) << "[Output] Could not write pixels to " << path << ", error = " << out->geterror() << std::endl; #if OIIO_PLUGIN_VERSION < 22 OIIO::ImageOutput::destroy(out); #endif return false; } if (!out->close()) { PR_LOG(L_ERROR) << "[Output] Could not close file " << path << ", error = " << out->geterror() << std::endl; #if OIIO_PLUGIN_VERSION < 22 OIIO::ImageOutput::destroy(out); #endif return false; } #if OIIO_PLUGIN_VERSION < 22 OIIO::ImageOutput::destroy(out); #endif return true; } bool ImageIO::load(const std::filesystem::path& path, std::vector<float>& data, size_t& width, size_t& height, size_t& channels) { auto in = OIIO::ImageInput::open(path.string()); if (!in) { PR_LOG(L_ERROR) << "[Input] Could not open file " << path << ", error = " << OIIO::geterror() << std::endl; return false; } const OIIO::ImageSpec spec = in->spec(); width = std::max(0, spec.width); height = std::max(0, spec.height); channels = std::max(0, spec.nchannels); if (width * height * channels == 0) { PR_LOG(L_ERROR) << "[Input] Image file " << path << " has bad specifications" << std::endl; #if OIIO_PLUGIN_VERSION < 22 OIIO::ImageInput::destroy(in); #endif return false; } const float gamma = spec.get_float_attribute("oiio:Gamma", 1.0f); const bool isSRGB = spec.get_string_attribute("oiio:ColorSpace") == "sRGB"; data.resize(width * height * channels); if (!in->read_image(OIIO::TypeFloat, data.data())) { PR_LOG(L_ERROR) << "[Input] Could not read file " << path << ", error = " << in->geterror() << std::endl; #if OIIO_PLUGIN_VERSION < 22 OIIO::ImageInput::destroy(in); #endif } if (!in->close()) { PR_LOG(L_ERROR) << "[Input] Could not close file " << path << ", error = " << in->geterror() << std::endl; #if OIIO_PLUGIN_VERSION < 22 OIIO::ImageInput::destroy(in); #endif } #if OIIO_PLUGIN_VERSION < 22 OIIO::ImageInput::destroy(in); #endif // Map to linear if (isSRGB) { const auto map = [](float u) { if (u <= 0.04045f) return u / 12.92f; else return std::pow((u + 0.055f) / 1.055f, 2.4f); }; //PR_OPT_LOOP for (float& v : data) v = map(v); } else if (gamma != 1.0f) { const float invGamma = 1 / gamma; //PR_OPT_LOOP for (float& v : data) v = std::pow(v, invGamma); } return true; } } // namespace PR
28.690647
148
0.650201
PearCoding
85b9aed1dcde728eecce0366c3f190a1540c442b
224
cpp
C++
various/COP3330/lect9/sample9.cpp
chgogos/oop
3b0e6bbd29a76f863611e18d082913f080b1b571
[ "MIT" ]
14
2019-04-23T13:45:10.000Z
2022-03-12T18:26:47.000Z
various/COP3330/lect9/sample9.cpp
chgogos/oop
3b0e6bbd29a76f863611e18d082913f080b1b571
[ "MIT" ]
null
null
null
various/COP3330/lect9/sample9.cpp
chgogos/oop
3b0e6bbd29a76f863611e18d082913f080b1b571
[ "MIT" ]
9
2019-09-01T15:17:45.000Z
2020-11-13T20:31:36.000Z
#include <iostream> #include <stdio.h> using namespace std; int main() { int MyInt = 4; int &MyIntRef = MyInt; int *MyIntPtr; MyIntPtr = &MyIntRef; cout << *MyIntPtr << "\n"; return 0; } /* 4 */
10.666667
30
0.558036
chgogos
85bc42eec3122deae4f4f2cb2c166a236d58a2a3
60,580
cpp
C++
corokafka/impl/corokafka_consumer_manager_impl.cpp
gridgentoo/corokafka
23705484d7126771c012e04304499aa06dbc88c7
[ "Apache-2.0" ]
null
null
null
corokafka/impl/corokafka_consumer_manager_impl.cpp
gridgentoo/corokafka
23705484d7126771c012e04304499aa06dbc88c7
[ "Apache-2.0" ]
null
null
null
corokafka/impl/corokafka_consumer_manager_impl.cpp
gridgentoo/corokafka
23705484d7126771c012e04304499aa06dbc88c7
[ "Apache-2.0" ]
null
null
null
/* ** Copyright 2019 Bloomberg Finance L.P. ** ** 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 <corokafka/impl/corokafka_consumer_manager_impl.h> #include <cppkafka/macros.h> #include <cmath> #include <tuple> using namespace std::placeholders; namespace Bloomberg { namespace corokafka { //=========================================================================================== // class ConsumerManagerImpl //=========================================================================================== ConsumerManagerImpl::ConsumerManagerImpl(quantum::Dispatcher& dispatcher, const ConnectorConfiguration& connectorConfiguration, const ConfigMap& configs) : _dispatcher(dispatcher) { //Create a consumer for each topic and apply the appropriate configuration for (const auto& entry : configs) { // Process each configuration auto it = _consumers.emplace(entry.first, ConsumerTopicEntry(nullptr, connectorConfiguration, entry.second, dispatcher.getNumIoThreads(), dispatcher.getCoroQueueIdRangeForAny())); setup(entry.first, it.first->second); } } ConsumerManagerImpl::ConsumerManagerImpl(quantum::Dispatcher& dispatcher, const ConnectorConfiguration& connectorConfiguration, ConfigMap&& configs) : _dispatcher(dispatcher) { //Create a consumer for each topic and apply the appropriate configuration for (auto&& entry : configs) { // Process each configuration auto it = _consumers.emplace(entry.first, ConsumerTopicEntry(nullptr, connectorConfiguration, std::move(entry.second), dispatcher.getNumIoThreads(), dispatcher.getCoroQueueIdRangeForAny())); setup(entry.first, it.first->second); } } ConsumerManagerImpl::~ConsumerManagerImpl() { shutdown(); } void ConsumerManagerImpl::setup(const std::string& topic, ConsumerTopicEntry& topicEntry) { const Configuration::Options& rdKafkaOptions = topicEntry._configuration.getOptions(Configuration::OptionType::RdKafka); const Configuration::Options& rdKafkaTopicOptions = topicEntry._configuration.getTopicOptions(Configuration::OptionType::RdKafka); const Configuration::Options& internalOptions = topicEntry._configuration.getOptions(Configuration::OptionType::Internal); //Validate config const cppkafka::ConfigurationOption* brokerList = Configuration::findOption("metadata.broker.list", rdKafkaOptions); if (!brokerList) { throw std::runtime_error(std::string("Consumer broker list not found. Please set 'metadata.broker.list' for topic ") + topic); } //Set the rdkafka configuration options cppkafka::Configuration kafkaConfig(rdKafkaOptions); kafkaConfig.set_default_topic_configuration(cppkafka::TopicConfiguration(rdKafkaTopicOptions)); const cppkafka::ConfigurationOption* autoThrottle = Configuration::findOption("internal.consumer.auto.throttle", internalOptions); if (autoThrottle) { topicEntry._throttleControl.autoThrottle() = StringEqualCompare()(autoThrottle->get_value(), "true"); } const cppkafka::ConfigurationOption* throttleMultiplier = Configuration::findOption("internal.consumer.auto.throttle.multiplier", internalOptions); if (throttleMultiplier) { topicEntry._throttleControl.throttleMultiplier() = std::stol(throttleMultiplier->get_value()); } //Set the global callbacks if (topicEntry._configuration.getErrorCallback()) { auto errorFunc = std::bind(errorCallback2, std::ref(topicEntry), _1, _2, _3); kafkaConfig.set_error_callback(std::move(errorFunc)); } if (topicEntry._configuration.getThrottleCallback() || topicEntry._throttleControl.autoThrottle()) { auto throttleFunc = std::bind(throttleCallback, std::ref(topicEntry), _1, _2, _3, _4); kafkaConfig.set_throttle_callback(std::move(throttleFunc)); } if (topicEntry._configuration.getLogCallback()) { auto logFunc = std::bind(logCallback, std::ref(topicEntry), _1, _2, _3, _4); kafkaConfig.set_log_callback(std::move(logFunc)); } if (topicEntry._configuration.getStatsCallback()) { auto statsFunc = std::bind(statsCallback, std::ref(topicEntry), _1, _2); kafkaConfig.set_stats_callback(std::move(statsFunc)); } if (topicEntry._configuration.getOffsetCommitCallback()) { auto offsetCommitFunc = std::bind(offsetCommitCallback, std::ref(topicEntry), _1, _2, _3); kafkaConfig.set_offset_commit_callback(std::move(offsetCommitFunc)); } if (topicEntry._configuration.getPreprocessorCallback()) { topicEntry._preprocessorCallback = std::bind(preprocessorCallback, std::ref(topicEntry), _1); } const cppkafka::ConfigurationOption* autoPersist = Configuration::findOption("internal.consumer.auto.offset.persist", internalOptions); if (autoPersist) { topicEntry._autoOffsetPersist = StringEqualCompare()(autoPersist->get_value(), "true"); } const cppkafka::ConfigurationOption* persistStrategy = Configuration::findOption("internal.consumer.offset.persist.strategy", internalOptions); if (persistStrategy) { if (StringEqualCompare()(persistStrategy->get_value(), "commit")) { topicEntry._autoOffsetPersistStrategy = OffsetPersistStrategy::Commit; } else if (StringEqualCompare()(persistStrategy->get_value(), "store")) { topicEntry._autoOffsetPersistStrategy = OffsetPersistStrategy::Store; } else { throw std::runtime_error("Unknown internal.consumer.offset.persist.strategy value"); } } const cppkafka::ConfigurationOption* autoPersistOnException = Configuration::findOption("internal.consumer.auto.offset.persist.on.exception", internalOptions); if (autoPersistOnException) { topicEntry._autoOffsetPersistOnException = StringEqualCompare()(autoPersist->get_value(), "true"); } const cppkafka::ConfigurationOption* commitExec = Configuration::findOption("internal.consumer.commit.exec", internalOptions); if (commitExec) { if (StringEqualCompare()(commitExec->get_value(), "sync")) { topicEntry._autoCommitExec = ExecMode::Sync; } else if (StringEqualCompare()(commitExec->get_value(), "async")) { topicEntry._autoCommitExec = ExecMode::Async; } else { throw std::runtime_error("Unknown internal.consumer.commit.exec value"); } } // Set underlying rdkafka options if (topicEntry._autoOffsetPersist) { kafkaConfig.set("enable.auto.offset.store", false); if (topicEntry._autoOffsetPersistStrategy == OffsetPersistStrategy::Commit) { kafkaConfig.set("enable.auto.commit", false); kafkaConfig.set("auto.commit.interval.ms", 0); } else { kafkaConfig.set("enable.auto.commit", true); } } bool roundRobinPolling = false; //default is batch const cppkafka::ConfigurationOption* pollStrategy = Configuration::findOption("internal.consumer.poll.strategy", internalOptions); if (pollStrategy) { if (StringEqualCompare()(pollStrategy->get_value(), "roundrobin")) { roundRobinPolling = true; } else if (!StringEqualCompare()(pollStrategy->get_value(), "batch")) { throw std::runtime_error("Unknown internal.consumer.poll.strategy"); } } //======================================================================================= //DO NOT UPDATE ANY KAFKA CONFIG OPTIONS BELOW THIS POINT SINCE THE CONSUMER MAKES A COPY //======================================================================================= //Create a consumer topicEntry._consumer.reset(new cppkafka::Consumer(kafkaConfig)); topicEntry._committer.reset(new cppkafka::BackoffCommitter(*topicEntry._consumer)); if (roundRobinPolling) { topicEntry._roundRobin.reset(new cppkafka::RoundRobinPollStrategy(*topicEntry._consumer)); } auto offsetCommitErrorFunc = std::bind(&offsetCommitErrorCallback, std::ref(topicEntry), _1); topicEntry._committer->set_error_callback(offsetCommitErrorFunc); //Set internal config options const cppkafka::ConfigurationOption* pauseOnStart = Configuration::findOption("internal.consumer.pause.on.start", internalOptions); if (pauseOnStart) { topicEntry._pauseOnStart = StringEqualCompare()(pauseOnStart->get_value(), "true"); } const cppkafka::ConfigurationOption* skipUnknownHeaders = Configuration::findOption("internal.consumer.skip.unknown.headers", internalOptions); if (skipUnknownHeaders) { topicEntry._skipUnknownHeaders = StringEqualCompare()(skipUnknownHeaders->get_value(), "true"); } const cppkafka::ConfigurationOption* consumerTimeout = Configuration::findOption("internal.consumer.timeout.ms", internalOptions); if (consumerTimeout) { topicEntry._consumer->set_timeout(std::chrono::milliseconds(std::stoll(consumerTimeout->get_value()))); } const cppkafka::ConfigurationOption* pollTimeout = Configuration::findOption("internal.consumer.poll.timeout.ms", internalOptions); if (pollTimeout) { topicEntry._pollTimeout = std::chrono::milliseconds(std::stoll(pollTimeout->get_value())); } const cppkafka::ConfigurationOption* logLevel = Configuration::findOption("internal.consumer.log.level", internalOptions); if (logLevel) { cppkafka::LogLevel level = logLevelFromString(logLevel->get_value()); topicEntry._consumer->set_log_level(level); topicEntry._logLevel = level; } const cppkafka::ConfigurationOption* numRetriesOption = Configuration::findOption("internal.consumer.commit.num.retries", internalOptions); if (numRetriesOption) { topicEntry._committer->set_maximum_retries(std::stoll(numRetriesOption->get_value())); } const cppkafka::ConfigurationOption* backoffStrategyOption = Configuration::findOption("internal.consumer.commit.backoff.strategy", internalOptions); if (backoffStrategyOption) { if (StringEqualCompare()(backoffStrategyOption->get_value(), "linear")) { topicEntry._committer->set_backoff_policy(cppkafka::BackoffPerformer::BackoffPolicy::LINEAR); } else if (StringEqualCompare()(backoffStrategyOption->get_value(), "exponential")) { topicEntry._committer->set_backoff_policy(cppkafka::BackoffPerformer::BackoffPolicy::EXPONENTIAL); } else { throw std::runtime_error("Unknown internal.consumer.commit.backoff.strategy value"); } } const cppkafka::ConfigurationOption* backoffInterval = Configuration::findOption("internal.consumer.commit.backoff.interval.ms", internalOptions); if (backoffInterval) { std::chrono::milliseconds interval(std::stoll(backoffInterval->get_value())); topicEntry._committer->set_initial_backoff(interval); topicEntry._committer->set_backoff_step(interval); } const cppkafka::ConfigurationOption* maxBackoff = Configuration::findOption("internal.consumer.commit.max.backoff.ms", internalOptions); if (maxBackoff) { topicEntry._committer->set_maximum_backoff(std::chrono::milliseconds(std::stoll(maxBackoff->get_value()))); } const cppkafka::ConfigurationOption* batchSize = Configuration::findOption("internal.consumer.read.size", internalOptions); if (batchSize) { topicEntry._batchSize = std::stoll(batchSize->get_value()); } const cppkafka::ConfigurationOption* threadRangeLow = Configuration::findOption("internal.consumer.receive.callback.thread.range.low", internalOptions); if (threadRangeLow) { int value = std::stoi(threadRangeLow->get_value()); if (value < topicEntry._receiveCallbackThreadRange.first || value > topicEntry._receiveCallbackThreadRange.second) { throw std::runtime_error("Invalid value for internal.consumer.receive.callback.thread.range.low"); } topicEntry._receiveCallbackThreadRange.first = value; } const cppkafka::ConfigurationOption* threadRangeHigh = Configuration::findOption("internal.consumer.receive.callback.thread.range.high", internalOptions); if (threadRangeHigh) { int value = std::stoi(threadRangeHigh->get_value()); if (value < topicEntry._receiveCallbackThreadRange.first || value > topicEntry._receiveCallbackThreadRange.second) { throw std::runtime_error("Invalid value for internal.consumer.receive.callback.thread.range.high"); } topicEntry._receiveCallbackThreadRange.second = value; } const cppkafka::ConfigurationOption* receiveCallbackExec = Configuration::findOption("internal.consumer.receive.callback.exec", internalOptions); if (receiveCallbackExec) { if (StringEqualCompare()(receiveCallbackExec->get_value(), "sync")) { topicEntry._receiveCallbackExec = ExecMode::Sync; } else if (StringEqualCompare()(receiveCallbackExec->get_value(), "async")) { topicEntry._receiveCallbackExec = ExecMode::Async; } else { throw std::runtime_error("Unknown internal.consumer.receive.callback.exec value"); } } const cppkafka::ConfigurationOption* receiveThread = Configuration::findOption("internal.consumer.receive.invoke.thread", internalOptions); if (receiveThread) { if (StringEqualCompare()(receiveThread->get_value(), "io")) { topicEntry._receiveOnIoThread = true; } else if (StringEqualCompare()(receiveThread->get_value(), "coro")) { topicEntry._receiveOnIoThread = false; topicEntry._receiveCallbackExec = ExecMode::Sync; //override user setting } else { throw std::runtime_error("Unknown internal.consumer.receive.invoke.thread value"); } } const cppkafka::ConfigurationOption* batchPrefetch = Configuration::findOption("internal.consumer.batch.prefetch", internalOptions); if (batchPrefetch) { topicEntry._batchPrefetch = StringEqualCompare()(batchPrefetch->get_value(), "true"); } const cppkafka::ConfigurationOption* preprocessMessages = Configuration::findOption("internal.consumer.preprocess.messages", internalOptions); if (preprocessMessages) { topicEntry._preprocess = StringEqualCompare()(preprocessMessages->get_value(), "true"); } const cppkafka::ConfigurationOption* invokeThread = Configuration::findOption("internal.consumer.preprocess.invoke.thread", internalOptions); if (invokeThread) { if (StringEqualCompare()(invokeThread->get_value(), "io")) { topicEntry._preprocessOnIoThread = true; } else if (StringEqualCompare()(invokeThread->get_value(), "coro")) { topicEntry._preprocessOnIoThread = false; } else { throw std::runtime_error("Unknown internal.consumer.preprocess.invoke.thread value"); } } // Set the buffered producer callbacks if (topicEntry._configuration.getRebalanceCallback() || ((topicEntry._configuration.getPartitionStrategy() == PartitionStrategy::Dynamic) && !topicEntry._configuration.getInitialPartitionAssignment().empty())) { auto assignmentFunc = std::bind(&ConsumerManagerImpl::assignmentCallback, std::ref(topicEntry), _1); topicEntry._consumer->set_assignment_callback(std::move(assignmentFunc)); } if (topicEntry._configuration.getRebalanceCallback()) { auto revocationFunc = std::bind(&ConsumerManagerImpl::revocationCallback, std::ref(topicEntry), _1); topicEntry._consumer->set_revocation_callback(std::move(revocationFunc)); auto rebalanceErrorFunc = std::bind(&ConsumerManagerImpl::rebalanceErrorCallback, std::ref(topicEntry), _1); topicEntry._consumer->set_rebalance_error_callback(std::move(rebalanceErrorFunc)); } if (topicEntry._pauseOnStart) { topicEntry._consumer->pause(topic); } //subscribe or statically assign partitions to this consumer if (topicEntry._configuration.getPartitionStrategy() == PartitionStrategy::Static) { if ((topicEntry._configuration.getInitialPartitionAssignment().size() == 1) && (topicEntry._configuration.getInitialPartitionAssignment().front().get_partition() == RD_KAFKA_PARTITION_UA)) { //assign all partitions belonging to this topic cppkafka::TopicMetadata metadata = topicEntry._consumer->get_metadata(topicEntry._consumer->get_topic(topic)); cppkafka::TopicPartitionList partitions = cppkafka::convert(topic, metadata.get_partitions()); //set the specified offset on all partitions for (auto& p : partitions) { p.set_offset(topicEntry._configuration.getInitialPartitionAssignment().front().get_offset()); } topicEntry._consumer->assign(partitions); } else { topicEntry._consumer->assign(topicEntry._configuration.getInitialPartitionAssignment()); } } else { topicEntry._consumer->subscribe({topic}); } } ConsumerMetadata ConsumerManagerImpl::getMetadata(const std::string& topic) { auto it = findConsumer(topic); return makeMetadata(it->second); } void ConsumerManagerImpl::preprocess(bool enable, const std::string& topic) { if (topic.empty()) { for (auto&& consumer : _consumers) { consumer.second._preprocess = enable; } } else { auto it = findConsumer(topic); it->second._preprocess = enable; } } void ConsumerManagerImpl::pause(const std::string& topic) { if (topic.empty()) { for (auto&& consumer : _consumers) { consumer.second._consumer->pause(); consumer.second._isPaused = true; } } else { ConsumerTopicEntry& consumerTopicEntry = findConsumer(topic)->second; consumerTopicEntry._consumer->pause(); consumerTopicEntry._isPaused = true; } } void ConsumerManagerImpl::resume(const std::string& topic) { if (topic.empty()) { for (auto&& consumer : _consumers) { consumer.second._consumer->resume(); consumer.second._isPaused = false; } } else { auto it = _consumers.find(topic); if (it == _consumers.end()) { throw std::runtime_error("Invalid topic"); } ConsumerTopicEntry& consumerTopicEntry = findConsumer(topic)->second; consumerTopicEntry._consumer->resume(); consumerTopicEntry._isPaused = false; } } void ConsumerManagerImpl::subscribe(const std::string& topic, cppkafka::TopicPartitionList partitionList) { ConsumerTopicEntry& topicEntry = findConsumer(topic)->second; if (topicEntry._isSubscribed) { throw std::runtime_error("Already subscribed"); } //subscribe or statically assign partitions to this consumer topicEntry._isSubscribed = true; topicEntry._setOffsetsOnStart = true; if (!partitionList.empty()) { //Overwrite the initial assignment topicEntry._configuration.assignInitialPartitions(topicEntry._configuration.getPartitionStrategy(), std::move(partitionList)); } if (topicEntry._configuration.getPartitionStrategy() == PartitionStrategy::Static) { cppkafka::TopicPartitionList partitions = topicEntry._configuration.getInitialPartitionAssignment(); for (auto& partition : partitions) { partition.set_offset(RD_KAFKA_OFFSET_STORED); } topicEntry._consumer->assign(partitions); } else { topicEntry._consumer->subscribe({topic}); } } void ConsumerManagerImpl::unsubscribe(const std::string& topic) { if (topic.empty()) { for (auto&& consumer : _consumers) { if (consumer.second._isSubscribed) { if (consumer.second._configuration.getPartitionStrategy() == PartitionStrategy::Static) { consumer.second._consumer->unassign(); } else { consumer.second._consumer->unsubscribe(); } consumer.second._isSubscribed = false; } } } else { ConsumerTopicEntry& consumerTopicEntry = findConsumer(topic)->second; if (consumerTopicEntry._isSubscribed) { if (consumerTopicEntry._configuration.getPartitionStrategy() == PartitionStrategy::Static) { consumerTopicEntry._consumer->unassign(); } else { consumerTopicEntry._consumer->unsubscribe(); } } } } cppkafka::Error ConsumerManagerImpl::commit(const cppkafka::TopicPartition& topicPartition, const void* opaque, bool forceSync) { auto it = _consumers.find(topicPartition.get_topic()); if (it == _consumers.end()) { return RD_KAFKA_RESP_ERR_UNKNOWN_TOPIC_OR_PART; } return commitImpl(it->second, cppkafka::TopicPartitionList{topicPartition}, opaque, forceSync); } cppkafka::Error ConsumerManagerImpl::commit(const cppkafka::TopicPartitionList& topicPartitions, const void* opaque, bool forceSync) { if (topicPartitions.empty()) { return RD_KAFKA_RESP_ERR_INVALID_PARTITIONS; } auto it = _consumers.find(topicPartitions.at(0).get_topic()); if (it == _consumers.end()) { return RD_KAFKA_RESP_ERR_UNKNOWN_TOPIC_OR_PART; } return commitImpl(it->second, topicPartitions, opaque, forceSync); } cppkafka::Error ConsumerManagerImpl::commitImpl(ConsumerTopicEntry& entry, const cppkafka::TopicPartitionList& topicPartitions, const void* opaque, bool forceSync) { try { const cppkafka::TopicPartition& headPartition = topicPartitions.at(0); if (entry._committer->get_consumer().get_configuration().get_offset_commit_callback() && (opaque != nullptr)) { entry._offsets.insert(headPartition, opaque); } if (entry._autoOffsetPersistStrategy == OffsetPersistStrategy::Commit || forceSync) { if ((entry._autoCommitExec == ExecMode::Sync) || forceSync) { if (headPartition.get_partition() == RD_KAFKA_PARTITION_UA) { //commit the current assignment entry._committer->commit(); } else { entry._committer->commit(topicPartitions); } } else { // async if (headPartition.get_partition() == RD_KAFKA_PARTITION_UA) { //commit the current assignment entry._committer->get_consumer().async_commit(); } else { entry._committer->get_consumer().async_commit(topicPartitions); } } } else { //OffsetPersistStrategy::Store #if (RD_KAFKA_VERSION >= RD_KAFKA_STORE_OFFSETS_SUPPORT_VERSION) entry._committer->get_consumer().store_offsets(topicPartitions); #else std::ostringstream oss; oss << hex << "Current RdKafka version " << RD_KAFKA_VERSION << " does not support this functionality. Must be greater than " << RD_KAFKA_STORE_OFFSETS_SUPPORT_VERSION; throw std::runtime_error(oss.str()); #endif } } catch (const cppkafka::HandleException& ex) { return ex.get_error(); } catch (const cppkafka::ActionTerminatedException& ex) { return RD_KAFKA_RESP_ERR__FAIL; //no more retries left } catch (...) { return RD_KAFKA_RESP_ERR_UNKNOWN; } return {}; } const ConsumerConfiguration& ConsumerManagerImpl::getConfiguration(const std::string& topic) const { auto it = findConsumer(topic); return it->second._configuration; } std::vector<std::string> ConsumerManagerImpl::getTopics() const { std::vector<std::string> topics; topics.reserve(_consumers.size()); for (const auto& entry : _consumers) { topics.emplace_back(entry.first); } return topics; } void ConsumerManagerImpl::shutdown() { if (!_shutdownInitiated.test_and_set()) { unsubscribe({}); } } void ConsumerManagerImpl::poll() { auto now = std::chrono::steady_clock::now(); for (auto&& entry : _consumers) { if (!entry.second._isSubscribed) { continue; //we are no longer subscribed here } // Adjust throttling if necessary adjustThrottling(entry.second, now); bool doPoll = !entry.second._pollFuture || (entry.second._pollFuture->waitFor(std::chrono::milliseconds(0)) == std::future_status::ready); if (doPoll) { // Round-robin if (entry.second._roundRobin) { entry.second._pollFuture = _dispatcher.postFirst((int)quantum::IQueue::QueueId::Any, true, pollCoro, entry.second)-> then(processorCoro, entry.second)-> end(); } else { // Batch entry.second._pollFuture = _dispatcher.post((int)quantum::IQueue::QueueId::Any, true, pollBatchCoro, entry.second); } } } } void ConsumerManagerImpl::errorCallback2( ConsumerTopicEntry& topicEntry, cppkafka::KafkaHandleBase& handle, int error, const std::string& reason) { errorCallback(topicEntry, handle, error, reason, nullptr); } void ConsumerManagerImpl::errorCallback( ConsumerTopicEntry& topicEntry, cppkafka::KafkaHandleBase& handle, int error, const std::string& reason, cppkafka::Message* message) { cppkafka::CallbackInvoker<Callbacks::ErrorCallback> ("error", topicEntry._configuration.getErrorCallback(), &handle) (makeMetadata(topicEntry), cppkafka::Error((rd_kafka_resp_err_t)error), reason, message); } void ConsumerManagerImpl::throttleCallback( ConsumerTopicEntry& topicEntry, cppkafka::KafkaHandleBase& handle, const std::string& brokerName, int32_t brokerId, std::chrono::milliseconds throttleDuration) { if (!topicEntry._isPaused) { //calculate throttle periods cppkafka::Consumer& consumer = static_cast<cppkafka::Consumer&>(handle); ThrottleControl::Status status = topicEntry._throttleControl.handleThrottleCallback(throttleDuration); if (status._on) { consumer.pause(); } else if (status._off) { consumer.resume(); } } cppkafka::CallbackInvoker<Callbacks::ThrottleCallback> ("throttle", topicEntry._configuration.getThrottleCallback(), &handle) (makeMetadata(topicEntry), brokerName, brokerId, throttleDuration); } void ConsumerManagerImpl::logCallback( ConsumerTopicEntry& topicEntry, cppkafka::KafkaHandleBase& handle, int level, const std::string& facility, const std::string& message) { cppkafka::CallbackInvoker<Callbacks::LogCallback> ("log", topicEntry._configuration.getLogCallback(), &handle) (makeMetadata(topicEntry), static_cast<cppkafka::LogLevel>(level), facility, message); } void ConsumerManagerImpl::statsCallback( ConsumerTopicEntry& topicEntry, cppkafka::KafkaHandleBase& handle, const std::string& json) { cppkafka::CallbackInvoker<Callbacks::StatsCallback> ("stats", topicEntry._configuration.getStatsCallback(), &handle) (makeMetadata(topicEntry), json); } void ConsumerManagerImpl::offsetCommitCallback( ConsumerTopicEntry& topicEntry, cppkafka::Consumer& consumer, cppkafka::Error error, const cppkafka::TopicPartitionList& topicPartitions) { // Check if we have opaque data cppkafka::TopicPartitionList& partitions = const_cast<cppkafka::TopicPartitionList&>(topicPartitions); std::vector<const void*> opaques; if (!topicEntry._offsets.empty()) { opaques.reserve(partitions.size()); } for (auto& partition : partitions) { //subtract one since rdkafka always gives us the next offset partition.set_offset(partition.get_offset()-1); //remove the opaque values and pass them back to the application if (!topicEntry._offsets.empty()) { opaques.push_back(topicEntry._offsets.remove(partition)); } } cppkafka::CallbackInvoker<Callbacks::OffsetCommitCallback> ("offset commit", topicEntry._configuration.getOffsetCommitCallback(), &consumer) (makeMetadata(topicEntry), error, partitions, opaques); } bool ConsumerManagerImpl::offsetCommitErrorCallback( ConsumerTopicEntry& topicEntry, cppkafka::Error error) { report(topicEntry, cppkafka::LogLevel::LogErr, error.get_error(), "Failed to commit offset.", nullptr); return ((error.get_error() != RD_KAFKA_RESP_ERR_OFFSET_OUT_OF_RANGE) && (error.get_error() != RD_KAFKA_RESP_ERR_OFFSET_METADATA_TOO_LARGE) && (error.get_error() != RD_KAFKA_RESP_ERR_INVALID_COMMIT_OFFSET_SIZE)); } bool ConsumerManagerImpl::preprocessorCallback( ConsumerTopicEntry& topicEntry, cppkafka::TopicPartition hint) { // Check if we have opaque data return cppkafka::CallbackInvoker<Callbacks::PreprocessorCallback> ("preprocessor", topicEntry._configuration.getPreprocessorCallback(), topicEntry._consumer.get()) (hint); } void ConsumerManagerImpl::assignmentCallback( ConsumerTopicEntry& topicEntry, cppkafka::TopicPartitionList& topicPartitions) { // Clear any throttling we may have topicEntry._isSubscribed = true; topicEntry._throttleControl.reset(); PartitionStrategy strategy = topicEntry._configuration.getPartitionStrategy(); if ((strategy == PartitionStrategy::Dynamic) && !topicEntry._configuration.getInitialPartitionAssignment().empty() && topicEntry._setOffsetsOnStart) { topicEntry._setOffsetsOnStart = false; //perform first offset assignment based on user config for (auto&& partition : topicPartitions) { for (const auto& assigned : topicEntry._configuration.getInitialPartitionAssignment()) { if (partition.get_partition() == assigned.get_partition()) { //we have a match partition.set_offset(assigned.get_offset()); break; } } } } cppkafka::CallbackInvoker<Callbacks::RebalanceCallback> ("assignment", topicEntry._configuration.getRebalanceCallback(), topicEntry._consumer.get()) (makeMetadata(topicEntry), cppkafka::Error(RD_KAFKA_RESP_ERR__ASSIGN_PARTITIONS), topicPartitions); } void ConsumerManagerImpl::revocationCallback( ConsumerTopicEntry& topicEntry, const cppkafka::TopicPartitionList& topicPartitions) { topicEntry._isSubscribed = false; cppkafka::CallbackInvoker<Callbacks::RebalanceCallback> ("revocation", topicEntry._configuration.getRebalanceCallback(), topicEntry._consumer.get()) (makeMetadata(topicEntry), cppkafka::Error(RD_KAFKA_RESP_ERR__REVOKE_PARTITIONS), const_cast<cppkafka::TopicPartitionList&>(topicPartitions)); } void ConsumerManagerImpl::rebalanceErrorCallback( ConsumerTopicEntry& topicEntry, cppkafka::Error error) { cppkafka::TopicPartitionList partitions; cppkafka::CallbackInvoker<Callbacks::RebalanceCallback> ("rebalance", topicEntry._configuration.getRebalanceCallback(), topicEntry._consumer.get()) (makeMetadata(topicEntry), error, partitions); } void ConsumerManagerImpl::adjustThrottling(ConsumerTopicEntry& topicEntry, const std::chrono::steady_clock::time_point& now) { if (!topicEntry._isPaused && topicEntry._throttleControl.reduceThrottling(now)) { // Resume only if this consumer is not paused explicitly by the user topicEntry._consumer->resume(); } } void ConsumerManagerImpl::report( ConsumerTopicEntry& topicEntry, cppkafka::LogLevel level, int error, const std::string& reason, const cppkafka::Message& message) { if (error) { errorCallback(topicEntry, *topicEntry._consumer, error, reason, &const_cast<cppkafka::Message&>(message)); } if (topicEntry._logLevel >= level) { logCallback(topicEntry, *topicEntry._consumer, (int)level, "corokafka", reason); } } void ConsumerManagerImpl::setConsumerBatchSize(size_t size) { _batchSize = size; } size_t ConsumerManagerImpl::getConsumerBatchSize() const { return _batchSize; } std::vector<cppkafka::Message> ConsumerManagerImpl::messageBatchReceiveTask(ConsumerTopicEntry& entry) { try { if (entry._pollTimeout.count() == -1) { return entry._consumer->poll_batch(entry._batchSize); } else { return entry._consumer->poll_batch(entry._batchSize, entry._pollTimeout); } } catch (const std::exception& ex) { exceptionHandler(ex, entry); throw ex; } } int ConsumerManagerImpl::messageRoundRobinReceiveTask(quantum::ThreadPromise<MessageContainer>::Ptr promise, ConsumerTopicEntry& entry) { try { int batchSize = entry._batchSize; std::chrono::milliseconds timeoutPerMessage(entry._pollTimeout.count()/entry._batchSize); while (batchSize--) { if (entry._pollTimeout.count() == -1) { cppkafka::Message message = entry._roundRobin->poll(); if (message) { promise->push(std::move(message)); } } else { cppkafka::Message message = entry._roundRobin->poll(timeoutPerMessage); if (message) { promise->push(std::move(message)); } } } } catch (const std::exception& ex) { exceptionHandler(ex, entry); } return promise->closeBuffer(); } ConsumerManagerImpl::DeserializedMessage ConsumerManagerImpl::deserializeMessage(ConsumerTopicEntry& entry, const cppkafka::Message& kafkaMessage) { DeserializerError de; if (kafkaMessage.get_error()) { de._error = kafkaMessage.get_error(); de._source |= (uint8_t)DeserializerError::Source::Kafka; return DeserializedMessage(boost::any(), boost::any(), HeaderPack{}, de); } const TypeErasedDeserializer& deserializer = entry._configuration.getTypeErasedDeserializer(); //Get the topic partition cppkafka::TopicPartition toppar(kafkaMessage.get_topic(), kafkaMessage.get_partition(), kafkaMessage.get_offset()); //Deserialize the key boost::any key = cppkafka::CallbackInvoker<Deserializer>("key_deserializer", *deserializer._keyDeserializer, entry._consumer.get()) (toppar, kafkaMessage.get_key()); if (key.empty()) { // Decoding failed de._error = RD_KAFKA_RESP_ERR__KEY_DESERIALIZATION; de._source |= (uint8_t)DeserializerError::Source::Key; report(entry, cppkafka::LogLevel::LogErr, RD_KAFKA_RESP_ERR__KEY_DESERIALIZATION, "Failed to deserialize key", kafkaMessage); } //Deserialize the headers if any HeaderPack headers(deserializer._headerEntries.size()); int num = 0; const cppkafka::HeaderList<cppkafka::Header<cppkafka::Buffer>>& kafkaHeaders = kafkaMessage.get_header_list(); for (auto it = kafkaHeaders.begin(); it != kafkaHeaders.end(); ++it) { try { const TypeErasedDeserializer::HeaderEntry& headerEntry = deserializer._headerDeserializers.at(it->get_name()); headers[headerEntry._pos].first = it->get_name(); headers[headerEntry._pos].second = cppkafka::CallbackInvoker<Deserializer>("header_deserializer", *headerEntry._deserializer, entry._consumer.get()) (toppar, it->get_value()); if (headers[headerEntry._pos].second.empty()) { // Decoding failed de._error = RD_KAFKA_RESP_ERR__VALUE_DESERIALIZATION; de._source |= (uint8_t)DeserializerError::Source::Header; de._headerNum = num; std::ostringstream oss; oss << "Failed to deserialize header: " << it->get_name(); report(entry, cppkafka::LogLevel::LogErr, RD_KAFKA_RESP_ERR__VALUE_DESERIALIZATION, oss.str(), kafkaMessage); break; } } catch (const std::exception& ex) { if (entry._skipUnknownHeaders) { report(entry, cppkafka::LogLevel::LogWarning, 0, ex.what(), kafkaMessage); continue; } de._error = RD_KAFKA_RESP_ERR__NOT_IMPLEMENTED; de._source |= (uint8_t)DeserializerError::Source::Header; de._headerNum = num; report(entry, cppkafka::LogLevel::LogErr, RD_KAFKA_RESP_ERR__NOT_IMPLEMENTED, ex.what(), kafkaMessage); break; } ++num; } //Deserialize the payload boost::any payload = cppkafka::CallbackInvoker<Deserializer>("payload_deserializer", *deserializer._payloadDeserializer, entry._consumer.get()) (toppar, kafkaMessage.get_payload()); if (payload.empty()) { // Decoding failed de._error = RD_KAFKA_RESP_ERR__VALUE_DESERIALIZATION; de._source |= (uint8_t)DeserializerError::Source::Payload; report(entry, cppkafka::LogLevel::LogErr, RD_KAFKA_RESP_ERR__VALUE_DESERIALIZATION, "Failed to deserialize payload", kafkaMessage); } return DeserializedMessage(std::move(key), std::move(payload), std::move(headers), de); } ConsumerManagerImpl::DeserializedMessage ConsumerManagerImpl::deserializeCoro(quantum::VoidContextPtr ctx, ConsumerTopicEntry& entry, const cppkafka::Message& kafkaMessage) { bool skip = false; if (entry._preprocessorCallback && entry._preprocess) { if (entry._preprocessOnIoThread) { // Call the preprocessor callback skip = ctx->template postAsyncIo(preprocessorTask, entry, kafkaMessage)->get(ctx); } else { //run in this coroutine skip = entry._preprocessorCallback(cppkafka::TopicPartition(kafkaMessage.get_topic(), kafkaMessage.get_partition(), kafkaMessage.get_offset())); } if (skip) { //return immediately and skip de-serializing DeserializedMessage dm; std::get<3>(dm)._error = RD_KAFKA_RESP_ERR__BAD_MSG; std::get<3>(dm)._source |= (uint8_t)DeserializerError::Source::Preprocessor; return dm; } } // Deserialize the message return deserializeMessage(entry, kafkaMessage); } std::vector<bool> ConsumerManagerImpl::executePreprocessorCallbacks( quantum::VoidContextPtr ctx, ConsumerTopicEntry& entry, const std::vector<cppkafka::Message>& messages) { // Preprocessor IO threads const size_t callbackThreadRangeSize = entry._receiveCallbackThreadRange.second - entry._receiveCallbackThreadRange.first + 1; int numPerBatch = messages.size()/callbackThreadRangeSize; int remainder = messages.size()%callbackThreadRangeSize; std::vector<bool> skipMessages(messages.size(), false); std::vector<quantum::CoroFuturePtr<int>> futures; futures.reserve(callbackThreadRangeSize); auto inputIt = messages.cbegin(); size_t batchIndex = 0; // Run the preprocessor callbacks in batches for (int i = 0; i < (int)callbackThreadRangeSize; ++i) { //get the begin and end iterators for each batch size_t batchSize = (i < remainder) ? numPerBatch + 1 : numPerBatch; if (batchSize == 0) { break; //nothing to do } int ioQueueId = i + entry._receiveCallbackThreadRange.first; futures.emplace_back(ctx->postAsyncIo(ioQueueId, false, [&entry, &skipMessages, batchIndex, batchSize, inputIt]() mutable ->int { for (size_t j = batchIndex; j < (batchIndex + batchSize) && entry._preprocess; ++j, ++inputIt) { skipMessages[j] = entry._preprocessorCallback(cppkafka::TopicPartition(inputIt->get_topic(), inputIt->get_partition(), inputIt->get_offset())); } return 0; })); // Advance index and iterator batchIndex += batchSize; std::advance(inputIt, batchSize); } //Wait on preprocessor stage to finish for (auto&& f : futures) { f->wait(ctx); } return skipMessages; } std::vector<ConsumerManagerImpl::DeserializedMessage> ConsumerManagerImpl::deserializeBatchCoro(quantum::VoidContextPtr ctx, ConsumerTopicEntry& entry, const std::vector<cppkafka::Message>& messages) { std::vector<bool> skipMessages; if (entry._configuration.getPreprocessorCallback() && entry._preprocess) { if (entry._preprocessOnIoThread) { skipMessages = executePreprocessorCallbacks(ctx, entry, messages); } else { skipMessages.resize(messages.size(), false); } } // Reset values size_t numCoros = entry._coroQueueIdRangeForAny.second - entry._coroQueueIdRangeForAny.first + 1; int numPerBatch = messages.size()/numCoros; int remainder = messages.size()%numCoros; std::vector<DeserializedMessage> deserializedMessages(messages.size()); //pre-allocate default constructed messages std::vector<quantum::CoroContextPtr<int>> futures; futures.reserve(numCoros); auto inputIt = messages.cbegin(); size_t batchIndex = 0; // Post unto all the coroutine threads. for (int i = entry._coroQueueIdRangeForAny.first; i <= entry._coroQueueIdRangeForAny.second; ++i) { //get the begin and end iterators for each batch size_t batchSize = (i < remainder) ? numPerBatch + 1 : numPerBatch; if (batchSize == 0) { break; //nothing to do } futures.emplace_back(ctx->post(i, false, [&entry, &deserializedMessages, &skipMessages, inputIt, batchIndex, batchSize] (quantum::CoroContextPtr<int>) mutable ->int { for (size_t j = batchIndex; j < (batchIndex + batchSize); ++j, ++inputIt) { if (entry._configuration.getPreprocessorCallback() && entry._preprocess && !entry._preprocessOnIoThread) { // Run the preprocessor on the coroutine thread skipMessages[j] = entry._preprocessorCallback(cppkafka::TopicPartition(inputIt->get_topic(), inputIt->get_partition(), inputIt->get_offset())); } if (!skipMessages.empty() && skipMessages[j]) { // Set error and mark source as preprocessor std::get<3>(deserializedMessages[j])._error = RD_KAFKA_RESP_ERR__BAD_MSG; std::get<3>(deserializedMessages[j])._source |= (uint8_t)DeserializerError::Source::Preprocessor; } else { // Deserialize message deserializedMessages[j] = deserializeMessage(entry, *inputIt); } } return 0; })); // Advance index and iterator batchIndex += batchSize; std::advance(inputIt, batchSize); } //Wait on deserialize stage to finish for (auto&& f : futures) { f->wait(ctx); } return deserializedMessages; } int ConsumerManagerImpl::invokeReceiver(ConsumerTopicEntry& entry, cppkafka::Message&& kafkaMessage, DeserializedMessage&& deserializedMessage) { cppkafka::CallbackInvoker<Receiver>("receiver", entry._configuration.getTypeErasedReceiver(), entry._consumer.get()) (*entry._committer, entry._offsets, std::move(kafkaMessage), //kafka raw message std::get<0>(std::move(deserializedMessage)), //key std::get<1>(std::move(deserializedMessage)), //payload std::get<2>(std::move(deserializedMessage)), //headers std::get<3>(std::move(deserializedMessage)), //error makeOffsetPersistSettings(entry)); return 0; } int ConsumerManagerImpl::receiverTask(ConsumerTopicEntry& entry, cppkafka::Message&& kafkaMessage, DeserializedMessage&& deserializedMessage) { return invokeReceiver(entry, std::move(kafkaMessage), std::move(deserializedMessage)); } std::deque<ConsumerManagerImpl::MessageTuple> ConsumerManagerImpl::pollCoro(quantum::VoidContextPtr ctx, ConsumerTopicEntry& entry) { try { using MessageTuple = std::tuple<cppkafka::Message, quantum::CoroContext<DeserializedMessage>::Ptr>; std::deque<MessageTuple> messageQueue; // Start the IO task to get messages in a round-robin way quantum::CoroFuture<MessageContainer>::Ptr future = ctx->postAsyncIo( (int)quantum::IQueue::QueueId::Any, true, messageRoundRobinReceiveTask, entry); // Receive all messages from kafka and deserialize in parallel bool isBufferClosed = false; while (!isBufferClosed) { cppkafka::Message message = future->pull(ctx, isBufferClosed); if (!isBufferClosed) { messageQueue.emplace_back(MessageTuple(std::move(message), nullptr)); MessageTuple& tuple = messageQueue.back(); if (!std::get<0>(tuple).get_error()) { // check if message has any errors std::get<1>(tuple) = ctx->post(deserializeCoro, entry, std::get<0>(tuple)); } } } // Pass the message queue to the processor coroutine return messageQueue; } catch (const std::exception& ex) { exceptionHandler(ex, entry); throw ex; } } void ConsumerManagerImpl::processMessageBatchOnIoThreads(quantum::VoidContextPtr ctx, ConsumerTopicEntry& entry, std::vector<cppkafka::Message>&& raw, std::vector<DeserializedMessage>&& deserializedMessages) { const std::pair<int,int>& threadRange = entry._receiveCallbackThreadRange; const int callbackThreadRangeSize = threadRange.second - threadRange.first + 1; if (callbackThreadRangeSize > 1) { // split the messages into io queues std::vector<ReceivedBatch> partitions(callbackThreadRangeSize); size_t rawIx = 0; for (auto&& deserializedMessage : deserializedMessages) { cppkafka::Message& rawMessage = raw[rawIx++]; if (rawIx > raw.size()) { throw std::out_of_range("Invalid message index"); } // Find out on which IO thread we should process this message const int ioQueue = mapPartitionToQueue(rawMessage.get_partition(), threadRange); partitions[ioQueue - threadRange.first] .emplace_back(std::make_tuple(std::move(rawMessage), std::move(deserializedMessage))); } if (rawIx != raw.size()) { throw std::runtime_error("Not all messages were processed"); } // invoke batch jobs for the partitioned messages std::vector<quantum::ICoroFuture<int>::Ptr> ioFutures; ioFutures.reserve(partitions.size()); for (size_t queueIx = 0; queueIx < partitions.size(); ++queueIx) { const int ioQueue = queueIx + threadRange.first; quantum::ICoroFuture<int>::Ptr future = ctx->postAsyncIo(ioQueue, false, receiverMultipleBatchesTask, entry, std::move(partitions[queueIx])); if (entry._receiveCallbackExec == ExecMode::Sync) { ioFutures.push_back(future); } } // wait until all the batches are processed for (auto c: ioFutures) { c->get(ctx); } } else { // optimization: no need to spend time on message distribution for a single io queue quantum::ICoroFuture<int>::Ptr future = ctx->postAsyncIo(threadRange.first, false, receiverSingleBatchTask, entry, std::move(raw), std::move(deserializedMessages)); if (entry._receiveCallbackExec == ExecMode::Sync) { future->get(ctx); } } } int ConsumerManagerImpl::pollBatchCoro(quantum::VoidContextPtr ctx, ConsumerTopicEntry& entry) { try{ // get the messages from the prefetched future, or std::vector<cppkafka::Message> raw; if (entry._batchPrefetch) { if (entry._messagePrefetchFuture) { //get the pre-fetched batch raw = entry._messagePrefetchFuture->get(ctx); } // start pre-fetching for the next batch entry._messagePrefetchFuture = ctx->postAsyncIo ((int)quantum::IQueue::QueueId::Any, true, messageBatchReceiveTask, entry); } else { raw = ctx->postAsyncIo((int)quantum::IQueue::QueueId::Any, true, messageBatchReceiveTask, entry)->get(ctx); } std::vector<DeserializedMessage> deserializedMessages = ctx->post(deserializeBatchCoro, entry, raw)->get(ctx); if (entry._receiveOnIoThread) { processMessageBatchOnIoThreads(ctx, entry, std::move(raw), std::move(deserializedMessages)); } else { invokeSingleBatchReceiver(entry, std::move(raw), std::move(deserializedMessages)); } return 0; } catch (const std::exception& ex) { exceptionHandler(ex, entry); return -1; } } int ConsumerManagerImpl::receiverMultipleBatchesTask(ConsumerTopicEntry& entry, ReceivedBatch&& messageBatch) { for (auto&& messageTuple : messageBatch) { cppkafka::CallbackInvoker<Receiver>("receiver", entry._configuration.getTypeErasedReceiver(), entry._consumer.get()) (*entry._committer, entry._offsets, std::get<0>(std::move(messageTuple)), //kafka raw message std::get<0>(std::get<1>(std::move(messageTuple))), //key std::get<1>(std::get<1>(std::move(messageTuple))), //payload std::get<2>(std::get<1>(std::move(messageTuple))), //headers std::get<3>(std::get<1>(std::move(messageTuple))), //error makeOffsetPersistSettings(entry)); } return 0; } int ConsumerManagerImpl::invokeSingleBatchReceiver(ConsumerTopicEntry& entry, std::vector<cppkafka::Message>&& rawMessages, std::vector<DeserializedMessage>&& deserializedMessages) { size_t rawIx = 0; for (auto&& deserializedMessage : deserializedMessages) { cppkafka::Message& rawMessage = rawMessages[rawIx++]; if (rawIx > rawMessages.size()) { throw std::out_of_range("Invalid message index"); } cppkafka::CallbackInvoker<Receiver>("receiver", entry._configuration.getTypeErasedReceiver(), entry._consumer.get()) (*entry._committer, entry._offsets, std::move(rawMessage), //kafka raw message std::get<0>(std::move(deserializedMessage)), //key std::get<1>(std::move(deserializedMessage)), //payload std::get<2>(std::move(deserializedMessage)), //headers std::get<3>(std::move(deserializedMessage)), //error makeOffsetPersistSettings(entry)); } if (rawIx != rawMessages.size()) { throw std::runtime_error("Not all messages were processed"); } return 0; } int ConsumerManagerImpl::receiverSingleBatchTask(ConsumerTopicEntry& entry, std::vector<cppkafka::Message>&& rawMessages, std::vector<DeserializedMessage>&& deserializedMessages) { return invokeSingleBatchReceiver(entry, std::move(rawMessages), std::move(deserializedMessages)); } bool ConsumerManagerImpl::preprocessorTask(ConsumerTopicEntry& entry, const cppkafka::Message& kafkaMessage) { return entry._preprocessorCallback(cppkafka::TopicPartition(kafkaMessage.get_topic(), kafkaMessage.get_partition(), kafkaMessage.get_offset())); } int ConsumerManagerImpl::processorCoro(quantum::VoidContextPtr ctx, ConsumerTopicEntry& entry) { //Get the polled messages from the previous stage (non-blocking) std::deque<MessageTuple> messageQueue = ctx->getPrev<std::deque<MessageTuple>>(); // Enqueue all messages and wait for completion for (auto& messageTuple : messageQueue) { try { auto &message = std::get<0>(messageTuple); auto deserializedFuture = std::get<1>(messageTuple); if (entry._receiveOnIoThread) { // Find out on which IO thread we should process this message int ioQueue = mapPartitionToQueue(message.get_partition(), entry._receiveCallbackThreadRange); // Post and wait until delivered quantum::ICoroFuture<int>::Ptr future = ctx->postAsyncIo(ioQueue, false, receiverTask, entry, std::move(message), deserializedFuture ? deserializedFuture->get(ctx) : DeserializedMessage()); if (entry._receiveCallbackExec == ExecMode::Sync) { future->get(ctx); } } else { //call serially on this coroutine invokeReceiver(entry, std::move(message), deserializedFuture ? deserializedFuture->get(ctx) : DeserializedMessage()); } } catch (const std::exception& ex) { exceptionHandler(ex, entry); } } return 0; } void ConsumerManagerImpl::exceptionHandler(const std::exception& ex, const ConsumerTopicEntry& topicEntry) { handleException(ex, makeMetadata(topicEntry), topicEntry._configuration, topicEntry._logLevel); } ConsumerMetadata ConsumerManagerImpl::makeMetadata(const ConsumerTopicEntry& topicEntry) { return ConsumerMetadata(topicEntry._configuration.getTopic(), topicEntry._consumer.get(), topicEntry._configuration.getPartitionStrategy()); } int ConsumerManagerImpl::mapPartitionToQueue(int partition, const std::pair<int,int>& range) { return (partition % (range.second - range.first + 1)) + range.first; } OffsetPersistSettings ConsumerManagerImpl::makeOffsetPersistSettings(const ConsumerTopicEntry& topicEntry) { return {topicEntry._autoOffsetPersist, topicEntry._autoOffsetPersistOnException, topicEntry._autoOffsetPersistStrategy, topicEntry._autoCommitExec}; } ConsumerManagerImpl::Consumers::iterator ConsumerManagerImpl::findConsumer(const std::string& topic) { auto it = _consumers.find(topic); if (it == _consumers.end()) { throw std::runtime_error("Invalid topic"); } return it; } ConsumerManagerImpl::Consumers::const_iterator ConsumerManagerImpl::findConsumer(const std::string& topic) const { auto it = _consumers.find(topic); if (it == _consumers.end()) { throw std::runtime_error("Invalid topic"); } return it; } } }
43.520115
154
0.611571
gridgentoo
85beaa553c98c788002eef0f4d070a28bd621981
5,831
cpp
C++
pimc/particleContainer/particleContainer.cpp
lucaparisi91/qmc4
f1ad1b105568500c9a8259e509dd3e01a933a050
[ "MIT" ]
null
null
null
pimc/particleContainer/particleContainer.cpp
lucaparisi91/qmc4
f1ad1b105568500c9a8259e509dd3e01a933a050
[ "MIT" ]
null
null
null
pimc/particleContainer/particleContainer.cpp
lucaparisi91/qmc4
f1ad1b105568500c9a8259e509dd3e01a933a050
[ "MIT" ]
null
null
null
#include "particleContainer.h" #include <array> #include <cmath> #include <cassert> #include <exception> #include <iostream> #include <sstream> #include <algorithm> #include <memory.h> #include "../pimcConfigurations.h" namespace pimc { template<int d> inline int indexFortranStorage(const int* im, const int* sizes) { return sizes[0]*( sizes[1]*im[2] + im[1] ) + im[0] ; } template<int d> void indicesFromIndexFortranStorage(int* im, int cellIndex,const int* sizes) { im[0]=cellIndex%sizes[0]; cellIndex-=im[0]; cellIndex/=sizes[0]; im[1]=cellIndex%sizes[1]; cellIndex-=im[1]; cellIndex/=sizes[1]; im[2]=cellIndex; } auto wrap( int index, int N) { if (index < 0) {return index + N;}; if (index >= N) {return index - N ;} return index; }; auto nDisplacement( int index , int N ) { if (index<0) return +1; if (index>=N) return - 1; return 0; } simpleCellNeighbourList::simpleCellNeighbourList(std::array<size_t,getDimensions()> nCells, std::array<Real,getDimensions()> lBox ) : _nCells(nCells), _lBox(lBox), nParticles(0) { int nCellsTotal=1; for(int d=0;d<getDimensions();d++) { nCellsTotal*=nCells[d]; _left[d]=-lBox[d]/2; _right[d]=lBox[d]/2; _delta[d]=_lBox[d]/_nCells[d]; _lBoxInverse[d]=1/_lBox[d]; } cells.resize(nCellsTotal); for ( size_t i=0;i<nCellsTotal;i++) { cells[i]=(new cell{}); } for (int i=0;i<_nCells[0];i++) for (int j=0;j<_nCells[1];j++) for (int k=0;k<_nCells[2];k++) { auto & neighbours = getCell(i,j,k).neighbours(); auto & displacements = getCell(i,j,k).displacements(); getCell(i,j,k).setCellIndex({i,j,k}); int iNeigh=0; for (int ii=i-1;ii<=i+1;ii++) for (int jj=j-1;jj<=j+1;jj++) for (int kk=k-1;kk<=k+1;kk++) { if ( (ii==i) and (jj==j) and (kk==k) ) { continue; } int iii=wrap(ii,_nCells[0]); int jjj=wrap(jj,_nCells[1]); int kkk=wrap(kk,_nCells[2]); neighbours[iNeigh]= & (getCell(iii,jjj,kkk) ); displacements(iNeigh,0)=nDisplacement(ii,_nCells[0])*_lBox[0]; displacements(iNeigh,1)=nDisplacement(jj,_nCells[1])*_lBox[1]; displacements(iNeigh,2)=nDisplacement(kk,_nCells[2])*_lBox[2]; iNeigh++; } } } simpleCellNeighbourList::~simpleCellNeighbourList() { for ( int i=0;i<cells.size();i++) { delete cells[i]; } } void simpleCellNeighbourList::setCapacity(size_t N) { cellIndexPerParticle.resize( N ); subIndexPerParticle.resize( N); isParticleRemoved.resize(N,true); for ( auto cell : cells) { //cell->setCapacity(N); } } cell::cell( size_t nMaxParticles) : _nMaxParticles(nMaxParticles), _displacements( std::pow(3,getDimensions() ) - 1 ,getDimensions() ), _nParticles(0), nBuffer(10), _index{0,0,0} { int nNeighbours=std::pow(3,getDimensions()) -1; _displacements.setConstant(0); _neighbours.resize( nNeighbours,nullptr); }; void cell::setCapacity(size_t N) { _particleIndex.resize(N); _nMaxParticles=N; } linkedCellParticles::linkedCellParticles( std::array<size_t,getDimensions()> nCells, std::array<Real,getDimensions() > lBox ) : _nCells(nCells), _lBox(lBox) {} void linkedCellParticles::setCapacity(size_t N,size_t M) { auto oldSize=particles.size(); particles.resize( M + 1); for(int i=oldSize;i<M + 1;i++) { particles[i]=std::make_shared<linkedCell_t>(_nCells,_lBox); }; for(int i=0;i<M + 1;i++) { particles[i]->setCapacity(N); } } void linkedCellParticles::add( const Eigen::Tensor<Real,3> & data, const range_t & timeRange,const range_t & particleRange) { for (int t=timeRange[0]; t<=timeRange[1]+1;t++) { for(int i=particleRange[0];i<=particleRange[1];i++) { particles[t]->add(i, data(i,0,t),data(i,1,t),data(i,2,t)); } } } void linkedCellParticles::add( const Eigen::Tensor<Real,3> & data, const mask_t & mask, const range_t & timeRange,const range_t & particleRange) { for (int t=timeRange[0]; t<=timeRange[1]+1;t++) { for(int i=particleRange[0];i<=particleRange[1];i++) { if ( mask(i,t) == 1 ) { particles[t]->add(i, data(i,0,t),data(i,1,t),data(i,2,t)); } } } } void linkedCellParticles::update( const Eigen::Tensor<Real,3> & data, const range_t & timeRange,const range_t & particleRange) { remove(timeRange,particleRange); add(data,timeRange,particleRange); } void linkedCellParticles::update( const Eigen::Tensor<Real,3> & data, const mask_t & mask, const range_t & timeRange,const range_t & particleRange) { remove(timeRange,particleRange); add(data,mask,timeRange,particleRange); } void linkedCellParticles::remove( const range_t & timeRange,const range_t & particleRange) { for (int t=timeRange[0]; t<=timeRange[1]+1;t++) { for(int i=particleRange[0];i<=particleRange[1];i++) { particles[t]->remove(i); } } } }
24.295833
149
0.537644
lucaparisi91
85c14746d830a377c8fc64b56d5af9c8ae2a6ffa
7,462
cxx
C++
Modules/Radiometry/Simulation/test/otbImageSimulationMethodKMeansClassif.cxx
qingswu/otb
ed903b6a5e51a27a3d04786e4ad1637cf6b2772e
[ "Apache-2.0" ]
null
null
null
Modules/Radiometry/Simulation/test/otbImageSimulationMethodKMeansClassif.cxx
qingswu/otb
ed903b6a5e51a27a3d04786e4ad1637cf6b2772e
[ "Apache-2.0" ]
null
null
null
Modules/Radiometry/Simulation/test/otbImageSimulationMethodKMeansClassif.cxx
qingswu/otb
ed903b6a5e51a27a3d04786e4ad1637cf6b2772e
[ "Apache-2.0" ]
null
null
null
/* * Copyright (C) 2005-2019 Centre National d'Etudes Spatiales (CNES) * * This file is part of Orfeo Toolbox * * https://www.orfeo-toolbox.org/ * * 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 "otbVectorImage.h" #include "otbImageFileWriter.h" #include "otbVectorDataFileReader.h" #include "otbVectorDataToLabelMapWithAttributesFilter.h" #include "otbSpatialisationFilter.h" #include "otbImageSimulationMethod.h" #include "otbAttributesMapLabelObject.h" #include "otbImageFileReader.h" #include "itkWeightedCentroidKdTreeGenerator.h" #include "itkKdTreeBasedKmeansEstimator.h" #include "otbKMeansImageClassificationFilter.h" int otbImageSimulationMethodKMeansClassif(int itkNotUsed(argc), char* argv[]) { const char* satRSRFilename = argv[1]; unsigned int nbBands = static_cast<unsigned int>(atoi(argv[2])); const char* rootPath = argv[3]; unsigned int radius = atoi(argv[4]); const char* outfilename = argv[5]; const char* outLabelfilename = argv[6]; const unsigned int nbClasses = 4; double ConvergenceThreshold = 0.0001; unsigned int NumberOfIterations = 1000; typedef unsigned short LabelType; const unsigned int Dimension = 2; typedef otb::Image<LabelType, Dimension> LabelImageType; typedef otb::VectorImage<double, Dimension> OutputImageType; typedef otb::ImageFileWriter<OutputImageType> ImageWriterType; typedef otb::ImageFileWriter<LabelImageType> LabelImageWriterType; typedef otb::VectorData<double, Dimension> VectorDataType; typedef otb::AttributesMapLabelObject<LabelType, Dimension, std::string> LabelObjectType; typedef itk::LabelMap<LabelObjectType> LabelMapType; typedef otb::SpatialisationFilter<LabelMapType> SpatialisationFilterType; typedef otb::ProspectModel SimulationStep1Type; typedef otb::SailModel SimulationStep2Type; typedef otb::ProlateInterpolateImageFunction<LabelImageType> FTMType; typedef otb::ImageSimulationMethod<VectorDataType, SpatialisationFilterType, SimulationStep1Type, SimulationStep2Type, FTMType, OutputImageType> ImageSimulationMethodType; typedef OutputImageType::PixelType SampleType; typedef itk::Statistics::ListSample<SampleType> ListSampleType; typedef itk::Statistics::WeightedCentroidKdTreeGenerator<ListSampleType> TreeGeneratorType; typedef TreeGeneratorType::KdTreeType TreeType; typedef itk::Statistics::KdTreeBasedKmeansEstimator<TreeType> EstimatorType; typedef otb::KMeansImageClassificationFilter<OutputImageType, LabelImageType, nbClasses> ClassificationFilterType; typedef itk::ImageRegionIterator<OutputImageType> ImageRegionIteratorType; /** Instantiation of pointer objects*/ ImageWriterType::Pointer writer = ImageWriterType::New(); LabelImageWriterType::Pointer labelWriter = LabelImageWriterType::New(); ImageSimulationMethodType::Pointer imageSimulation = ImageSimulationMethodType::New(); SpatialisationFilterType::Pointer spatialisationFilter = SpatialisationFilterType::New(); ClassificationFilterType::Pointer classifier = ClassificationFilterType::New(); SpatialisationFilterType::SizeType objectSize; objectSize[0] = 300; objectSize[1] = 300; SpatialisationFilterType::SizeType nbOjects; nbOjects[0] = 2; nbOjects[1] = 2; std::vector<std::string> pathVector(nbClasses); pathVector[0] = "JHU/becknic/rocks/sedimentary/powder/0_75/txt/greywa1f.txt"; pathVector[1] = ""; pathVector[2] = "JHU/becknic/water/txt/coarse.txt"; pathVector[3] = "JHU/becknic/soils/txt/0015c.txt"; std::vector<std::string> areaVector(nbClasses); areaVector[0] = "sedimentaryRock"; areaVector[1] = "prosail"; areaVector[2] = "water"; areaVector[3] = "soils"; std::vector<LabelType> labels(nbClasses); labels[0] = 1; labels[1] = 2; labels[2] = 3; labels[3] = 4; spatialisationFilter->SetObjectSize(objectSize); spatialisationFilter->SetNumberOfObjects(nbOjects); spatialisationFilter->SetPathVector(pathVector); spatialisationFilter->SetAreaVector(areaVector); spatialisationFilter->SetLabels(labels); imageSimulation->SetSpatialisation(spatialisationFilter); imageSimulation->SetNumberOfComponentsPerPixel(nbBands); imageSimulation->SetSatRSRFilename(satRSRFilename); imageSimulation->SetPathRoot(rootPath); imageSimulation->SetRadius(radius); // imageSimulation->SetMean(); // imageSimulation->SetVariance(); imageSimulation->UpdateData(); imageSimulation->GetOutputReflectanceImage()->Update(); // get all the pixel of the image for KMeans centroid estimation OutputImageType::IndexType centroidIndex; centroidIndex[0] = objectSize[0] / 2; centroidIndex[1] = objectSize[1] / 2; EstimatorType::ParametersType initialCentroids(nbBands * nbClasses); ImageRegionIteratorType it(imageSimulation->GetOutputReflectanceImage(), imageSimulation->GetOutputReflectanceImage()->GetLargestPossibleRegion()); it.GoToBegin(); ListSampleType::Pointer listSample = ListSampleType::New(); listSample->SetMeasurementVectorSize(nbBands); unsigned int x = 0; unsigned int classIndex = 0; while (!it.IsAtEnd()) { if (it.GetIndex() == centroidIndex) { for (unsigned int j = 0; j < nbBands; ++j) { initialCentroids[j + classIndex * nbBands] = it.Get()[j]; } classIndex++; if (x < (nbOjects[0] - 1)) { centroidIndex[0] += objectSize[0]; x++; } else { x = 0; centroidIndex[0] = objectSize[0] / 2; centroidIndex[1] += objectSize[1]; } } listSample->PushBack(it.Get()); ++it; } TreeGeneratorType::Pointer treeGenerator = TreeGeneratorType::New(); treeGenerator->SetSample(listSample); treeGenerator->SetBucketSize(100 / (10 * nbClasses)); treeGenerator->Update(); EstimatorType::Pointer estimator = EstimatorType::New(); estimator->SetKdTree(treeGenerator->GetOutput()); estimator->SetParameters(initialCentroids); estimator->SetMaximumIteration(NumberOfIterations); estimator->SetCentroidPositionChangesThreshold(ConvergenceThreshold); estimator->StartOptimization(); classifier->SetCentroids(estimator->GetParameters()); classifier->SetInput(imageSimulation->GetOutputReflectanceImage()); // Write the result to an image file writer->SetFileName(outfilename); writer->SetInput(imageSimulation->GetOutputReflectanceImage()); writer->Update(); labelWriter->SetFileName(outLabelfilename); // labelWriter->SetInput(imageSimulation->GetOutputLabelImage()); labelWriter->SetInput(classifier->GetOutput()); labelWriter->Update(); return EXIT_SUCCESS; }
38.266667
155
0.719244
qingswu
85c2389dec561ca7a80bd6c08f9934a6746ac57a
7,736
cpp
C++
appsrc/DistributedConfigGenerator.cpp
slashdotted/PomaPure
c469efba9813b4b897129cff9699983c3f90b24b
[ "BSD-3-Clause" ]
2
2017-12-11T01:07:45.000Z
2021-08-21T20:57:04.000Z
appsrc/DistributedConfigGenerator.cpp
slashdotted/PomaPure
c469efba9813b4b897129cff9699983c3f90b24b
[ "BSD-3-Clause" ]
null
null
null
appsrc/DistributedConfigGenerator.cpp
slashdotted/PomaPure
c469efba9813b4b897129cff9699983c3f90b24b
[ "BSD-3-Clause" ]
1
2017-08-29T17:53:20.000Z
2017-08-29T17:53:20.000Z
/* * Copyright (C)2015,2016,2017 Amos Brocco (amos.brocco@supsi.ch) * Scuola Universitaria Professionale della * Svizzera Italiana (SUPSI) * 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 Scuola Universitaria Professionale della Svizzera * Italiana (SUPSI) 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 <COPYRIGHT HOLDER> 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 <boost/property_tree/json_parser.hpp> #include <boost/lexical_cast.hpp> #include <cstdlib> #include "DistributedConfigGenerator.h" #include <iostream> namespace poma { DistributedConfigGenerator::DistributedConfigGenerator(const std::string &p_source_mid, const std::map<std::string, Module> &p_modules, const std::vector<Link> &p_links, unsigned int base_port) : m_source_mid{p_source_mid}, m_modules{p_modules}, m_links{p_links}, m_base_port{base_port} { } void DistributedConfigGenerator::process() { for (auto &it : m_modules) { auto v{m_modules.find(it.first)}; const Module &mod{v->second}; m_host_modules_map.insert(std::make_pair(mod.mhost, mod)); m_module_host_map.insert(std::make_pair(mod.mid, mod.mhost)); } std::string source_host{m_module_host_map.find(m_source_mid)->second}; Link lnkprocessor; lnkprocessor.fid = Module::source(source_host); lnkprocessor.tid = m_source_mid; m_host_link_map.insert(std::make_pair(source_host, lnkprocessor)); for (auto &lnk : m_links) { if (lnk.fid == "" || m_module_host_map.count(lnk.fid) == 0) { die("invalid link definition: invalid or no source specified: " + lnk.fid + ", to " + lnk.tid + ", channel " + lnk.channel); } if (lnk.tid == "" || m_module_host_map.count(lnk.tid) == 0) { die("invalid link definition: invalid or no destination specified: " + lnk.tid + ", from " + lnk.fid + ", channel " + lnk.channel); } if (lnk.channel == "") { die("invalid link definition: channel cannot be empty"); } std::string fhost{m_module_host_map[lnk.fid]}; std::string thost{m_module_host_map[lnk.tid]}; if (fhost == thost) { std::cout << fhost << "<->" << thost << std::endl; m_host_link_map.insert(std::make_pair(fhost, lnk)); } else { // Insert ZeroMQ bridge Module sink; sink.mid = Module::unique("__net_sink_"); sink.mtype = "ZeroMQSink"; sink.mhost = fhost; sink.mparams["sinkaddress"] = Module::address(thost, m_base_port); sink.mparams["#bandwidth"] = lnk.bandwidth; Module source; source.mid = Module::unique("__net_source"); source.mtype = "ZeroMQSource"; source.mhost = thost; source.mparams["sourceaddress"] = Module::address("*", m_base_port); source.mparams["#bandwidth"] = lnk.bandwidth; ++m_base_port; m_host_modules_map.insert(std::make_pair(sink.mhost, sink)); m_host_modules_map.insert(std::make_pair(source.mhost, source)); m_module_host_map[sink.mid] = sink.mhost; m_module_host_map[source.mid] = source.mhost; Link lnksink; lnksink.fid = lnk.fid; lnksink.tid = sink.mid; lnksink.channel = lnk.channel; lnksink.debug = lnk.debug; lnksink.bandwidth = lnk.bandwidth; m_host_link_map.insert(std::make_pair(fhost, lnksink)); Link lnksource; lnksource.fid = source.mid; lnksource.tid = lnk.tid; lnksource.channel = lnk.channel; lnksource.debug = lnk.debug; lnksource.bandwidth = lnk.bandwidth; m_host_link_map.insert(std::make_pair(thost, lnksource)); Link lnkprocessor; lnkprocessor.fid = Module::source(thost); lnkprocessor.tid = source.mid; m_host_link_map.insert(std::make_pair(thost, lnkprocessor)); } } // Each host must have a ParProcessor module as source for (auto const &h: hosts()) { Module source_pp; source_pp.mid = Module::source(h); source_pp.mhost = h; source_pp.mtype = "ParProcessor"; m_host_modules_map.insert(std::make_pair(source_pp.mhost, source_pp)); m_module_host_map.insert(std::make_pair(source_pp.mid, source_pp.mhost)); } } void DistributedConfigGenerator::get_config(const std::string &host, std::string &p_source_mid, std::map<std::string, Module> &p_modules, std::vector<Link> &p_links) { p_source_mid = Module::source(host); auto iter = m_host_modules_map.equal_range(host); for (auto it = iter.first; it != iter.second; ++it) { const Module& module{it->second}; p_modules[module.mid] = module; } auto iter2 = m_host_link_map.equal_range(host); for (auto it = iter2.first; it != iter2.second; ++it) { p_links.push_back(it->second); } } std::set<std::string> DistributedConfigGenerator::hosts() const { std::set<std::string> hosts; for(auto const& h: m_host_modules_map) { hosts.insert(h.first); } return hosts; } std::set<std::string> DistributedConfigGenerator::modules(const std::string &host) const { std::set<std::string> modules; auto iter = m_host_modules_map.equal_range(host); for (auto it = iter.first; it != iter.second; ++it) { const Module& module{it->second}; modules.insert(module.mtype); } return modules; } }
47.460123
118
0.586608
slashdotted
85c3a32ec8a115fac835f0e829db3cbda2aa6e23
35,918
cpp
C++
csl/cslbase/arith07.cpp
arthurcnorman/general
5e8fef0cc7999fa8ab75d8fdf79ad5488047282b
[ "BSD-2-Clause" ]
null
null
null
csl/cslbase/arith07.cpp
arthurcnorman/general
5e8fef0cc7999fa8ab75d8fdf79ad5488047282b
[ "BSD-2-Clause" ]
null
null
null
csl/cslbase/arith07.cpp
arthurcnorman/general
5e8fef0cc7999fa8ab75d8fdf79ad5488047282b
[ "BSD-2-Clause" ]
null
null
null
// arith07.cpp Copyright (C) 1990-2020 Codemist // // Arithmetic functions. negation plus a load of Common Lisp things // for support of complex numbers. // // /************************************************************************** * Copyright (C) 2020, Codemist. A C Norman * * * * 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 relevant * * 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. * * * * 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 OWNERS 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. * *************************************************************************/ // $Id: arith07.cpp 5387 2020-08-20 19:40:24Z arthurcnorman $ #include "headers.h" LispObject copyb(LispObject a) // // copy a bignum. // { LispObject b; size_t len = bignum_length(a), i; push(a); b = get_basic_vector(TAG_NUMBERS, TYPE_BIGNUM, len); pop(a); len = (len-CELL)/4; for (i=0; i<len; i++) bignum_digits(b)[i] = vbignum_digits(a)[i]; return b; } LispObject negateb(LispObject a) // // Negate a bignum. Note that negating the 1-word bignum // value of 0x08000000 will produce a fixnum as a result (for 32 bits), // which might confuse the caller... in a similar way negating // the value -0x40000000 will need to promote from a one-word // bignum to a 2-word bignum. How messy just for negation! // And on 64 bit systems the same effect applies but with larger values! // In an analogous manner negating the positive number of the style // 0x40000000 can lead to a negative result that uses one less digit. // Well on a 64-bit machine it is a 2-word bignum that can end up // negated to get a fixnum result. // { LispObject b; size_t len = bignum_length(a), i; int32_t carry; // There are two messy special cases here. The first is that there is a // positive value (2^27 or 2^59) which has to be represented as a bignum, // but when you negate it you get a fixnum. // Then there will be negative values (the smallest being -2^31 or -2^62) // that fit in a certain number of words of bignum, but their absolute // value needs one more word... // Note that on a 64-bit machine there ought never to be any one-word // bignums because all the values representable with just one 31-bit digit // can be handled as fixnums instead. if (SIXTY_FOUR_BIT && len == CELL+8) // two-word bignum - do specially { if (bignum_digits(a)[0] == 0 && bignum_digits(a)[1] == (int32_t)0x10000000) return MOST_NEGATIVE_FIXNUM; else if (bignum_digits(a)[0] == 0 && (int32_t)bignum_digits(a)[1] == -(int32_t)(1<<30)) return make_three_word_bignum(0, 1<<30, 0); uint32_t d0 = bignum_digits(a)[0]; int32_t d1 = (int32_t)~bignum_digits(a)[1]; if (d0 == 0) d1++; else return make_two_word_bignum(d1, (-d0) & 0x7fffffff); } if (!SIXTY_FOUR_BIT && len == CELL+4) // one-word bignum - do specially { int32_t d0 = -(int32_t)bignum_digits(a)[0]; if (d0 == MOST_NEGATIVE_FIXVAL) return MOST_NEGATIVE_FIXNUM; else if (d0 == 0x40000000) return make_two_word_bignum(0, d0); else return make_one_word_bignum(d0); } push(a); b = get_basic_vector(TAG_NUMBERS, TYPE_BIGNUM, len); pop(a); len = (len-CELL-4)/4; carry = -1; for (i=0; i<len; i++) { // The next couple of lines really caught me out wrt compiler optimisation // before I put in all the casts. I used to have what was in effect // carry = (signed_x ^ 0x7fffffff) + (int32_t)((uint32_t)carry>>31); // ... ((uint32_t)carry >> 31); // and a compiler seems to have observed that the masking leaves the left // operand of the addition positive, and that the unsigned shift right // leaves the right operand positive too. So based on an assumption that // signed integer overflow will not happen it deduces that the sum will also // be positive, and hence that on the next line (carry>>31) will be zero. // For the assumption to fail there will have had to be integer overflow, and // the C/C++ standards say that the consequence of that are undefined - a term // that can include behaviour as per the optimised code here. // // To avoid that I am working on the basis that casts between int32_t and // uint32_t will leave bit representations unchanged and that arithmetic uses // twos complement for signed values. Then by casting to unsigned at times // I can allow a carry to propagate into the top bit of a word without that // counting as an overflow, and that should force the compiler to do the // arithmetic in full. // // Having spotted this particular case I now worry about how many related // ones there may be hiding in the code! // carry = ADD32(clear_top_bit(~bignum_digits(a)[i]), top_bit(carry)); bignum_digits(b)[i] = clear_top_bit(carry); } // Handle the top digit separately since it is signed. carry = ADD32(~bignum_digits(a)[i], top_bit(carry)); if (!signed_overflow(carry)) { // If the most significant word ends up as -1 then I just might // have 0x40000000 in the next word down and so I may need to shrink // the number. Since I handled 1-word bignums specially I have at // least two words to deal with here. if (carry == -1 && (bignum_digits(b)[i-1] & 0x40000000) != 0) { bignum_digits(b)[i-1] |= ~0x7fffffff; setnumhdr(b, numhdr(b) - pack_hdrlength(1)); if (SIXTY_FOUR_BIT) { if ((i & 1) != 0) bignum_digits(b)[i] = 0; else *reinterpret_cast<Header *>(&bignum_digits(b)[i]) = make_bighdr( 2); } else { if ((i & 1) == 0) bignum_digits(b)[i] = 0; else *reinterpret_cast<Header *>(&bignum_digits(b)[i]) = make_bighdr( 2); } } else bignum_digits(b)[i] = carry; // no shrinking needed return b; } // Here I have overflow: this can only happen when I negate a number // that started off with 0xc0000000 in the most significant digit, // and I have to pad a zero word onto the front. bignum_digits(b)[i] = clear_top_bit(carry); return lengthen_by_one_bit(b, carry); } // // generic negation // LispObject negate(LispObject a) { switch (static_cast<int>(a) & TAG_BITS) { case TAG_FIXNUM: if (!SIXTY_FOUR_BIT && is_sfloat(a)) return a ^ 0x80000000U; if (SIXTY_FOUR_BIT && is_sfloat(a)) return a ^ UINT64_C(0x8000000000000000); else return make_lisp_integer64(-int_of_fixnum(a)); case TAG_NUMBERS: { int32_t ha = type_of_header(numhdr(a)); switch (ha) { case TYPE_BIGNUM: return negateb(a); case TYPE_RATNUM: { LispObject n = numerator(a), d = denominator(a); push(d); n = negate(n); pop(d); return make_ratio(n, d); } case TYPE_COMPLEX_NUM: { LispObject r = real_part(a), i = imag_part(a); push(i); r = negate(r); pop(i); push(r); i = negate(i); pop(r); return make_complex(r, i); } default: return aerror1("bad arg for minus", a); } } case TAG_BOXFLOAT: switch (type_of_header(flthdr(a))) { case TYPE_SINGLE_FLOAT: return make_boxfloat(-single_float_val(a), TYPE_SINGLE_FLOAT); case TYPE_DOUBLE_FLOAT: return make_boxfloat(-double_float_val(a), TYPE_DOUBLE_FLOAT); #ifdef HAVE_SOFTFLOAT case TYPE_LONG_FLOAT: { float128_t aa = long_float_val(a); f128M_negate(&aa); return make_boxfloat128(aa); } #endif // HAVE_SOFTFLOAT } default: return aerror1("bad arg for minus", a); } } /*****************************************************************************/ //** Transcendental functions etcetera. ** /*****************************************************************************/ // // Much of the code here is extracted from the portable Fortran library // used by Codemist with its Fortran compiler. // // // The object of the following macro is to adjust the floating point // variables concerned so that the more significant one can be squared // with NO LOSS OF PRECISION. It is only used when there is no danger // of over- or under-flow. // // This code is NOT PORTABLE but can be modified for use elsewhere // It should, however, serve for IEEE and IBM FP formats. // typedef union _char_double { double d; char c[8]; } char_double_union; #ifdef LITTLEENDIAN #define LOW_BITS_OFFSET 0 #else #define LOW_BITS_OFFSET 4 #endif // The code here explictly puns between a double and a row of char values // so that it can force the bottom 32-bits of the represenattion of the // double to be zero. The use of the char type here and then memset to clear // it is intended to keep me safe from strict-aliasing concerns, and modern // C compilers are liable to map the use of memset onto a simple store // instruction. #define _fp_normalize(high, low) \ { char_double_union temp; /* access to representation */ \ temp.d = high; /* take original number */ \ std::memset(&temp.c[LOW_BITS_OFFSET], 0, 4); \ /* make low part of mantissa 0 */ \ low += (high - temp.d); /* add into low-order result */ \ high = temp.d; \ } // // A modern C system will provide a datatype "complex double" which // will (I hope) provide direct implementations of some things I need // here. However in the end I may prefer not to use it because for // real floating point I am using crlibm that implements correctly // rounded and hence consistent across all platforms values. If I use // that as a basis for my complex code I will at least get bit-for-bit // identical results everywhere even if I do not manage to achieve // correctly rounded last-bit performance in all cases. // log, sqrt and all the inverse trig functions here need careful review // as to their treatment of -0.0 on branch-cuts! // double Cabs(Complex z) { // // Obtain the absolute value of a complex number - note that the main // agony here is in ensuring that neither overflow nor underflow can // wreck the calculation. Given ideal arithmetic the sum could be carried // through as just sqrt(x^2 + y^2). // double x = z.real, y = z.imag; double scale; int n1, n2; if (x==0.0) return std::fabs(y); else if (y==0.0) return std::fabs(x); static_cast<void>(std::frexp(x, &n1)); static_cast<void>(std::frexp(y, &n2)); // The exact range of values returned by frexp does not matter here if (n2>n1) n1 = n2; // n1 is now the exponent of the larger (in absolute value) of x, y scale = std::ldexp(1.0, n1); // can not be 0.0 x /= scale; y /= scale; // The above scaling operation introduces no rounding error (since the // scale factor is exactly a power of 2). It reduces the larger of x, y // to be somewhere near 1.0 so overflow in x*x+y*y is impossible. It is // still possible that one of x*x and y*y will underflow (but not both) // but this is harmless. return scale * std::sqrt(x*x + y*y); } Complex Ccos(Complex z) { double x = z.real, y = z.imag; // // cos(x + iy) = cos(x)*cosh(y) - i sin(x)*sinh(y) // For smallish y this can be used directly. For |y| > 50 I will // compute sinh and cosh as just +/- exp(|y|)/2 // double s = std::sin(x), c = std::cos(x); double absy = std::fabs(y); if (absy <= 50.0) { double sh = std::sinh(y), ch = std::cosh(y); z.real = c*ch; z.imag = - s*sh; return z; } else { double w; int n = _reduced_exp(absy, &w) - 1; z.real = std::ldexp(c*w, n); if (y < 0.0) z.imag = std::ldexp(s*w, n); else z.imag = std::ldexp(-s*w, n); return z; } } static double reduced_power(double a, int n) { // // Compute (1 + a)^n - 1 avoiding undue roundoff error. // Assumes n >= 1 on entry and that a is small. // if (n == 1) return a; { double d = reduced_power(a, n/2); d = (2.0 + d)*d; if (n & 1) d += (1.0 + d)*a; return d; } } // // The following value is included for documentation purposes - it // give the largest args that can be given to exp() without leading to // overflow on IEEE-arithmetic machines. // #define _exp_arg_limit 709.78271289338397 // Note that in any case exp(50.0) will not overflow (it is only 5.2e21), // so it can be evaluated the simple direct way. // int _reduced_exp(double x, double *r) { // // (*r) = exp(x)/2^n; return n; // where n will be selected so that *r gets set to a fairly small value // (precise range of r unimportant provided it will be WELL away from // chances of overflow, even when exp(x) would actually overflow). This // function may only be called with argument x that is positive and // large enough that n will end up satisfying n>=1. The coding here // will ensure that if x>4.0, and in general the use of this function // will only be for x > 50. // For IBM hardware it would be good to be able to control the value // of n mod 4, maybe, to help counter wobbling precision. This is not // done here. // int n; double f; n = static_cast<int>(x / 7.625 + 0.5); // // 7.625 = 61/8 and is expected to have an exact floating point // representation here, so f is computed without any rounding error. // (do I need something like the (x - 0.5) - 0.5 trick here?) // f = std::exp(x - 7.625*static_cast<double>(n)); // // the magic constant is ((exp(61/8) / 2048) - 1) and it arises because // 61/88 is a decent rational approximation to log(2), hence exp(61/8) // is almost 2^11. Thus I compute exp(x) as // 2^(11*n) * (exp(61/8)/2^11)^n * exp(f) // The first factor is exact, the second is (1+e)^n where e is small and // n is an integer, so can be computer accurately, and the residue f at the // end is small enough not to give over-bad trouble. // The numeric constant given here was calculated with the REDUCE 3.3 // bigfloat package. // #define _e61q8 3.81086435594567676751e-4 *r = reduced_power(_e61q8, n)*f + f; #undef _e61q8 return 11*n; } Complex Cexp(Complex z) { double x = z.real, y = z.imag; // // value is exp(x)*(cos(y) + i sin(y)) but have care with overflow // Here (and throughout the complex library) there is an opportunity // to save time by computing sin(y) and cos(y) together. Since this // code is (to begin with) to sit on top of an arbitrary C library, // perhaps with hardware support for the calculation of real-valued // trig functions I am not going to try to realise this saving. // double s = std::sin(y), c = std::cos(y); // // if x > 50 I will use a cautious sceme which computes exp(x) with // its (binary) exponent separated. Note that 50.0 is chosen as a // number noticably smaller than _exp_arg_limit (exp(50) = 5.18e21), // but is not a critical very special number. // if (x <= 50.0) // includes x < 0.0, of course { double w = std::exp(x); z.real = w*c; z.imag = w*s; return z; } else { double w; int n = _reduced_exp(x, &w); z.real = std::ldexp(w*c, n); z.imag = std::ldexp(w*s, n); return z; } } Complex Cln(Complex z) { double x = z.real, y = z.imag; // // if x and y are both very large then cabs(z) may be out of range // even though log or if is OK. Thus it is necessary to perform an // elaborate scaled calculation here, and not just // z.real = log(cabs(z)); // double scale, r; int n1, n2; if (x==0.0) r = std::log(std::fabs(y)); else if (y==0.0) r = std::log(std::fabs(x)); else { static_cast<void>(std::frexp(x, &n1)); static_cast<void>(std::frexp(y, &n2)); // The exact range of values returned by frexp does not matter here if (n2>n1) n1 = n2; scale = std::ldexp(1.0, n1); x /= scale; y /= scale; r = std::log(scale) + 0.5*std::log(x*x + y*y); } z.real = r; // // The C standard is not very explicit about the behaviour of atan2(0.0, -n) // while for Fortran it is necessary that this returns +pi not -pi. Hence // with extreme caution I put a special test here. // if (y == 0.0) if (x < 0.0) z.imag = _pi; else z.imag = 0.0; else z.imag = std::atan2(y, x); return z; } // // Complex raising to a power. This seems to be pretty nasty // to get right, and the code includes extra high precision variants // on atan() and log(). Further refinements wrt efficiency may be // possible later on. // This code has been partially tested, and seems to be uniformly // better than using just a**b = exp(b*log(a)), but much more careful // study is needed before it can possibly be claimed that it is // right in the sense of not throwing away accuracy when it does not // have to. I also need to make careful checks to verify that the // correct (principal) value is computed. // // // The next function is used after arithmetic has been done on extra- // precision numbers so that the relationship between high and low parts // is no longer known. Re-instate it. // #define _two_minus_25 2.98023223876953125e-8 // 2^(-25) static double fp_add(double a, double b, double *lowres) { // Result is the high part of a+b, with the low part assigned to *lowres double absa, absb; if (a >= 0.0) absa = a; else absa = -a; if (b >= 0.0) absb = b; else absb = -b; if (absa < absb) { double t = a; a = b; b = t; } // Now a is the larger (in absolute value) of the two numbers if (absb > absa * _two_minus_25) { double al = 0.0, bl = 0.0; // // If the exponent difference beweeen a and b is no more than 25 then // I can add the top part (20 or 24 bits) of a to the top part of b // without going beyond the 52 or 56 bits that a full mantissa can hold. // _fp_normalize(a, al); _fp_normalize(b, bl); a = a + b; // No rounding needed here b = al + bl; if (a == 0.0) { a = b; b = 0.0; } } // // The above step leaves b small wrt the value in a (unless a+b led // to substantial cancellation of leading digits), but leaves the high // part a with bits everywhere. Force low part of a to zero. // { double al = 0.0; _fp_normalize(a, al); b = b + al; } if (a >= 0.0) absa = a; else absa = -a; if (b >= 0.0) absb = b; else absb = -b; if (absb > absa * _two_minus_25) // // If on input a is close to -b, then a+b is close to zero. In this // case the exponents of a abd b matched, and so earlier calculations // have all been done exactly. Go around again to split residue into // high and low parts. // { double al = 0.0, bl = 0.0; _fp_normalize(b, bl); a = a + b; _fp_normalize(a, al); b = bl + al; } *lowres = b; return a; } #undef _two_minus_25 static void extended_atan2(double b, double a, double *thetah, double *thetal) { int octant; double rh, rl, thh, thl; // // First reduce the argument to the first octant (i.e. a, b both +ve, // and b <= a). // if (b < 0.0) { octant = 4; a = -a; b = -b; } else octant = 0; if (a < 0.0) { double t = a; octant += 2; a = b; b = -t; } if (b > a) { double t = a; octant += 1; a = b; b = t; } { static struct { double h; double l; } _atan[] = { // // The table here gives atan(n/16) in 1.5-precision for n=0..16 // Note that all the magic numbers used in this file were calculated // using the REDUCE bigfloat package, and all the 'exact' parts have // a denominator of at worst 2^26 and so are expected to have lots // of trailing zero bits in their floating point representation. // { 0.0, 0.0 }, { 0.06241881847381591796875, -0.84778585694947708870e-8 }, { 0.124355018138885498046875, -2.35921240630155201508e-8 }, { 0.185347974300384521484375, -2.43046897565983490387e-8 }, { 0.2449786663055419921875, -0.31786778380154175187e-8 }, { 0.302884876728057861328125, -0.83530864557675689054e-8 }, { 0.358770668506622314453125, 0.17639499059427950639e-8 }, { 0.412410438060760498046875, 0.35366268088529162896e-8 }, { 0.4636476039886474609375, 0.50121586552767562314e-8 }, { 0.512389481067657470703125, -2.07569197640365239794e-8 }, { 0.558599293231964111328125, 2.21115983246433832164e-8 }, { 0.602287352085113525390625, -0.59501493437085023057e-8 }, { 0.643501102924346923828125, 0.58689374629746842287e-8 }, { 0.6823165416717529296875, 1.32029951485689299817e-8 }, { 0.71882998943328857421875, 1.01883359311982641515e-8 }, { 0.75315129756927490234375, -1.66070805128190106297e-8 }, { 0.785398185253143310546875, -2.18556950009312141541e-8 } }; int k = static_cast<int>(16.0*(b/a + 0.03125)); // 0 to 16 double kd = static_cast<double>(k)/16.0; double ah = a, al = 0.0, bh = b, bl = 0.0, ch, cl, q, q2; _fp_normalize(ah, al); _fp_normalize(bh, bl); ch = bh - ah*kd; cl = bl - al*kd; ah = ah + bh*kd; al = al + bl*kd; bh = ch; bl = cl; // Now |(a/b)| <= 1/32 ah = fp_add(ah, al, &al); // Re-normalise bh = fp_add(bh, bl, &bl); // Compute approximation to b/a rh = (bh + bl)/(ah + al); rl = 0.0; _fp_normalize(rh, rl); bh -= ah*rh; bl -= al*rh; rl = (bh + bl)/(ah + al); // Quotient now formed // // Now it is necessary to compute atan(q) to one-and-a-half precision. // Since |q| < 1/32 I will leave just q as the high order word of // the result and compute atan(q)-q as a single precision value. This // gives about 16 bits accuracy beyond regular single precision work. // q = rh + rl; q2 = q*q; // The expansion the follows could be done better using a minimax poly rl -= q*q2*(0.33333333333333333333 - q2*(0.20000000000000000000 - q2*(0.14285714285714285714 - q2*(0.11111111111111111111 - q2* 0.09090909090909090909)))); // OK - now (rh, rl) is atan(reduced b/a). Need to add on atan(kd) rh += _atan[k].h; rl += _atan[k].l; } // // The following constants give high precision versions of pi and pi/2, // and the high partwords (p2h and pih) have lots of low order zero bits // in their binary representation. Expect (=require) that the arithmetic // that computes thh is done without introduced rounding error. // #define _p2h 1.57079632580280303955078125 #define _p2l 9.92093579680540441639751e-10 #define _pih 3.14159265160560607910156250 #define _pil 1.984187159361080883279502e-9 switch (octant) { default: case 0: thh = rh; thl = rl; break; case 1: thh = _p2h - rh; thl = _p2l - rl; break; case 2: thh = _p2h + rh; thl = _p2l + rl; break; case 3: thh = _pih - rh; thl = _pil - rl; break; case 4: thh = -_pih + rh; thl = -_pil + rl; break; case 5: thh = -_p2h - rh; thl = -_p2l - rl; break; case 6: thh = -_p2h + rh; thl = -_p2l + rl; break; case 7: thh = -rh; thl = -rl; break; } #undef _p2h #undef _p2l #undef _pih #undef _pil *thetah = fp_add(thh, thl, thetal); } static void extended_log(int k, double a, double b, double *logrh, double *logrl) { // // If we had exact arithmetic this procedure could be: // k*log(2) + 0.5*log(a^2 + b^2) // double al = 0.0, bl = 0.0, all = 0.0, bll = 0.0, c, ch, cl, cll; double w, q, qh, ql, rh, rl; int n; // // First (a^2 + b^2) is calculated, using extra precision. // Because any rounding at this stage can lead to bad errors in // the power that I eventually want to compute, I use 3-word // arithmetic here, and with the version of _fp_normalize given // above and IEEE or IBM370 arithmetic this part of the // computation is exact. // _fp_normalize(a, al); _fp_normalize(al, all); _fp_normalize(b, bl); _fp_normalize(bl, bll); ch = a*a + b*b; cl = 2.0*(a*al + b*bl); cll = (al*al + bl*bl) + all*(2.0*(a + al) + all) + bll*(2.0*(b + bl) + bll); _fp_normalize(ch, cl); _fp_normalize(cl, cll); c = ch + (cl + cll); // single precision approximation // // At this stage the scaling of the input value will mean that we // have 0.25 <= c <= 2.0 // // Now rewrite things as // (2*k + n)*log(s) + 0.5*log((a^2 + b^2)/2^n)) // where s = sqrt(2) // and where the arg to the log is in sqrt(0.5), sqrt(2) // #define _sqrt_half 0.70710678118654752440 #define _sqrt_two 1.41421356237309504880 k = 2*k; while (c < _sqrt_half) { k -= 1; ch *= 2.0; cl *= 2.0; cll *= 2.0; c *= 2.0; } while (c > _sqrt_two) { k += 1; ch *= 0.5; cl *= 0.5; cll *= 0.5; c *= 0.5; } #undef _sqrt_half #undef _sqrt_two n = static_cast<int>(16.0/c + 0.5); w = static_cast<double>(n) / 16.0; ch *= w; cl *= w; cll *= w; // Now |c-1| < 0.04317 ch = (ch - 0.5) - 0.5; ch = fp_add(ch, cl, &cl); cl = cl + cll; // // (ch, cl) is now the reduced argument ready for calculating log(1+c), // and now that the reduction is over I can drop back to the use of just // two doubleprecision values to represent c. // c = ch + cl; qh = c / (2.0 + c); ql = 0.0; _fp_normalize(qh, ql); ql = ((ch - qh*(2.0 + ch)) + cl - qh*cl) / (2.0 + c); // (qh, ql) is now c/(2.0 + c) rh = qh; // 18 bits bigger than low part will end up q = qh + ql; w = q*q; rl = ql + q*w*(0.33333333333333333333 + w*(0.20000000000000000000 + w*(0.14285714285714285714 + w*(0.11111111111111111111 + w*(0.09090909090909090909))))); // // (rh, rl) is now atan(c) correct to double precision plus about 18 bits. // { double temp; static struct { double h; double l; } _log_table[] = { // // The following values are (in extra precision) -log(n/16)/2 for n // in the range 11 to 23 (i.e. roughly over sqrt(2)/2 to sqrt(2)) // { 0.1873466968536376953125, 2.786706765149099245e-8 }, { 0.1438410282135009765625, 0.801238948715710950e-8 }, { 0.103819668292999267578125, 1.409612298322959552e-8 }, { 0.066765725612640380859375, -2.930037906928620319e-8 }, { 0.0322692394256591796875, 2.114312640614896196e-8 }, { 0.0, 0.0 }, { -0.0303122997283935546875, -1.117982386660280307e-8 }, { -0.0588915348052978515625, 1.697710612429310295e-8 }, { -0.08592510223388671875, -2.622944289242004947e-8 }, { -0.111571788787841796875, 1.313073691899185245e-8 }, { -0.135966837406158447265625, -2.033566243215020975e-8 }, { -0.159226894378662109375, 2.881939480146987639e-8 }, { -0.18145275115966796875, 0.431498374218108783e-8 } }; rh = fp_add(rh, _log_table[n-11].h, &temp); rl = temp + _log_table[n-11].l + rl; } #define _exact_part_logroot2 0.3465735912322998046875 #define _approx_part_logroot2 (-9.5232714997888393927e-10) // Multiply this by k and add it in { double temp, kd = static_cast<double>(k); rh = fp_add(rh, kd*_exact_part_logroot2, &temp); rl = rl + temp + kd*_approx_part_logroot2; } #undef _exact_part_logroot2 #undef _approx_part_logroot2 *logrh = rh; *logrl = rl; return; } Complex Cpow(Complex z1, Complex z2) { double a = z1.real, b = z1.imag, c = z2.real, d = z2.imag; int k, m, n; double scale; double logrh, logrl, thetah, thetal; double r, i, rh, rl, ih, il, clow, dlow, q; double cw, sw, cost, sint; if (b == 0.0 && d == 0.0 && a >= 0.0)// Simple case if both args are real { z1.real = std::pow(a, c); z1.imag = 0.0; return z1; } // // Start by scaling z1 by dividing out a power of 2 so that |z1| is // fairly close to 1 // if (a == 0.0) { if (b == 0.0) return z1; // 0.0**anything is really an error // The exact values returned by frexp do not matter here static_cast<void>(std::frexp(b, &k)); } else { static_cast<void>(std::frexp(a, &k)); if (b != 0.0) { int n; static_cast<void>(std::frexp(b, &n)); if (n > k) k = n; } } scale = std::ldexp(1.0, k); a /= scale; b /= scale; // // The idea next is to express z1 as r*exp(i theta), then z1**z2 // is exp(z2*log(z1)) and the exponent simplifies to // (c*log r - d*theta) + i(c theta + d log r). // Note r = scale*sqrt(a*a + b*b) now. // The argument for exp() must be computed to noticably more than // regular precision, since otherwise exp() greatly magnifies the // error in the real part (if it is large and positive) and range // reduction in the imaginary part can equally lead to accuracy // problems. Neither c nor d can usefully be anywhere near the // extreme range of floating point values, so I will not even try // to scale them, thus I will end up happy(ish) if I can compute // atan2(b, a) and log(|z1|) in one-and-a-half precision form. // It would be best to compute theta in units of pi/4 rather than in // raidians, since then the case of z^n (integer n) with arg(z) an // exact multiple of pi/4 would work out better. However at present I // just hope that the 1.5-precision working is good enough. // extended_atan2(b, a, &thetah, &thetal); extended_log(k, a, b, &logrh, &logrl); // Normalise all numbers clow = 0.0; dlow = 0.0; _fp_normalize(c, clow); _fp_normalize(d, dlow); // (rh, rl) = c*logr - d*theta; rh = c*logrh - d*thetah; // No rounding in this computation rl = c*logrl + clow*(logrh + logrl) - d*thetal - dlow* (thetah + thetal); // (ih, il) = c*theta + d*logr; ih = c*thetah + d*logrh; // No rounding in this computation il = c*thetal + clow*(thetah + thetal) + d*logrl + dlow* (logrh + logrl); // // Now it remains to take the exponential of the extended precision // value in ((rh, rl), (ih, il)). // Range reduce the real part by multiples of log(2), and the imaginary // part by multiples of pi/2. // rh = fp_add(rh, rl, &rl); // renormalise r = rh + rl; // Approximate value #define _recip_log_2 1.4426950408889634074 q = r * _recip_log_2; m = (q < 0.0) ? static_cast<int>(q - 0.5) : static_cast<int>(q + 0.5); q = static_cast<double>(m); #undef _recip_log_2 // // log 2 = 11629080/2^24 - 0.000 00000 19046 54299 95776 78785 // to reasonable accuracy. It is vital that the exact part be // read in as a number with lots of low zero bits, so when it gets // multiplied by the integer q there is NO rounding needed. // #define _exact_part_log2 0.693147182464599609375 #define _approx_part_log2 (-1.9046542999577678785418e-9) rh = rh - q*_exact_part_log2; rl = rl - q*_approx_part_log2; #undef _exact_part_log2 #undef _approx_part_log2 r = std::exp(rh + rl); // This should now be accurate enough ih = fp_add(ih, il, &il); i = ih + il; // Approximate value #define _recip_pi_by_2 0.6366197723675813431 q = i * _recip_pi_by_2; n = (q < 0.0) ? static_cast<int>(q - 0.5) : static_cast<int>(q + 0.5); q = static_cast<double>(n); // // pi/2 = 105414357/2^26 + 0.000 00000 09920 93579 68054 04416 39751 // to reasonable accuracy. It is vital that the exact part be // read in as a number with lots of low zero bits, so when it gets // multiplied by the integer q there is NO rounding needed. // #define _exact_part_pi2 1.57079632580280303955078125 #define _approx_part_pi2 9.92093579680540441639751e-10 ih = ih - q*_exact_part_pi2; il = il - q*_approx_part_pi2; #undef _recip_pi_by_2 #undef _exact_part_pi2 #undef _approx_part_pi2 i = ih + il; // Now accurate enough // // Having done super-careful range reduction I can call the regular // sin/cos routines here. If sin/cos could both be computed together // that could speed things up a little bit, but by this stage they have // not much in common. // cw = std::cos(i); sw = std::sin(i); switch (n & 3) // quadrant control { default: case 0: cost = cw; sint = sw; break; case 1: cost = -sw; sint = cw; break; case 2: cost = -cw; sint = -sw; break; case 3: cost = sw; sint = -cw; break; } // // Now, at long last, I can assemble the results and return. // z1.real = std::ldexp(r*cost, m); z1.imag = std::ldexp(r*sint, m); return z1; } // // End of complex-to-complex-power code. // // end of arith07.cpp
36.914697
85
0.587143
arthurcnorman
85c99d2b6b4215afc6f0ae82c6234c5939f9b5cc
7,056
cpp
C++
src/testcase/backtrace.cpp
jjg1914/testcase
1edca3295ea65d654f0b363bd0bde8c0f0b653f3
[ "MIT" ]
null
null
null
src/testcase/backtrace.cpp
jjg1914/testcase
1edca3295ea65d654f0b363bd0bde8c0f0b653f3
[ "MIT" ]
null
null
null
src/testcase/backtrace.cpp
jjg1914/testcase
1edca3295ea65d654f0b363bd0bde8c0f0b653f3
[ "MIT" ]
null
null
null
#include <bfd.h> #include <execinfo.h> #include <cxxabi.h> #include <csignal> #include <cmath> #include <map> #include <string> #include <sstream> #include <iostream> #include <iomanip> #include <memory> #include "testcase/backtrace.h" using namespace std; using namespace testcase; #define BACKTRACE_BUF_SIZE \ (sizeof(backtrace_buf)/sizeof(backtrace_buf[0])) namespace { backtrace_exception_f exception_handler; void* backtrace_buf[1024]; struct BFD_info { bool found; string filename; string functionname; unsigned int line; }; struct BFD { static void init(); BFD(const string &fname); ~BFD(); BFD_info addr_info(const string &addr); bfd_vma addr_vma(const string &addr); private: static void find_addr(bfd* p, asection *section, void *data); bfd* ptr_bfd; map<string,bfd_vma> map_syms; static bfd_vma pc; static asymbol **info_symtab; static bfd_boolean info_found; static const char* info_filename; static const char* info_functionname; static unsigned int info_line; }; std::string sym2fname(const char *sym); std::string sym2addr(const char *sym); void handle_terminate(); void handle_sigsegv(int); void handle_sigfpe(int); void handle_sigill(int); void handle_sigbus(int); } bfd_vma BFD::pc; asymbol **BFD::info_symtab = NULL; bfd_boolean BFD::info_found = 0; const char* BFD::info_filename; const char* BFD::info_functionname; unsigned int BFD::info_line; void BFD::init() { bfd_init(); } BFD::BFD(const string &fname) : ptr_bfd(bfd_openr(fname.c_str(),NULL)) { char **matching; if (ptr_bfd && !bfd_check_format(ptr_bfd, bfd_archive) && bfd_check_format_matches(ptr_bfd, bfd_object, &matching) && bfd_get_file_flags(ptr_bfd) & HAS_SYMS) { unsigned int size; asymbol **symtab; long symc = bfd_read_minisymbols(ptr_bfd, 0, (void**) &symtab, &size); if (symc == 0) { symc = bfd_read_minisymbols(ptr_bfd, 1, (void**) &symtab, &size); } for (int i = 0; i < symc; ++i) { symbol_info info; bfd_symbol_info(symtab[i], &info); map_syms.emplace(symtab[i]->name, info.value); } } } BFD::~BFD() { if (ptr_bfd) { bfd_close(ptr_bfd); } } BFD_info BFD::addr_info(const string &addr) { BFD_info rval; pc = addr_vma(addr); rval.found = (info_found = 0); bfd_map_over_sections(ptr_bfd,BFD::find_addr, NULL); if (info_found) { rval.found = true; rval.filename = (info_filename ? info_filename : ""); rval.functionname = (info_functionname ? info_functionname : "Anonymous Function"); rval.line = info_line; } return rval; } bfd_vma BFD::addr_vma(const string &addr) { int i = addr.find_last_of('+'); bfd_vma base = 0; if (i > 0) { string sym = addr.substr(0,i); auto it = map_syms.find(sym); if (it != map_syms.end()) { base = it->second; } } bfd_vma offset = bfd_scan_vma(addr.substr(i + 1).c_str(), NULL, 16); return base + offset; } void BFD::find_addr(bfd* p, asection *section, void *) { bfd_vma vma; bfd_size_type size; if (info_found) return; if ((bfd_get_section_flags(p, section) & SEC_ALLOC) == 0) return; vma = bfd_get_section_vma(p, section); if (pc < vma) return; size = bfd_get_section_size(section); if (pc >= vma + size) return; info_found = bfd_find_nearest_line(p, section, info_symtab, pc - vma, &info_filename, &info_functionname, &info_line); } namespace { std::string sym2fname(const char *sym) { string base(sym); int i = base.size() - 1; while (base[i] != '(') { --i; } return base.substr(0,i); } std::string sym2addr(const char *sym) { string base(sym); int e = base.size() - 1, s; while (base[e] != ')') { --e; } s = e; while (base[s] != '(') { --s; } if (e - s == 1) { e = base.size() - 1; while (base[e] != ']') { --e; } s = e; while (base[s] != '[') { --s; } } return base.substr(s + 1,e - s - 1); } void handle_terminate() { static bool recursive_guard = 0; static int init_depth = 0; ErrorInfo info(ErrorInfo::ETERM, backtrace_depth()); try { if (recursive_guard) { exception e; info.depth = init_depth; exception_handler(info, e); } else { recursive_guard = true; init_depth = info.depth;; throw; } } catch (exception &e) { info.eno = ErrorInfo::EEXP; exception_handler(info, e); } catch (...) { exception e; info.eno = ErrorInfo::EUNKNOWN; exception_handler(info, e); } } void handle_sigsegv(int) { ErrorInfo info(ErrorInfo::ESEGV, backtrace_depth()); exception e; exception_handler(info, e); } void handle_sigfpe(int) { ErrorInfo info(ErrorInfo::EFPE, backtrace_depth()); exception e; exception_handler(info, e); } void handle_sigill(int) { ErrorInfo info(ErrorInfo::EILL, backtrace_depth()); exception e; exception_handler(info, e); } void handle_sigbus(int) { ErrorInfo info(ErrorInfo::EBUS, backtrace_depth()); exception e; exception_handler(info, e); } } testcase::ErrorInfo::ErrorInfo(Errno eno, int depth) : eno(eno), depth(depth) {} std::string testcase::sbacktrace(int bottom, int top) { stringstream ss; int size = backtrace((void**)&backtrace_buf,BACKTRACE_BUF_SIZE); char **sym = backtrace_symbols(backtrace_buf, size); BFD::init(); map<string,BFD> str2bfd; int s = size - bottom + 1; int width = log10(size - top - 1 - s) + 1; for (int i = s; i < size - top - 1; ++i) { string fname(sym2fname(sym[i])); BFD& rbfd = str2bfd.emplace(fname, fname).first->second; BFD_info info = rbfd.addr_info(sym2addr(sym[i])); if (info.found) { ss << setw(width) << (i - s); ss << ": " << backtrace_demangle(info.functionname) << endl; ss << string(width + 2,' '); ss << "[" << info.filename << ":" << info.line << "]" << endl; ss << string(width + 2,' '); ss << fname << "(+0x" << hex << rbfd.addr_vma(sym2addr(sym[i])) << ")"; ss << dec << endl; } else { ss << setw(width) << (i - s) << ": " << sym[i] << endl; } } free(sym); return ss.str(); } void testcase::backtrace_exception(const std::function<void(const ErrorInfo&, const std::exception &e)> &f) { exception_handler = f; set_terminate(handle_terminate); signal(SIGSEGV,handle_sigsegv); signal(SIGFPE,handle_sigfpe); signal(SIGILL,handle_sigill); signal(SIGBUS,handle_sigbus); } std::string testcase::backtrace_demangle(const std::string &sym) { int status; unique_ptr<char> realname(abi::__cxa_demangle(sym.c_str(), 0, 0, &status)); if (status) { return sym; } else { return realname.get(); } } int testcase::backtrace_depth() { return backtrace((void**)&backtrace_buf,BACKTRACE_BUF_SIZE) - 1; } void testcase::backtrace_trap() { raise(SIGTRAP); }
21.512195
77
0.618906
jjg1914
85cb6cbecfb350484fccd1aee3264ef374dbd7b6
4,152
cpp
C++
src/guacamole/guac_clipboard.cpp
unk0rrupt/collab-vm-server
30a18cc91b757216a08e900826b589ce29bc3bf0
[ "Apache-2.0" ]
74
2020-12-20T19:29:21.000Z
2021-12-04T14:59:29.000Z
src/guacamole/guac_clipboard.cpp
unk0rrupt/collab-vm-server
30a18cc91b757216a08e900826b589ce29bc3bf0
[ "Apache-2.0" ]
2
2020-12-27T12:10:50.000Z
2021-01-24T12:38:24.000Z
src/guacamole/guac_clipboard.cpp
unk0rrupt/collab-vm-server
30a18cc91b757216a08e900826b589ce29bc3bf0
[ "Apache-2.0" ]
4
2020-12-20T14:28:11.000Z
2021-08-20T17:01:11.000Z
/* * Copyright (C) 2014 Glyptodon LLC * * 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. */ #define _CRT_SECURE_NO_WARNINGS #include "config.h" #include "guac_clipboard.h" #include "guacamole/protocol.h" #include "guacamole/stream.h" #include "GuacClient.h" #include "GuacUser.h" #include <string.h> #include <stdlib.h> guac_common_clipboard* guac_common_clipboard_alloc(int size) { guac_common_clipboard* clipboard = (guac_common_clipboard*)malloc(sizeof(guac_common_clipboard)); /* Init clipboard */ clipboard->mimetype[0] = '\0'; clipboard->buffer = (char*)malloc(size); clipboard->length = 0; clipboard->available = size; return clipboard; } void guac_common_clipboard_free(guac_common_clipboard* clipboard) { free(clipboard->buffer); free(clipboard); } /** * Callback for guac_client_foreach_user() which sends clipboard data to each * connected client. */ static void __send_user_clipboard(GuacUser* user, void* data) { guac_common_clipboard* clipboard = (guac_common_clipboard*) data; char* current = clipboard->buffer; int remaining = clipboard->length; /* Begin stream */ guac_stream* stream = user->AllocStream(); guac_protocol_send_clipboard(user->socket_, stream, clipboard->mimetype); user->Log(GUAC_LOG_DEBUG, "Created stream %i for %s clipboard data.", stream->index, clipboard->mimetype); /* Split clipboard into chunks */ while (remaining > 0) { /* Calculate size of next block */ int block_size = GUAC_COMMON_CLIPBOARD_BLOCK_SIZE; if (remaining < block_size) block_size = remaining; /* Send block */ guac_protocol_send_blob(user->socket_, stream, current, block_size); user->Log(GUAC_LOG_DEBUG, "Sent %i bytes of clipboard data on stream %i.", block_size, stream->index); /* Next block */ remaining -= block_size; current += block_size; } user->Log(GUAC_LOG_DEBUG, "Clipboard stream %i complete.", stream->index); /* End stream */ guac_protocol_send_end(user->socket_, stream); user->FreeStream(stream); } void guac_common_clipboard_send(guac_common_clipboard* clipboard, GuacClient* client) { //guac_client_log(client, GUAC_LOG_DEBUG, "Broadcasting clipboard to all connected users."); //guac_client_foreach_user(client, __send_user_clipboard, clipboard); //guac_client_log(client, GUAC_LOG_DEBUG, "Broadcast of clipboard complete."); } void guac_common_clipboard_reset(guac_common_clipboard* clipboard, const char* mimetype) { clipboard->length = 0; strncpy(clipboard->mimetype, mimetype, sizeof(clipboard->mimetype)-1); } void guac_common_clipboard_append(guac_common_clipboard* clipboard, const char* data, int length) { /* Truncate data to available length */ int remaining = clipboard->available - clipboard->length; if (remaining < length) length = remaining; /* Append to buffer */ memcpy(clipboard->buffer + clipboard->length, data, length); /* Update length */ clipboard->length += length; }
32.692913
99
0.71315
unk0rrupt
85cc1d3b70ab1457358c4c505c56772a8f8ae098
2,749
cpp
C++
src/MeshDataBuffer.cpp
jaredmulconry/GLProj
722fc9804cf6bd2ee0098e6eed9261198f55d0b9
[ "MIT" ]
1
2016-11-28T07:14:41.000Z
2016-11-28T07:14:41.000Z
src/MeshDataBuffer.cpp
jaredmulconry/GLProj
722fc9804cf6bd2ee0098e6eed9261198f55d0b9
[ "MIT" ]
null
null
null
src/MeshDataBuffer.cpp
jaredmulconry/GLProj
722fc9804cf6bd2ee0098e6eed9261198f55d0b9
[ "MIT" ]
null
null
null
#include "MeshDataBuffer.hpp" #include "GLFW/glfw3.h" namespace GlProj { namespace Graphics { MeshDataBuffer::MeshDataBuffer(BufferType bufferType, GLsizeiptr dataSize, const GLvoid* data, GLenum dataType, GLint elemsPerVert, BufferUsage usage) : bufferType(GLenum(bufferType)) , dataType(dataType) , elementsPerVertex(elemsPerVert) { glGenBuffers(1, &meshDataHandle); glBindBuffer(this->bufferType, meshDataHandle); glBufferData(this->bufferType, dataSize, data, GLenum(usage)); } MeshDataBuffer::MeshDataBuffer(MeshDataBuffer&& x) noexcept : meshDataHandle(x.meshDataHandle) , bufferType(x.bufferType) , dataType(x.dataType) , elementsPerVertex(x.elementsPerVertex) { x.meshDataHandle = invalidHandle; } MeshDataBuffer& MeshDataBuffer::operator=(MeshDataBuffer&& x) noexcept { if (this != &x) { if (meshDataHandle != invalidHandle) { glDeleteBuffers(1, &meshDataHandle); } meshDataHandle = x.meshDataHandle; bufferType = x.bufferType; dataType = x.dataType; elementsPerVertex = x.elementsPerVertex; x.meshDataHandle = invalidHandle; } return *this; } MeshDataBuffer::~MeshDataBuffer() { if (meshDataHandle != invalidHandle) { glDeleteBuffers(1, &meshDataHandle); } } GLuint MeshDataBuffer::GetHandle() const noexcept { return meshDataHandle; } BufferType MeshDataBuffer::GetBufferType() const noexcept { return BufferType(bufferType); } GLenum MeshDataBuffer::GetDataType() const noexcept { return dataType; } GLint MeshDataBuffer::GetElementsPerVertex() const noexcept { return elementsPerVertex; } void MeshDataBuffer::UpdateData(GLintptr offset, GLsizeiptr dataSize, const GLvoid * data) const noexcept { glBufferSubData(bufferType, offset, dataSize, data); } void* MeshDataBuffer::MapBuffer(GLintptr offset, GLsizeiptr dataSize, GLbitfield access) const noexcept { return glMapBufferRange(bufferType, offset, dataSize, access); } void MeshDataBuffer::UnmapBuffer() const noexcept { glUnmapBuffer(bufferType); } void MeshDataBuffer::Bind() const noexcept { glBindBuffer(bufferType, GetHandle()); } void MeshDataBuffer::BindBase(GLuint index) const noexcept { glBindBufferBase(bufferType, index, GetHandle()); } void MeshDataBuffer::BindRange(GLuint index, GLintptr offset, GLsizeiptr size) const noexcept { glBindBufferRange(bufferType, index, GetHandle(), offset, size); } bool operator==(const MeshDataBuffer& x, const MeshDataBuffer& y) noexcept { return x.meshDataHandle == y.meshDataHandle; } bool operator!=(const MeshDataBuffer& x, const MeshDataBuffer& y) noexcept { return !(x == y); } } }
26.95098
107
0.719534
jaredmulconry
85cd11adad48cfa373d705f644b8c537794fde31
7,135
cc
C++
test/web/test_parser.cc
protocolocon/nanoWeb
a89b3f9d9c9b7421a5005971565795519728f31b
[ "BSD-2-Clause" ]
null
null
null
test/web/test_parser.cc
protocolocon/nanoWeb
a89b3f9d9c9b7421a5005971565795519728f31b
[ "BSD-2-Clause" ]
null
null
null
test/web/test_parser.cc
protocolocon/nanoWeb
a89b3f9d9c9b7421a5005971565795519728f31b
[ "BSD-2-Clause" ]
null
null
null
/* -*- mode: c++; coding: utf-8; c-file-style: "stroustrup"; -*- Contributors: Asier Aguirre All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE.txt file. */ #include "catch.hpp" #include "ml_parser.h" #define _ "\n" #define DUMP(x, ...) x, ##__VA_ARGS__ using namespace std; using namespace webui; namespace { bool stringCompare(const char* str, const char* pos, int size) { return int(strlen(str)) == size && !strncmp(str, pos, size); } } TEST_CASE("parser: id", "[parser]") { MLParser ml; const char* str("s0mething"); REQUIRE(ml.parse(str, strlen(str))); DUMP(ml.dumpTree()); REQUIRE(ml.size() == 1); CHECK(ml[0].type() == MLParser::EntryType::Id); CHECK(stringCompare("s0mething", ml[0].pos, ml.size(0))); } TEST_CASE("parser: number", "[parser]") { MLParser ml; const char* str("123.4"); REQUIRE(ml.parse(str, strlen(str))); DUMP(ml.dumpTree()); REQUIRE(ml.size() == 1); CHECK(ml[0].type() == MLParser::EntryType::Number); CHECK(stringCompare("123.4", ml[0].pos, ml.size(0))); } TEST_CASE("parser: number negative", "[parser]") { MLParser ml; const char* str("-123.4"); REQUIRE(ml.parse(str, strlen(str))); DUMP(ml.dumpTree()); REQUIRE(ml.size() == 1); CHECK(ml[0].type() == MLParser::EntryType::Number); CHECK(stringCompare("-123.4", ml[0].pos, ml.size(0))); } TEST_CASE("parser: number invalid", "[parser]") { MLParser ml; const char* str("-12.3.4"); CHECK(!ml.parse(str, strlen(str))); str = "12f"; CHECK(!ml.parse(str, strlen(str))); } TEST_CASE("parser: function", "[parser]") { MLParser ml; const char* str("combine(id1, id2, id3)"); REQUIRE(ml.parse(str, strlen(str))); DUMP(ml.dumpTree()); REQUIRE(ml.size() == 4); CHECK(ml[0].type() == MLParser::EntryType::Function); CHECK(ml[1].type() == MLParser::EntryType::Id); CHECK(ml[2].type() == MLParser::EntryType::Id); CHECK(ml[3].type() == MLParser::EntryType::Id); CHECK(ml[0].next == ml.size()); CHECK(stringCompare("combine", ml[0].pos, ml.size(0))); } TEST_CASE("parser: function empty", "[parser]") { MLParser ml; const char* str("combine()"); REQUIRE(ml.parse(str, strlen(str))); DUMP(ml.dumpTree()); REQUIRE(ml.size() == 1); CHECK(ml[0].type() == MLParser::EntryType::Function); CHECK(ml[0].next == ml.size()); CHECK(stringCompare("combine", ml[0].pos, ml.size(0))); } TEST_CASE("parser: color", "[parser]") { MLParser ml; const char* str("#1234abcd"); REQUIRE(ml.parse(str, strlen(str))); DUMP(ml.dumpTree()); REQUIRE(ml.size() == 1); CHECK(ml[0].type() == MLParser::EntryType::Color); CHECK(stringCompare("#1234abcd", ml[0].pos, ml.size(0))); } TEST_CASE("parser: string", "[parser]") { MLParser ml; const char* str("\"str\""); REQUIRE(ml.parse(str, strlen(str))); DUMP(ml.dumpTree()); REQUIRE(ml.size() == 1); CHECK(ml[0].type() == MLParser::EntryType::String); CHECK(stringCompare("\"str\"", ml[0].pos, ml.size(0))); } TEST_CASE("parser: list", "[parser]") { MLParser ml; const char* str("[#ffaacc, someId, [id5, id6], anotherId]"); REQUIRE(ml.parse(str, strlen(str))); DUMP(ml.dumpTree()); REQUIRE(ml.size() == 7); CHECK(ml[0].type() == MLParser::EntryType::List); CHECK(ml[3].type() == MLParser::EntryType::List); CHECK(stringCompare("#ffaacc", ml[1].pos, ml.size(1))); CHECK(stringCompare("someId", ml[2].pos, ml.size(2))); CHECK(stringCompare("id5", ml[4].pos, ml.size(4))); CHECK(stringCompare("id6", ml[5].pos, ml.size(5))); CHECK(stringCompare("anotherId", ml[6].pos, ml.size(6))); } TEST_CASE("parser: operation", "[parser]") { MLParser ml; const char* str("a + b * (c + f(d))"); REQUIRE(ml.parse(str, strlen(str))); DUMP(ml.dumpTree()); REQUIRE(ml.size() == 8); CHECK(ml[1].type() == MLParser::EntryType::Operator); } TEST_CASE("parser: operation invalid", "[parser]") { MLParser ml; const char* str("a + + b"); CHECK(!ml.parse(str, strlen(str))); } TEST_CASE("parser: operation invalid 2", "[parser]") { MLParser ml; const char* str("* c"); CHECK(!ml.parse(str, strlen(str))); } TEST_CASE("parser: object", "[parser]") { MLParser ml; const char* str("Object { // comment" _" key: value // comment" _" id: [list] // comment" _" obj { } // comment" _" obj2 { // comment" _" obj3 { // comment" _" [ // block" _" id: f(x) // comment" _" ] // comment" _" } // comment" _" } // comment" _"} // comment"); REQUIRE(ml.parse(str, strlen(str))); DUMP(ml.dumpTree()); CHECK(ml[0].type() == MLParser::EntryType::Object); CHECK(ml[0].next == ml.size()); } TEST_CASE("parser: wildcar", "[parser]") { MLParser ml; const char* str("@"); CHECK(ml.parse(str, strlen(str))); DUMP(ml.dumpTree()); REQUIRE(ml.size() == 1); CHECK(ml[0].type() == MLParser::EntryType::Wildcar); CHECK(ml[0].next == ml.size()); } TEST_CASE("parser: attributes", "[parser]") { MLParser ml; const char* str("self.width"); CHECK(ml.parse(str, strlen(str))); DUMP(ml.dumpTree()); REQUIRE(ml.size() == 2); CHECK(ml[0].type() == MLParser::EntryType::Id); CHECK(ml[1].type() == MLParser::EntryType::Attribute); } TEST_CASE("parser: assign", "[parser]") { MLParser ml; const char* str("a = 7"); CHECK(ml.parse(str, strlen(str))); DUMP(ml.dumpTree()); REQUIRE(ml.size() == 3); CHECK(ml[0].type() == MLParser::EntryType::Id); CHECK(ml[1].type() == MLParser::EntryType::Operator); CHECK(ml[2].type() == MLParser::EntryType::Number); } TEST_CASE("parser: failing case operation", "[parser]") { MLParser ml; const char* str("(12 + 21) / 2"); CHECK(ml.parse(str, strlen(str))); DUMP(ml.dumpTree()); REQUIRE(ml.size() == 5); } TEST_CASE("parser: failing case operation 2", "[parser]") { MLParser ml; const char* str("f(x + w*0.5, (y-2) + h*0.5)"); CHECK(ml.parse(str, strlen(str))); DUMP(ml.dumpTree()); REQUIRE(ml.size() == 13); CHECK(ml[2].next == 6); } TEST_CASE("parser: assign op", "[parser]") { MLParser ml; const char* str("x ^= 1"); CHECK(ml.parse(str, strlen(str))); DUMP(ml.dumpTree()); REQUIRE(ml.size() == 3); CHECK(ml[1].type() == MLParser::EntryType::Operator); } TEST_CASE("parser: complex object properties", "[parser]") { MLParser ml; const char* str("Object {" _" x: y + 1" _" y: (x * 5) + 2" _"}"); CHECK(ml.parse(str, strlen(str))); DUMP(ml.dumpTree()); REQUIRE(ml.size() == 11); CHECK(ml[2].next == 5); CHECK(ml[6].next == 11); }
30.361702
68
0.55417
protocolocon
85cfdef4c6e0b72a70a5a5674f7cb49381df7379
4,605
cpp
C++
Sources/RealSense/Microsoft.Psi.RealSense_Interop.Windows.x64/RealSenseDeviceUnmanaged.cpp
pat-sweeney/psi
273b6d442821cc9942953ea6b51cfcff0edda11f
[ "MIT" ]
332
2019-05-10T20:30:40.000Z
2022-03-14T08:42:33.000Z
Sources/RealSense/Microsoft.Psi.RealSense_Interop.Windows.x64/RealSenseDeviceUnmanaged.cpp
pat-sweeney/psi
273b6d442821cc9942953ea6b51cfcff0edda11f
[ "MIT" ]
117
2019-06-12T21:13:03.000Z
2022-03-19T00:32:20.000Z
Sources/RealSense/Microsoft.Psi.RealSense_Interop.Windows.x64/RealSenseDeviceUnmanaged.cpp
pat-sweeney/psi
273b6d442821cc9942953ea6b51cfcff0edda11f
[ "MIT" ]
73
2019-05-08T21:39:06.000Z
2022-03-24T08:34:26.000Z
// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. #include "RealSenseDeviceUnmanaged.h" #include "librealsense2\h\rs_sensor.h" #pragma managed(push, off) RealSenseDeviceUnmanaged::RealSenseDeviceUnmanaged() { refCount = 0; } RealSenseDeviceUnmanaged::~RealSenseDeviceUnmanaged() { pipeline.stop(); } #ifdef DUMP_DEVICE_INFO void RealSenseDeviceUnmanaged::DumpDeviceInfo() { rs2::context ctx; rs2::device_list devices = ctx.query_devices(); for (rs2::device device : devices) { wchar_t buf[1024]; swprintf(buf, L"Device: %S\n", device.get_info(RS2_CAMERA_INFO_NAME)); OutputDebugString(buf); std::vector<rs2::sensor> sensors = device.query_sensors(); for (rs2::sensor sensor : sensors) { swprintf(buf, L"Sensor: %S\n", sensor.get_info(RS2_CAMERA_INFO_NAME)); OutputDebugString(buf); std::vector<rs2::stream_profile> strmProfiles = sensor.get_stream_profiles(); for (int i = 0; i < strmProfiles.size(); i++) { rs2::stream_profile sprof = strmProfiles[i]; int w, h; rs2_get_video_stream_resolution(sprof.get(), &w, &h, nullptr); swprintf(buf, L"Profile %d: StrmIndex:%d StrmType:%S Width:%d Height:%d Format:%S FPS:%d\n", i, sprof.stream_index(), rs2_stream_to_string(sprof.stream_type()), w, h, rs2_format_to_string(sprof.format()), sprof.fps()); OutputDebugString(buf); } for (int i = 0; i < RS2_OPTION_COUNT; i++) { rs2_option option_type = static_cast<rs2_option>(i); if (sensor.supports(option_type)) { const char* description = sensor.get_option_description(option_type); swprintf(buf, L" Option:%S\n", description); OutputDebugString(buf); float current_value = sensor.get_option(option_type); swprintf(buf, L" Value:%f\n", current_value); OutputDebugString(buf); } } } } } #endif // DUMP_DEVICE_INFO unsigned int RealSenseDeviceUnmanaged::Initialize() { try { rs2::config config; config.enable_all_streams(); rs2::pipeline_profile pipeprof = pipeline.start(); // Read 30 frames so that things like autoexposure settle for (int i = 0; i < 30; i++) { try { pipeline.wait_for_frames(); } catch (...) { } } rs2::frameset frame = pipeline.wait_for_frames(); rs2::video_frame colorFrame = frame.get_color_frame(); if (colorFrame) { colorWidth = colorFrame.get_width(); colorHeight = colorFrame.get_height(); colorBpp = colorFrame.get_bits_per_pixel(); colorStride = colorFrame.get_stride_in_bytes(); } rs2::depth_frame depthFrame = frame.get_depth_frame(); if (depthFrame) { depthWidth = depthFrame.get_width(); depthHeight = depthFrame.get_height(); depthBpp = depthFrame.get_bits_per_pixel(); depthStride = depthFrame.get_stride_in_bytes(); } } catch (...) { return E_UNEXPECTED; } return 0; } unsigned int RealSenseDeviceUnmanaged::ReadFrame(char *colorBuffer, unsigned int colorBufferLen, char *depthBuffer, unsigned int depthBufferLen) { try { rs2::frameset frame = pipeline.wait_for_frames(); auto colorFrame = frame.get_color_frame(); int w = colorFrame.get_width(); int h = colorFrame.get_height(); int stride = colorFrame.get_stride_in_bytes(); int bpp = colorFrame.get_bytes_per_pixel(); unsigned int colorFrameSize = h * stride; if (colorFrameSize > colorBufferLen) { return E_UNEXPECTED; } char *srcRow = (char*)colorFrame.get_data(); char *dstRow = colorBuffer; for (int y = 0; y < h; y++) { char *srcCol = srcRow; char *dstCol = dstRow; for (int x = 0; x < w; x++) { dstCol[2] = srcCol[0]; dstCol[1] = srcCol[1]; dstCol[0] = srcCol[2]; srcCol += bpp; dstCol += 3; } srcRow += stride; dstRow += w * 3; } auto depthFrame = frame.get_depth_frame(); unsigned int depthFrameSize = depthFrame.get_height() * depthFrame.get_stride_in_bytes(); if (depthFrameSize > depthBufferLen) { return E_UNEXPECTED; } memcpy(depthBuffer, depthFrame.get_data(), depthFrameSize); } catch (...) { } return S_OK; } unsigned int RealSenseDeviceUnmanaged::AddRef() { return refCount++; } unsigned int RealSenseDeviceUnmanaged::Release() { unsigned int refcnt = --refCount; if (refcnt == 0) { delete this; } return refcnt; } unsigned int CreateRealSenseDeviceUnmanaged(IRealSenseDeviceUnmanaged **device) { RealSenseDeviceUnmanaged *dev = new RealSenseDeviceUnmanaged(); if (dev == nullptr) { return E_OUTOFMEMORY; } dev->Initialize(); dev->AddRef(); *device = dev; return S_OK; } #pragma managed(pop)
24.365079
144
0.686862
pat-sweeney
85d8971a1c6bc4ddede096086254af866af86abd
4,427
hpp
C++
Firmware/communication/can/can_simple.hpp
takijo0116/ODrive
4c01d0bff2a1c4a67e0f9979c9797b846f5de5d2
[ "MIT" ]
1
2021-06-08T13:10:27.000Z
2021-06-08T13:10:27.000Z
Firmware/communication/can/can_simple.hpp
takijo0116/ODrive
4c01d0bff2a1c4a67e0f9979c9797b846f5de5d2
[ "MIT" ]
null
null
null
Firmware/communication/can/can_simple.hpp
takijo0116/ODrive
4c01d0bff2a1c4a67e0f9979c9797b846f5de5d2
[ "MIT" ]
null
null
null
#ifndef __CAN_SIMPLE_HPP_ #define __CAN_SIMPLE_HPP_ #include <interfaces/canbus.hpp> #include "axis.hpp" class CANSimple { public: enum { MSG_CO_NMT_CTRL = 0x000, // CANOpen NMT Message REC MSG_ODRIVE_HEARTBEAT, MSG_ODRIVE_ESTOP, MSG_GET_MOTOR_ERROR, // Errors MSG_GET_ENCODER_ERROR, MSG_GET_SENSORLESS_ERROR, MSG_SET_AXIS_NODE_ID, MSG_SET_AXIS_REQUESTED_STATE, MSG_SET_AXIS_STARTUP_CONFIG, MSG_GET_ENCODER_ESTIMATES, MSG_GET_ENCODER_COUNT, MSG_SET_CONTROLLER_MODES, MSG_SET_INPUT_POS, MSG_SET_INPUT_VEL, MSG_SET_INPUT_TORQUE, MSG_SET_LIMITS, MSG_START_ANTICOGGING, MSG_SET_TRAJ_VEL_LIMIT, MSG_SET_TRAJ_ACCEL_LIMITS, MSG_SET_TRAJ_INERTIA, MSG_GET_IQ, MSG_GET_SENSORLESS_ESTIMATES, MSG_RESET_ODRIVE, MSG_GET_VBUS_VOLTAGE, MSG_CLEAR_ERRORS, MSG_CO_HEARTBEAT_CMD = 0x700, // CANOpen NMT Heartbeat SEND }; CANSimple(CanBusBase* canbus) : canbus_(canbus) {} bool init(fibre::Callback<bool, float, fibre::Callback<void>> timer, uint32_t tx_slots_start, uint32_t tx_slots_end, uint32_t rx_slot); private: struct PeriodicHandler { CANSimple* parent_; Axis* axis; int type; uint32_t* interval; uint32_t last; void trigger() { parent_->send_periodic(this); } }; bool renew_subscription(size_t i); void on_received(const can_Message_t& msg); //void on_sent(bool success); void send_periodic(PeriodicHandler* handler); void do_command(Axis& axis, const can_Message_t& cmd); // Get functions (msg.rtr bit must be set) void get_heartbeat(const Axis& axis, can_Message_t& txmsg); void get_motor_error_callback(const Axis& axis, can_Message_t& txmsg); void get_encoder_error_callback(const Axis& axis, can_Message_t& txmsg); void get_sensorless_error_callback(const Axis& axis, can_Message_t& txmsg); void get_encoder_estimates_callback(const Axis& axis, can_Message_t& txmsg); void get_encoder_count_callback(const Axis& axis, can_Message_t& txmsg); void get_iq_callback(const Axis& axis, can_Message_t& txmsg); void get_sensorless_estimates_callback(const Axis& axis, can_Message_t& txmsg); void get_vbus_voltage_callback(const Axis& axis, can_Message_t& txmsg); // Set functions static void set_axis_nodeid_callback(Axis& axis, const can_Message_t& msg); static void set_axis_requested_state_callback(Axis& axis, const can_Message_t& msg); static void set_axis_startup_config_callback(Axis& axis, const can_Message_t& msg); static void set_input_pos_callback(Axis& axis, const can_Message_t& msg); static void set_input_vel_callback(Axis& axis, const can_Message_t& msg); static void set_input_torque_callback(Axis& axis, const can_Message_t& msg); static void set_controller_modes_callback(Axis& axis, const can_Message_t& msg); static void set_limits_callback(Axis& axis, const can_Message_t& msg); static void set_traj_vel_limit_callback(Axis& axis, const can_Message_t& msg); static void set_traj_accel_limits_callback(Axis& axis, const can_Message_t& msg); static void set_traj_inertia_callback(Axis& axis, const can_Message_t& msg); static void set_linear_count_callback(Axis& axis, const can_Message_t& msg); // Other functions static void estop_callback(Axis& axis, const can_Message_t& msg); static void clear_errors_callback(Axis& axis, const can_Message_t& msg); static void start_anticogging_callback(const Axis& axis, const can_Message_t& msg); static constexpr uint8_t NUM_NODE_ID_BITS = 6; static constexpr uint8_t NUM_CMD_ID_BITS = 11 - NUM_NODE_ID_BITS; // Utility functions static constexpr uint32_t get_node_id(uint32_t msgID) { return (msgID >> NUM_CMD_ID_BITS); // Upper 6 or more bits }; static constexpr uint8_t get_cmd_id(uint32_t msgID) { return (msgID & 0x01F); // Bottom 5 bits } CanBusBase* canbus_; CanBusBase::CanSubscription* subscription_handles_[AXIS_COUNT]; fibre::Callback<bool, float, fibre::Callback<void>> timer_; uint32_t tx_slots_start_; uint32_t tx_slots_end_; uint32_t response_tx_slot_; uint32_t rx_slot_; std::array<PeriodicHandler, 2 * AXIS_COUNT> periodic_handlers_; }; #endif
38.833333
139
0.727355
takijo0116
85d93d6a22aedcccd4bfe212c8e59a9be7b48290
2,387
cpp
C++
PA/Laborator/2020-2021/lab05 - Backtracking/cpp/task-1/main.cpp
mihai-constantin/ACS
098c99d82dad8fb5d0e909da930c72f1185a99e2
[ "Apache-2.0" ]
null
null
null
PA/Laborator/2020-2021/lab05 - Backtracking/cpp/task-1/main.cpp
mihai-constantin/ACS
098c99d82dad8fb5d0e909da930c72f1185a99e2
[ "Apache-2.0" ]
null
null
null
PA/Laborator/2020-2021/lab05 - Backtracking/cpp/task-1/main.cpp
mihai-constantin/ACS
098c99d82dad8fb5d0e909da930c72f1185a99e2
[ "Apache-2.0" ]
null
null
null
#include <iostream> #include <fstream> #include <vector> #include <unordered_set> using namespace std; class Task { public: void solve() { read_input(); print_output(get_result()); } private: int n, k; void read_input() { ifstream fin("in"); fin >> n >> k; fin.close(); } void bkt(int step, int stop, vector<int> &domain, vector<int> &solution, unordered_set<int> &visited, vector<vector<int> > &all) { if (step == stop) { all.push_back(solution); return; } for (int i = 0; i < domain.size(); i++) { if (visited.find(domain[i]) == visited.end()) { visited.insert(domain[i]); solution[step] = domain[i]; bkt(step + 1, stop, domain, solution, visited, all); visited.erase(domain[i]); } } } vector<vector<int> > get_result() { vector<vector<int> > all; // TODO: Construiti toate aranjamentele de N luate cate K ale // multimii {1, ..., N}. // // Pentru a adauga un nou aranjament: // vector<int> aranjament; // all.push_back(aranjament); unordered_set<int> visited; vector<int> solution(k); vector<int> domain(n); for (int i = 0; i < n; i++) { domain[i] = i + 1; } bkt(0, k, domain, solution, visited, all); return all; } void print_output(const vector<vector<int> >& result) { ofstream fout("out"); fout << result.size() << '\n'; for (size_t i = 0; i < result.size(); i++) { for (size_t j = 0; j < result[i].size(); j++) { fout << result[i][j] << (j + 1 != result[i].size() ? ' ' : '\n'); } } fout.close(); } }; // [ATENTIE] NU modifica functia main! int main() { // * se aloca un obiect Task pe heap // (se presupune ca e prea mare pentru a fi alocat pe stiva) // * se apeleaza metoda solve() // (citire, rezolvare, printare) // * se distruge obiectul si se elibereaza memoria auto* task = new (std::nothrow) Task{}; // hint: cppreference/nothrow if (!task) { std::cerr << "new failed: WTF are you doing? Throw your PC!\n"; return -1; } task->solve(); delete task; return 0; }
27.125
134
0.509426
mihai-constantin
85e3a224111597a9bf265290809deab4b227b0c2
9,112
cpp
C++
SVEngine/src/node/SVScene.cpp
SVEChina/SVEngine
56174f479a3096e57165448142c1822e7db8c02f
[ "MIT" ]
34
2018-09-28T08:28:27.000Z
2022-01-15T10:31:41.000Z
SVEngine/src/node/SVScene.cpp
SVEChina/SVEngine
56174f479a3096e57165448142c1822e7db8c02f
[ "MIT" ]
null
null
null
SVEngine/src/node/SVScene.cpp
SVEChina/SVEngine
56174f479a3096e57165448142c1822e7db8c02f
[ "MIT" ]
8
2018-10-11T13:36:35.000Z
2021-04-01T09:29:34.000Z
// // SVScene.cpp // SVEngine // Copyright 2017-2020 // yizhou Fu,long Yin,longfei Lin,ziyu Xu,xiaofan Li,daming Li // #include "SVScene.h" #include "SVCameraNode.h" #include "SVNode.h" #include "SVNodeVisit.h" #include "../app/SVGlobalMgr.h" #include "../app/SVGlobalParam.h" #include "../basesys/SVStaticData.h" #include "../rendercore/SVRenderMgr.h" #include "../rendercore/SVRenderScene.h" #include "../rendercore/SVRenderer.h" #include "../rendercore/SVRenderObject.h" #include "../rendercore/SVRenderCmd.h" #include "../event/SVEventMgr.h" #include "../event/SVEvent.h" #include "../event/SVOpEvent.h" #include "../basesys/SVSceneMgr.h" #include "../basesys/SVCameraMgr.h" #include "../basesys/SVConfig.h" #include "../mtl/SVTexMgr.h" #include "../mtl/SVTexture.h" SVTree4::SVTree4(SVInst *_app) :SVGBase(_app){ m_treeLock = MakeSharedPtr<SVLock>(); for(s32 i=0;i<4;i++){ m_pTreeNode[i] = nullptr; } m_node = nullptr; } SVTree4::~SVTree4(){ m_node = nullptr; for(s32 i=0;i<4;i++){ m_pTreeNode[i] = nullptr; } m_treeLock = nullptr; } //世界大小和深度 void SVTree4::create(SVBoundBox& _box,s32 _depth){ m_treeBox = _box; //构建场景树 if(_depth>0){ FVec3 t_max = _box.getMax(); FVec3 t_min = _box.getMin(); FVec3 t_center = (t_max + t_min)*0.5f; //0 第一象限 SVBoundBox t_box0(t_center,t_max); m_pTreeNode[0] = MakeSharedPtr<SVTree4>(mApp); m_pTreeNode[0]->create(t_box0,_depth-1); //1 第二象限 SVBoundBox t_box1( FVec3(t_min.x,t_center.y,0.0f),FVec3(t_center.x,t_max.y,0.0f) ); m_pTreeNode[1] = MakeSharedPtr<SVTree4>(mApp); m_pTreeNode[1]->create(t_box1,_depth-1); //2 第三象限 SVBoundBox t_box2(t_min,t_center); m_pTreeNode[2] = MakeSharedPtr<SVTree4>(mApp); m_pTreeNode[2]->create(t_box2,_depth-1); //3 第四象限 SVBoundBox t_box3( FVec3(t_center.x,t_min.y,0.0f),FVec3(t_max.x,t_center.y,0.0f) ); m_pTreeNode[3] = MakeSharedPtr<SVTree4>(mApp); m_pTreeNode[3]->create(t_box3,_depth-1); }else{ //叶子节点 m_node = MakeSharedPtr<SVNode>(mApp); } } void SVTree4::destroy(){ m_treeLock->lock(); for(s32 i=0;i<4;i++){ if(m_pTreeNode[i]){ m_pTreeNode[i]->destroy(); } } m_treeLock->unlock(); clearNode(); } void SVTree4::update(f32 _dt){ m_treeLock->lock(); //本身挂载的节点进行更新 if(m_node) { m_node->deep_update(_dt); }else{ for(s32 i=0;i<4;i++){ if(m_pTreeNode[i]){ m_pTreeNode[i]->update(_dt); } } } m_treeLock->unlock(); } void SVTree4::visit(SVVisitorBasePtr _visitor){ m_treeLock->lock(); if(m_node) { m_node->deep_visit(_visitor); }else{ for(s32 i=0;i<4;i++){ if(m_pTreeNode[i]){ m_pTreeNode[i]->visit(_visitor); } } } m_treeLock->unlock(); } bool SVTree4::_isIn(SVNodePtr _node) { FVec3 t_pos = _node->getPosition(); //这块z先改为了0!!!!!!!!!!!! t_pos.z = 0; //在内部(以1,2,3,4)现象为顺序 if( m_treeBox.inside(t_pos) ){ return true; } return false; } void SVTree4::addNode(SVNodePtr _node, s32 iZOrder){ if (_node){ _node->setZOrder(iZOrder); addNode(_node); } } //增加节点 void SVTree4::addNode(SVNodePtr _node) { if(m_node) { m_node->addChild(_node); }else{ for(s32 i=0;i<4;i++){ if( m_pTreeNode[i]->_isIn(_node) ){ m_pTreeNode[i]->addNode(_node); break; } } } } //移除节点 bool SVTree4::removeNode(SVNodePtr _node) { bool t_ret = false; if(m_node) { t_ret = m_node->removeChild(_node); }else{ for(s32 i=0;i<4;i++){ if( m_pTreeNode[i]->removeNode(_node) ) { return true; } } } return t_ret; } //清理节点 void SVTree4::clearNode() { if(m_node) { m_node->clearChild(); }else{ for(s32 i=0;i<4;i++){ m_pTreeNode[i]->clearNode(); } } } bool SVTree4::hasNode(SVNodePtr _node) { if(m_node) { return m_node->hasChild(_node); }else{ for(s32 i=0;i<4;i++){ if( m_pTreeNode[i]->hasNode(_node) ){ return true; } } } return false; } //逻辑场景 SVScene::SVScene(SVInst *_app,cptr8 _name) :SVGBase(_app) { m_name = _name; m_color.setColorARGB(0x00000000); m_worldW = 0; m_worldH = 0; m_worldD = 0; //场景树 m_pSceneTree = MakeSharedPtr<SVTree4>(_app); //渲染场景 m_pRenderScene = MakeSharedPtr<SVRenderScene>(_app); } SVScene::~SVScene() { if(m_pSceneTree){ m_pSceneTree->destroy(); m_pSceneTree = nullptr; } m_pRenderScene = nullptr; } void SVScene::create(f32 _worldw ,f32 _worldh,s32 _depth){ m_worldW = _worldw; m_worldH = _worldh; m_worldD = _depth; if(m_pSceneTree){ SVBoundBox _box; FVec3 t_min,t_max; t_min.set(-0.5f*_worldw,-0.5f*_worldh, 0.0f); t_max.set(0.5f*_worldw,0.5f*_worldh, 0.0f); _box.set(t_min, t_max); m_pSceneTree->create(_box,_depth); } s32 m_sw = mApp->m_pGlobalParam->m_inner_width; s32 m_sh = mApp->m_pGlobalParam->m_inner_height; SVCameraNodePtr mainCamera = mApp->getCameraMgr()->getMainCamera(); if(mainCamera) { mainCamera->resetCamera(m_sw,m_sh); } // SVCameraNodePtr uiCamera = mApp->getCameraMgr()->getUICamera(); if(uiCamera) { uiCamera->resetCamera(m_sw,m_sh); } // } void SVScene::destroy(){ } void SVScene::addNode(SVNodePtr _node){ if(_node && m_pSceneTree){ m_pSceneTree->addNode(_node); } } void SVScene::addNode(SVNodePtr _node,s32 _zorder){ if(_node && m_pSceneTree){ _node->setZOrder(_zorder); addNode(_node); } } void SVScene::removeNode(SVNodePtr _node){ if(_node && m_pSceneTree){ m_pSceneTree->removeNode(_node); } } void SVScene::active() { } void SVScene::unactive() { } void SVScene::setSceneColor(f32 _r,f32 _g,f32 _b,f32 _a) { m_color.setColor(_r, _g, _b, _a); } void SVScene::update(f32 dt) { //遍历场景树 if(m_pSceneTree){ m_pSceneTree->update(dt); } // SVRendererPtr t_renderer = mApp->getRenderer(); if( t_renderer && t_renderer->hasSVTex(E_TEX_MAIN) ){ if (m_pRenderScene && false == m_pRenderScene->isSuspend() ) { SVRenderCmdFboBindPtr t_fbo_bind = MakeSharedPtr<SVRenderCmdFboBind>(t_renderer->getRenderTexture()); t_fbo_bind->mTag = "main_frame_bind"; m_pRenderScene->pushRenderCmd(RST_SCENE_BEGIN, t_fbo_bind); // SVRenderCmdClearPtr t_clear = MakeSharedPtr<SVRenderCmdClear>(); t_clear->mTag = "main_frame_clear"; t_clear->setRenderer(t_renderer); t_clear->setClearColor(m_color.r, m_color.g, m_color.b, m_color.a); m_pRenderScene->pushRenderCmd(RST_SCENE_BEGIN, t_clear); // SVRenderCmdFboUnbindPtr t_fbo_unbind = MakeSharedPtr<SVRenderCmdFboUnbind>(t_renderer->getRenderTexture()); t_fbo_unbind->mTag = "main_frame_unbind"; m_pRenderScene->pushRenderCmd(RST_SCENE_END, t_fbo_unbind); } } } void SVScene::visit(SVVisitorBasePtr _visitor){ if( m_pSceneTree ){ m_pSceneTree->visit(_visitor); } } SVRenderScenePtr SVScene::getRenderRS(){ return m_pRenderScene; } bool SVScene::procEvent(SVEventPtr _event) { return true; } //序列化场景 void SVScene::toJSON(RAPIDJSON_NAMESPACE::Document::AllocatorType &_allocator, RAPIDJSON_NAMESPACE::Value &_objValue) { RAPIDJSON_NAMESPACE::Value locationObj(RAPIDJSON_NAMESPACE::kObjectType);//创建一个Object类型的元素 locationObj.AddMember("name", RAPIDJSON_NAMESPACE::StringRef(m_name.c_str()), _allocator); u32 t_color = m_color.getColorARGB(); locationObj.AddMember("color", t_color, _allocator); locationObj.AddMember("worldw", m_worldW, _allocator); locationObj.AddMember("worldh", m_worldH, _allocator); locationObj.AddMember("worldd", m_worldD, _allocator); //序列化树 ? 要做这么复杂吗 if(m_pSceneTree){ } // _objValue.AddMember("SVScene", locationObj, _allocator); } void SVScene::fromJSON(RAPIDJSON_NAMESPACE::Value &item) { if (item.HasMember("name") && item["name"].IsString()) { m_name = item["name"].GetString(); } if (item.HasMember("color") && item["color"].IsUint()) { u32 t_color = item["color"].GetUint(); m_color.setColorARGB(t_color); } if (item.HasMember("worldw") && item["worldw"].IsFloat()) { m_worldW = item["worldw"].GetFloat(); } if (item.HasMember("worldh") && item["worldh"].IsFloat()) { m_worldH = item["worldh"].GetFloat(); } if (item.HasMember("worldd") && item["worldd"].IsInt()) { m_worldD = item["worldd"].GetInt(); } // if(!m_pSceneTree){ create(m_worldW,m_worldH,m_worldD); } }
26.259366
119
0.605685
SVEChina
85e7b434e4ae6c6d34529f621c507473dfc60304
1,067
hpp
C++
include/edlib/Hamiltonians/TITFIsing.hpp
chaeyeunpark/ExactDiagonalization
c93754e724486cc68453399c5dda6a2dadf45cb8
[ "MIT" ]
1
2021-04-24T08:47:05.000Z
2021-04-24T08:47:05.000Z
include/edlib/Hamiltonians/TITFIsing.hpp
chaeyeunpark/ExactDiagonalization
c93754e724486cc68453399c5dda6a2dadf45cb8
[ "MIT" ]
1
2021-09-28T19:02:14.000Z
2021-09-28T19:02:14.000Z
include/edlib/Hamiltonians/TITFIsing.hpp
chaeyeunpark/ExactDiagonalization
c93754e724486cc68453399c5dda6a2dadf45cb8
[ "MIT" ]
1
2020-03-22T18:59:11.000Z
2020-03-22T18:59:11.000Z
#ifndef ED_TITFI_HPP #define ED_TITFI_HPP #include <cstdint> #include <cassert> #include <algorithm> #include <map> #include <boost/dynamic_bitset.hpp> //#include "BitOperations.h" #include "../Basis/AbstractBasis1D.hpp" template<typename UINT> class TITFIsing { private: const edlib::AbstractBasis1D<UINT>& basis_; double J_; double h_; public: TITFIsing(const edlib::AbstractBasis1D<UINT>& basis, double J, double h) : basis_(basis), J_(J), h_(h) { } std::map<std::size_t,double> getCol(UINT n) const { unsigned int N = basis_.getN(); UINT a = basis_.getNthRep(n); const boost::dynamic_bitset<> bs(N, a); std::map<std::size_t, double> m; for(unsigned int i = 0; i < N; i++) { //Next-nearest { unsigned int j = (i+1)%N; int sgn = (1-2*bs[i])*(1-2*bs[j]); m[n] += -J_*sgn; //ZZ UINT s = a; s ^= basis_.mask({i}); int bidx; double coeff; std::tie(bidx, coeff) = basis_.hamiltonianCoeff(s, n); if(bidx >= 0) m[bidx] += -h_*coeff; } } return m; } }; #endif //ED_TITFI_HPP
18.084746
73
0.618557
chaeyeunpark