TEST_F(MindMapModelTest, sortChangeParent) { Mindmapmodel->createMindMap("Root"); Mindmapmodel->createNode("Node1"); Mindmapmodel->insertNodeChild(0, 1); Mindmapmodel->createNode("Node2"); Mindmapmodel->insertNodeChild(1, 2); Mindmapmodel->createNode("Node3"); Mindmapmodel->insertNodeSibling(1, 3); ASSERT_FALSE(Mindmapmodel->sortChangeParent(Mindmapmodel->MindMap[1]->getNodeList(), FIRST_NODE, 3)); TearDown(); SetUp(); Mindmapmodel->createMindMap("Root"); Mindmapmodel->createNode("Node1"); Mindmapmodel->insertNodeChild(0, 1); Mindmapmodel->createNode("Node2"); Mindmapmodel->insertNodeChild(1, 2); Mindmapmodel->createNode("Node3"); Mindmapmodel->insertNodeSibling(1, 3); ASSERT_TRUE(Mindmapmodel->sortChangeParent(Mindmapmodel->MindMap[1]->getNodeList(), FIRST_NODE, 2)); TearDown(); SetUp(); Mindmapmodel->createMindMap("Root"); Mindmapmodel->createNode("Node1"); Mindmapmodel->insertNodeChild(0, 1); Mindmapmodel->createNode("Node2"); Mindmapmodel->insertNodeChild(1, 2); Mindmapmodel->createNode("Node3"); Mindmapmodel->insertNodeChild(2, 3); ASSERT_TRUE(Mindmapmodel->sortChangeParent(Mindmapmodel->MindMap[1]->getNodeList(), FIRST_NODE, 3)); }
void SceneCamera::Update(){ if(inversed) { SetUp(control[currentType]->GetUp() * -1); //SetPosition(control[currentType]->GetPosition() * -1); //SetDirection(control[currentType]->GetDirection() *-1 ); } else { SetUp(control[currentType]->GetUp()); SetPosition(control[currentType]->GetPosition()); SetDirection(control[currentType]->GetDirection()); } // cout << "[SCENECAMERA][Update] controltype " << (int)currentType << endl; }
/// @param iterations Number of iterations to gather data for. /// @returns the number of nanoseconds the run took. uint64_t Run(std::size_t iterations) { std::size_t iteration = iterations; // Set up the testing fixture. SetUp(); // Get the starting time. Clock::TimePoint startTime, endTime; startTime = Clock::Now(); // Run the test body for each iteration. while (iteration--) TestBody(); // Get the ending time. endTime = Clock::Now(); // Tear down the testing fixture. TearDown(); // Return the duration in nanoseconds. return Clock::Duration(startTime, endTime); }
/*! * * @param lookAtVec * @param upVec */ Camera::Camera(glm::vec3 positionVec, glm::vec3 lookAtVec, glm::vec3 upVec) { m_initPos = positionVec; m_position = positionVec; m_initLookAt = lookAtVec; m_lookAt = lookAtVec; m_initUp = upVec; m_up = upVec; m_lookVec = m_initLookAt - m_initPos; m_initSide = glm::cross(m_lookVec, m_initUp); m_side = glm::cross(m_lookVec, m_initUp); SetSide(m_side); SetUp(m_up); SetLookAt(m_lookAt); SetPosition(m_position); m_fieldOfView = 60.0f; m_width = Singleton<Context>::Instance()->GetWidth(); m_height = Singleton<Context>::Instance()->GetHeight(); m_aspect = static_cast<float>(m_width) / static_cast<float>(m_height); m_nearPlane = 0.1f; m_farPlane = 200.f; m_viewMatrix = glm::lookAt(m_position, m_lookAt, m_up); m_inverseViewMatrix = glm::inverse(m_viewMatrix); m_projectionMatrix = glm::perspective(m_fieldOfView, m_aspect, m_nearPlane, m_farPlane); m_isOrtho = false; m_speed = 0.05; }
/*! * */ Camera::Camera() { m_position = glm::vec3(0.0, 0.0, 1.0); m_lookAt = glm::vec3(0.0, 0.0, 0.0); m_up = glm::vec3(0.0, 1.0, 0.0); m_side = glm::vec3(1.0, 0.0, 0.0); SetSide(m_side); SetUp(m_up); SetLookAt(m_lookAt); SetPosition(m_position); m_fieldOfView = 60.0f; m_width = Singleton<Context>::Instance()->GetWidth(); m_height = Singleton<Context>::Instance()->GetHeight(); m_aspect = static_cast<float>(m_width) / static_cast<float>(m_height); m_nearPlane = 0.1f; m_farPlane = 200.0f; m_viewMatrix = glm::lookAt(m_position, m_lookAt, m_up); m_inverseViewMatrix = glm::inverse(m_viewMatrix); m_projectionMatrix = glm::perspective(m_fieldOfView, m_aspect, m_nearPlane, m_farPlane); m_isOrtho = false; m_speed = 0.05; }
TEST_F(nearest_neighbor_test, save_load) { { core::fv_converter::datum d; d.string_values_.push_back(std::make_pair("k1", "val")); nearest_neighbor_->set_row("1", d); } // save to a buffer msgpack::sbuffer sbuf; msgpack::packer<msgpack::sbuffer> packer(sbuf); nearest_neighbor_->get_mixable_holder()->pack(packer); // restart the driver TearDown(); SetUp(); // unpack the buffer msgpack::unpacked unpacked; msgpack::unpack(&unpacked, sbuf.data(), sbuf.size()); nearest_neighbor_->get_mixable_holder()->unpack(unpacked.get()); std::vector<std::pair<std::string, float> > res = nearest_neighbor_->similar_row("1", 1); ASSERT_EQ(1u, res.size()); EXPECT_EQ("1", res[0].first); }
int main() { printf("hello world\n"); if(SetUp() < 0) { TearDown(); return -1; } GetPortMappingNum(); //int i = 0; //for(i=0; i<30; i++) //{ // GetPortMappingByIndex(i); //} GetPortMapping(16738, "TCP"); GetPortMapping(16738, "UDP"); AddPortMapping(16738, 16738, "TCP", g_lanaddr); AddPortMapping(16738, 16738, "UDP", g_lanaddr); AddPortMapping(16738, 16738, "TCP", "192.168.1.120"); AddPortMapping(16738, 16738, "UDP", "192.168.1.120"); TearDown(); return 0; }
/* This test creates and calls the ABL wall function edge algorithm for a single-element hex8 mesh and evaluates the resulting rhs vector for one of the faces against a pre-calculated value. */ TEST_F(ABLWallFunctionHex8ElementWithBCFields, abl_wall_function_edge_alg_rhs) { const double z0 = 0.1; const double Tref = 300.0; const double gravity = 9.81; const double rho_specified = 1.0; const double utau_specified = 0.067118435077841; const double up_specified = 0.15; const double yp_specified = 0.25; const double aMag = 0.25; const double tolerance = 1.0e-6; const int numDof = 3; SetUp(rho_specified, utau_specified, up_specified, yp_specified); double rhs_gold = -rho_specified*utau_specified*utau_specified*aMag; HelperObjectsABLWallFunction helperObjs(bulk, numDof, &meta.universal_part(), z0, Tref, gravity); helperObjs.computeGeomBoundAlg->execute(); // Edge alg test helperObjs.elemABLWallFunctionSolverAlg->initialize_connectivity(); helperObjs.realm.create_edges(); helperObjs.edgeABLWallFunctionSolverAlg->execute(); unit_test_utils::TestLinearSystem *linsys = helperObjs.linsys; EXPECT_NEAR(linsys->rhs_(0), rhs_gold, tolerance); }
void RattlerRemovalServiceTests::RemoveRattlers_ForMixedPacking_CorrectParticlesRemoved() { SetUp(); // The second particle is outside const FLOAT_TYPE diameter = 1.0; const SpatialVector c0 = {{4, 4, 0}}; const SpatialVector c1 = {{7, 7, 0}}; const SpatialVector c2 = {{5, 4, 0}}; const SpatialVector c3 = {{5, 5, 0}}; particles[0] = DomainParticle(0, diameter, c0); particles[1] = DomainParticle(1, diameter, c1); particles[2] = DomainParticle(2, diameter, c2); particles[3] = DomainParticle(3, diameter, c3); rattlerRemovalService->SetParticles(particles); vector<bool> rattlerMask(particlesCount); rattlerRemovalService->FillRattlerMask(0.999, &rattlerMask); boost::array<bool, 4> expectedRattlerMask = {{false, true, false, false}}; Assert::AreVectorsEqual(expectedRattlerMask, rattlerMask, "RemoveRattlers_ForMixedPacking_CorrectParticlesRemoved"); TearDown(); }
CBlockManager::CBlockManager() { BlockNum = 30; for(int i = 0;i < BlockNum;++i) m_Blocks[i].SetUp(); SetUp(); }
void RattlerRemovalServiceTests::RemoveRattlers_ForLoosePacking_AllParticlesRemoved() { SetUp(); // Diameter of each particle is very small const FLOAT_TYPE diameter = 0.1; const SpatialVector c0 = {{4, 4, 0}}; const SpatialVector c1 = {{4, 5, 0}}; const SpatialVector c2 = {{5, 4, 0}}; const SpatialVector c3 = {{5, 5, 0}}; particles[0] = DomainParticle(0, diameter, c0); particles[1] = DomainParticle(1, diameter, c1); particles[2] = DomainParticle(2, diameter, c2); particles[3] = DomainParticle(3, diameter, c3); rattlerRemovalService->SetParticles(particles); vector<bool> rattlerMask(particlesCount); rattlerRemovalService->FillRattlerMask(0.999, &rattlerMask); boost::array<bool, 4> expectedRattlerMask = {{true, true, true, true}}; Assert::AreVectorsEqual(expectedRattlerMask, rattlerMask, "RemoveRattlers_ForLoosePacking_AllParticlesRemoved"); TearDown(); }
void Button::MouseInput(CMouse &rMouse, int32_t iButton, int32_t iX, int32_t iY, DWORD dwKeyParam) { // inherited Control::MouseInput(rMouse, iButton, iX, iY, dwKeyParam); // process left down and up if (fEnabled) switch (iButton) { case C4MC_Button_LeftDown: // mark button as being down SetDown(); // remember drag target // no dragging movement will be done w/o drag component assigned // but it should be remembered if the user leaves the button with the mouse down // and then re-enters w/o having released the button if (!rMouse.pDragElement) rMouse.pDragElement = this; break; case C4MC_Button_LeftUp: // only if button was down... (might have dragged here) if (fDown) { // it's now up :) SetUp(true); // process event OnPress(); } break; }; }
void ClosestPairProviderTests::RegisterPair_ForFourParticlesAndMovedParticleIsCloseToNonMoved_ThisPairIsReturned() { SetUp(); //Closest pair is 2-3 with distance 0.5 const FLOAT_TYPE diameter = 1.0; const SpatialVector c0 = {{5, 5, 5}}; const SpatialVector c1 = {{5.5, 5, 5}}; const SpatialVector c2 = {{5, 8, 5}}; const SpatialVector c3 = {{5.5, 8, 5}}; particles[0] = DomainParticle(0, diameter, c0); particles[1] = DomainParticle(1, diameter, c1); particles[2] = DomainParticle(2, diameter, c2); particles[3] = DomainParticle(3, diameter, c3); closestPairProvider->SetParticles(particles); closestPairProvider->StartMove(0); particles[0].coordinates[Axis::Y] = 7.9; closestPairProvider->EndMove(); ParticlePair actualPair = closestPairProvider->FindClosestPair(); ParticlePair expectedPair(0, 2, 0.1 * 0.1); AssertPair(expectedPair, actualPair, "RegisterPair_ForFourParticlesAndMovedParticleIsCloseToNonMoved_ThisPairIsReturned"); TearDown(); }
void ClosestPairProviderTests::UnregisterPair_ForFourParticles_LeftParticlesAreNearest() { SetUp(); //Closest pair is 2-3 with distance 0.5 const FLOAT_TYPE diameter = 1.0; const SpatialVector c0 = {{5, 5, 5}}; const SpatialVector c1 = {{5.9, 5, 5}}; const SpatialVector c2 = {{5, 8, 5}}; const SpatialVector c3 = {{5.5, 8, 5}}; particles[0] = DomainParticle(0, diameter, c0); particles[1] = DomainParticle(1, diameter, c1); particles[2] = DomainParticle(2, diameter, c2); particles[3] = DomainParticle(3, diameter, c3); closestPairProvider->SetParticles(particles); closestPairProvider->StartMove(2); closestPairProvider->StartMove(3); ParticlePair actualPair = closestPairProvider->FindClosestPair(); ParticlePair expectedPair(0, 1, 0.9 * 0.9); AssertPair(expectedPair, actualPair, "UnregisterPair_ForFourParticles_LeftParticlesAreNearest"); TearDown(); }
JoystickFeature(const JOYSTICK_FEATURE& feature) : m_name(feature.name ? feature.name : ""), m_type(feature.type) { switch (m_type) { case JOYSTICK_FEATURE_TYPE_SCALAR: SetPrimitive(feature.scalar.primitive); break; case JOYSTICK_FEATURE_TYPE_ANALOG_STICK: SetUp(feature.analog_stick.up); SetDown(feature.analog_stick.down); SetRight(feature.analog_stick.right); SetLeft(feature.analog_stick.left); break; case JOYSTICK_FEATURE_TYPE_ACCELEROMETER: SetPositiveX(feature.accelerometer.positive_x); SetPositiveY(feature.accelerometer.positive_y); SetPositiveZ(feature.accelerometer.positive_z); break; case JOYSTICK_FEATURE_TYPE_MOTOR: SetPrimitive(feature.motor.primitive); break; default: break; } }
void Test::__run() { LOG("[ RUN ] %s.%s", name(), method()); SetUp(); TestContext &ctx = TestContext::getInstance(); ctx.setTest(name(), method()); StopWatch stopwatch; stopwatch.start(); __test(); stopwatch.stop(); int ms = stopwatch.getTimeMillisecond(); passCount_ = ctx.successCount(); failCount_ = ctx.failCount(); if(fail() == 0) { LOG("[ OK ] %s.%s (%d ms)", name(), method(), ms); } else { LOG("[ FAILED ] %s.%s (%d ms)", name(), method(), ms); } TearDown(); }
Int2 Main (void) { WindoW w; GrouP g; ButtoN b1, b2, b3, b4, b5; XOSPtr xosp; ProcessUpdatesFirst (FALSE); xosp = SetUp (); w = FixedWindow (-50, -33, -10, -10, "Consign", CloseConsignParentProc); g = HiddenGroup (w, 7, 0, NULL); b1 = PushButton (g, " Input GI ", ReadGIProc); b2 = PushButton (g, "Input FastA", ReadFileProc); b3 = PushButton (g, " Parameters", ConsignParamProc); b4 = PushButton (g, " Consign ", ConsignProc); b5 = PushButton (g, " Finish ", EndProg); SetObjectExtra (w, xosp, NULL); SetObjectExtra (b1, xosp, NULL); SetObjectExtra (b2, xosp, NULL); SetObjectExtra (b3, xosp, NULL); SetObjectExtra (b4, xosp, NULL); SetObjectExtra (b5, xosp, NULL); Show (w); ProcessEvents (); return 0; }
void AnimationEffectBurst::SetUp(float pOrbit, float pAnimTestShiftDist, float pAnimTestShiftDistSpeed, float pAnimTestShiftDistDecay, float pAnimTestShiftZ, float pAnimTestShiftZSpeed, float pAnimTestShiftZSpeedAdd) { SetUp(pOrbit, pAnimTestShiftDist, pAnimTestShiftDistSpeed); mPos.mZ = pAnimTestShiftZ; mVel.mZ = pAnimTestShiftZSpeed; }
void HcpGeneratorTests::ArrangePacking_ForHcp_NoParticleIntersections() { SetUp(); hcpGenerator->ArrangePacking(&particles); FLOAT_TYPE minDistanceSquare = FLT_MAX; FLOAT_TYPE currentDistanceSquare = 0; for (ParticleIndex i = 0; i < context->config->particlesCount - 1; i++) { for (ParticleIndex j = i + 1; j < context->config->particlesCount; j++) { currentDistanceSquare = mathService->GetNormalizedDistanceSquare(i, j, particles); if (currentDistanceSquare < minDistanceSquare) { minDistanceSquare = currentDistanceSquare; } } } FLOAT_TYPE minDistance = sqrt(minDistanceSquare); Assert::AreAlmostEqual(minDistance, 1.0, "ArrangePacking_ForHcp_NoParticleIntersections"); TearDown(); }
/************************************************************************* * This function is the driver for the partition refinement mode of ParMETIS **************************************************************************/ void Order_Partition(CtrlType *ctrl, GraphType *graph, WorkSpaceType *wspace) { SetUp(ctrl, graph, wspace); graph->ncon = 1; IFSET(ctrl->dbglvl, DBG_PROGRESS, rprintf(ctrl, "[%6d %8d %5d %5d][%d][%d]\n", graph->gnvtxs, GlobalSESum(ctrl, graph->nedges), GlobalSEMin(ctrl, graph->nvtxs), GlobalSEMax(ctrl, graph->nvtxs), ctrl->CoarsenTo, GlobalSEMax(ctrl, graph->vwgt[idxamax(graph->nvtxs, graph->vwgt)]))); if (graph->gnvtxs < 1.3*ctrl->CoarsenTo || (graph->finer != NULL && graph->gnvtxs > graph->finer->gnvtxs*COARSEN_FRACTION)) { /* Compute the initial npart-way multisection */ InitMultisection(ctrl, graph, wspace); if (graph->finer == NULL) { /* Do that only of no-coarsening took place */ ComputeNodePartitionParams(ctrl, graph, wspace); KWayNodeRefine(ctrl, graph, wspace, 2*NGR_PASSES, ORDER_UNBALANCE_FRACTION); } } else { /* Coarsen it and the partition it */ Mc_LocalMatch_HEM(ctrl, graph, wspace); Order_Partition(ctrl, graph->coarser, wspace); Moc_ProjectPartition(ctrl, graph, wspace); ComputeNodePartitionParams(ctrl, graph, wspace); KWayNodeRefine(ctrl, graph, wspace, 2*NGR_PASSES, ORDER_UNBALANCE_FRACTION); } }
BENCHMARK_DEFINE_F(dynamic_default_fixture, single_thread)(benchmark::State& state) { if (state.thread_index == 0) { SetUp(state); } sqeazy::remove_estimated_background_scheme<std::uint16_t> local; local.set_n_threads(1); local.encode(sinus_.data(), output_.data(), shape_); while (state.KeepRunning()) { state.PauseTiming(); std::fill(output_.begin(), output_.end(),0); state.ResumeTiming(); local.encode(sinus_.data(), output_.data(), shape_); } state.SetBytesProcessed(int64_t(state.iterations()) * int64_t(size_)*sizeof(sinus_.front())); }
void ClosestPairProviderTests::RegisterPair_ForFourParticlesAndMovedParticlesAreCloseThroughPeriodic_MovedParticlesAreNearest() { SetUp(); //Closest pair is 2-3 with distance 0.5 const FLOAT_TYPE diameter = 1.0; const SpatialVector c0 = {{5, 5, 5}}; const SpatialVector c1 = {{5.9, 5, 5}}; const SpatialVector c2 = {{5, 8, 5}}; const SpatialVector c3 = {{5.5, 8, 5}}; particles[0] = DomainParticle(0, diameter, c0); particles[1] = DomainParticle(1, diameter, c1); particles[2] = DomainParticle(2, diameter, c2); particles[3] = DomainParticle(3, diameter, c3); closestPairProvider->SetParticles(particles); closestPairProvider->StartMove(0); particles[0].coordinates[Axis::X] = 0.2; closestPairProvider->EndMove(); closestPairProvider->StartMove(1); particles[1].coordinates[Axis::X] = 9.99999; closestPairProvider->EndMove(); ParticlePair actualPair = closestPairProvider->FindClosestPair(); ParticlePair expectedPair(0, 1, 0.2 * 0.2); AssertPair(expectedPair, actualPair, "RegisterPair_ForFourParticlesAndMovedParticlesAreCloseThroughPeriodic_MovedParticlesAreNearest"); TearDown(); }
BENCHMARK_DEFINE_F(dynamic_default_fixture, max_threads)(benchmark::State& state) { if (state.thread_index == 0) { SetUp(state); } int nthreads = std::thread::hardware_concurrency(); sqeazy::frame_shuffle_scheme<std::uint16_t> local; local.set_n_threads(nthreads); local.encode(sinus_.data(), output_.data(), shape_); while (state.KeepRunning()) { state.PauseTiming(); std::fill(output_.begin(), output_.end(),0); state.ResumeTiming(); local.encode(sinus_.data(), output_.data(), shape_); } state.SetBytesProcessed(int64_t(state.iterations()) * int64_t(size_)*sizeof(sinus_.front())); }
void Button::MouseLeave(CMouse &rMouse) { Control::MouseLeave(rMouse); // mouse left fMouseOver = false; // reset down-state if mouse leves with button down if (rMouse.pDragElement == this) if (fEnabled) SetUp(false); }
CCamera::CCamera(void) { m_LiftAngle = 0.0f; SetUp(0, 1, 0); SetLookat(0, 0, 0); SetEye(1, 0, 1); UpdateMatrix(); }
bool Button::KeyButtonUp() { // space press activates button if (!fDown) return false; SetUp(true); if (fEnabled) OnPress(); return true; }
Server::Server(const int port) { logger.Log(INFO, std::string("Server starting on port # and default amount of connections accept")); amountOfConnectionsAccept = AMOUNT_OF_CONNECTIONS_ACCEPT_DEFAULT; connection = false; SetUp(port); Listen(); }
Server::Server() { logger.Log(INFO, std::string("Server starting on default port and default amount of connections accept")); amountOfConnectionsAccept = AMOUNT_OF_CONNECTIONS_ACCEPT_DEFAULT; connection = false; SetUp(7500); /* Needs a define in the library for the default server port */ Listen(); }
Server::Server(const int port, const int accept) { logger.Log(INFO, std::string("Server starting on port # and amount of connections accept #")); amountOfConnectionsAccept = accept; connection = false; SetUp(port); Listen(); }
void Main() { double accele_x_bias = 0.0, accele_y_bias = 0.0; double jyro_x_bias = 0.0, jyro_y_bias = 0.0; double accele_x = 0.0, accele_y = 0.0, accele_z = 0.0; double jyro_x = 0.0, jyro_y = 0.0; double theta_x = 0.0, theta_y = 0.0; double roll = 0.0, pitch = 0.0; int i = 0; SetUp(); for(i = 0; i < 100; i ++){ accele_x_bias += ADC_Read(ANAROG_PIN_ACCELE_X); accele_y_bias += ADC_Read(ANAROG_PIN_ACCELE_Y); jyro_x_bias += ADC_Read(ANAROG_PIN_JYRO_X); jyro_y_bias += ADC_Read(ANAROG_PIN_JYRO_Y); } accele_x_bias /= 100.0; accele_y_bias /= 100.0; jyro_x_bias /= 100.0; jyro_y_bias /= 100.0; while(1){ TMR0 = 0; accele_x = (ADC_read(ANAROG_PIN_ACCELE_X) - accele_x_bias) * ACCELE_COEFFICIENT; accele_y = (ADC_read(ANAROG_PIN_ACCELE_Y) - accele_y_bias) * ACCELE_COEFFICIENT; accele_z = (ADC_read(ANAROG_PIN_ACCELE_Z) - ACCELE_Z_BIAS) * ACCELE_COEFFICIENT; jyro_x = (ADC_read(ANAROG_PIN_JYRO_X) - jyro_x_bias) * JYRO_COEFFICIENT; jyro_y = (ADC_read(ANAROG_PIN_JYRO_Y) - jyro_y_bias) * JYRO_COEFFICIENT; theta_x = atan(accele_x / sqrt(accele_y * accele_y + accele_z * accele_z)) * (180.0 / PI); theta_y = atan(accele_y / sqrt(accele_x * accele_x + accele_z * accele_z)) * (180.0 / PI); roll += (jyro_x * DT) - (W * roll * DT) + (W * theta_x * DT); //相補フィルタ pitch += (jyro_y * DT) - (W * pitch * DT) + (W * theta_y * DT); if(-0.15 < roll && roll < 0.15) roll = 0.0; if(-0.15 < pitch && pitch < 0.15) pitch = 0.0; #if DEBUG_MODE #if ACCELE_CHECK_MODE accele_x = ADC_read(ANAROG_PIN_ACCELE_X); accele_y = ADC_read(ANAROG_PIN_ACCELE_Y); accele_z = ADC_read(ANAROG_PIN_ACCELE_Z); AcceleCheck(accele_x, accele_y, accele_z); #else Debug(roll, pitch); #endif #else OutPut(pitch - roll, pitch + roll); //right, left #endif } }