Esempio n. 1
0
int main(int argc, const char * argv[]) {


    Box boxOne = initBox(10, 20, 30);
    Box boxTwo = initBox(10, 20, 60);
    
    printf("Ratio of volume for Box 1 to Box 2 is %f", compareBoxVolumes(boxOne, boxTwo));
    
    return 0;
}
Esempio n. 2
0
Box *newBox(int x, int y, int s) {
    Box *box = (Box *)malloc(sizeof(Box));

    initBox(box, x, y, s);

    return box;
}
Esempio n. 3
0
int main(int argc, char** argv) {
    Box<double> box(2);
    initBox(box);
    Supp supp(1);
    Obj obj;
    UnconsRecStore<double> rs(3, 2);
    EigenCutFactory<double> fact(&rs, &supp, &obj, 0.68);
    std::vector< Cut<double> > cuts;
    fact.getCuts(box, cuts);

    supp.setLB(-1);
    ObjOne objone;
    EigenCutFactory<double> factone(&rs, &supp, &objone, 0.28);
    factone.getCuts(box, cuts);

    supp.setLB(0);
    ObjTwo objtwo;
    EigenCutFactory<double> facttwo(&rs, &supp, &objtwo, 0.5);
    facttwo.getCuts(box, cuts);
    for (auto o : cuts) {
        std::cout << CutUtils<double> ::toString(o) << "\n";
    }

    BNB_ASSERT((cuts[0].mType == Cut<double>::CutType::OUTER_BALL) && (BNBABS(cuts[0].mR - 0.8) < 0.001) && (cuts[0].mC[0] == 0) && (cuts[0].mC[1] == 0));
    BNB_ASSERT((cuts[1].mType == Cut<double>::CutType::INNER_BALL) && (BNBABS(cuts[1].mR - 1.6) < 0.001) && (cuts[1].mC[0] == 2) && (cuts[1].mC[1] == 0));
    BNB_ASSERT((cuts[2].mType == Cut<double>::CutType::LINEAR) &&(cuts[2].mR == 2) && (cuts[2].mC[0] == 1) && (cuts[2].mC[1] == 1));
    return 0;
}
Esempio n. 4
0
void KGroupBoxBase::setTitleWidget(QWidget *title) {
  if(_title)
    delete _title;
  
  _title = title;
  initBox();  
}
Esempio n. 5
0
Physics3DShape* Physics3DShape::createBox(const cocos2d::Vec3& extent)
{
    auto shape = new (std::nothrow) Physics3DShape();
    shape->initBox(extent);
    shape->autorelease();
    return shape;
}
Esempio n. 6
0
UsernameBox::UsernameBox() :
_saveButton(this, lang(lng_settings_save), st::usernameDone),
_cancelButton(this, lang(lng_cancel), st::usernameCancel),
_usernameInput(this, st::inpAddContact, qsl("@username"), App::self()->username),
_saveRequest(0), _checkRequest(0), _about(st::usernameWidth - 2 * st::boxTitlePos.x())  {
	_about.setRichText(st::usernameFont, lang(lng_username_about));
	_goodText = App::self()->username.isEmpty() ? QString() : lang(lng_username_available);
	initBox();
}
Esempio n. 7
0
void initOpengl()
{
	glEnable(GL_DEPTH_TEST);
	glEnable(GL_MULTISAMPLE);
	glPolygonMode(GL_BACK, GL_LINE);
	initCamera();
	initShaders();
	initBox();
}
Esempio n. 8
0
AddContactBox::AddContactBox(PeerData *peer) :
	_peer(peer),
	_addButton(this, lang(lng_settings_save), st::btnSelectDone),
	_retryButton(this, lang(lng_try_other_contact), st::btnSelectDone),
	_cancelButton(this, lang(lng_cancel), st::btnSelectCancel),
    _firstInput(this, st::inpAddContact, lang(peer->chat ? lng_dlg_new_group_name : lng_signup_firstname), peer->chat ? peer->name : peer->asUser()->firstName),
    _lastInput(this, st::inpAddContact, lang(lng_signup_lastname), peer->chat ? QString() : peer->asUser()->lastName),
    _phoneInput(this, st::inpAddContact, lang(lng_contact_phone)),
	_contactId(0), _addRequest(0) {

	initBox();
}
Esempio n. 9
0
    NlpProblem<double>* createProb() {
        NlpProblem<double>* prob = new NlpProblem<double>();

        /** Initializing bounding box **/
        Box<double> box(mN);
        initBox(box);
        prob->mBox = box;

        /** Setup objective */
        prob->mObj = mPobj;
        return prob;
    }
Esempio n. 10
0
AddContactBox::AddContactBox(QString fname, QString lname, QString phone) :
	_peer(0),
	_addButton(this, lang(lng_add_contact), st::btnSelectDone),
	_retryButton(this, lang(lng_try_other_contact), st::btnSelectDone),
	_cancelButton(this, lang(lng_cancel), st::btnSelectCancel),
    _firstInput(this, st::inpAddContact, lang(lng_signup_firstname), fname),
    _lastInput(this, st::inpAddContact, lang(lng_signup_lastname), lname),
    _phoneInput(this, st::inpAddContact, lang(lng_contact_phone), phone.isEmpty() ? phone : App::formatPhone(phone)),
	_contactId(0), _addRequest(0) {

	if (!phone.isEmpty()) {
		_phoneInput.setDisabled(true);
	}

	initBox();
}
Esempio n. 11
0
File: main.cpp Progetto: h-godai/ssa
/**
 * デバイスに対してのEGLコンテキストの初期化
 */
static int engine_init_display(struct engine* engine) {
    // OepGL ES と EGLの初期化

    const EGLint attribs[] =
            { EGL_SURFACE_TYPE, EGL_WINDOW_BIT, EGL_BLUE_SIZE, 8,
                    EGL_GREEN_SIZE, 8, EGL_RED_SIZE, 8, EGL_NONE };
    EGLint w, h, dummy, format;
    EGLint numConfigs;
    EGLConfig config;
    EGLSurface surface;
    EGLContext context;

    EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY);

    eglInitialize(display, 0, 0);

    eglChooseConfig(display, attribs, &config, 1, &numConfigs);

    eglGetConfigAttrib(display, config, EGL_NATIVE_VISUAL_ID, &format);

    ANativeWindow_setBuffersGeometry(engine->app->window, 0, 0, format);

    surface = eglCreateWindowSurface(display, config, engine->app->window,
            NULL);
    context = eglCreateContext(display, config, NULL, NULL);

    if (eglMakeCurrent(display, surface, surface, context) == EGL_FALSE) {
        LOGW("Unable to eglMakeCurrent");
        return -1;
    }

    eglQuerySurface(display, surface, EGL_WIDTH, &w);
    eglQuerySurface(display, surface, EGL_HEIGHT, &h);

    engine->display = display;
    engine->context = context;
    engine->surface = surface;
    engine->width = w;
    engine->height = h;
    engine->state.angle = 0;

    // ボックス表示の初期化
    initBox(engine);

    return 0;
}
Esempio n. 12
0
void resetGame(Game& game) {
    initBox(game.daBox, game.boxSprite);
    initItem(game.bonusItem);

    game.daEnemies.clear();
    game.daMissiles.clear();
    game.daBlasts.clear();
    game.lives.clear();

    for (int i = 0; i < STARTING_LIVES; i++) {
        BlastLogic life;
        initBlast(life, game.heartSprite, 7.0+(i*17.0), 5.0);
        life.outRect.w = life.outRect.h = 16;
        game.lives.push_back(life);
    }

    game.score = 0;
    game.multiplier = 1.0f;
    game.lastSpawnDate = SDL_GetTicks();
    game.lastTime = SDL_GetTicks();
    game.lag = 0;
}
Esempio n. 13
0
void KGroupBoxBase::resizeEvent(QResizeEvent *) {
  initBox();
}
Esempio n. 14
0
void BSPOctree::BSPOperation(BaseMesh *mesh1, BaseMesh *mesh2, BaseMesh** output)
{
    Box3 bbox = mesh1->AABB();
    bbox.IncludeBox(mesh2->AABB());

    NormalMesh *myMesh1 = new NormalMesh(mesh1), *myMesh2;

    if (FixedBSPTree::OP_DIFFERENCE == mOperation)
        myMesh2 = new NormalMesh(mesh2, NormalMesh::PARA_NEGATE);
    else myMesh2 = new NormalMesh(mesh2);

    myMesh1->NormalizeCoord(&bbox);
    myMesh1->FilterVertex(11);
    myMesh2->NormalizeCoord(&bbox);
    myMesh2->FilterVertex(11);
    
    normalizeBox3(mesh1->AABB(), bbox, mAABB1);
    normalizeBox3(mesh2->AABB(), bbox, mAABB2);
    staticFilterP(mAABB1, 11);
    staticFilterP(mAABB2, 11);

    auto t0 = clock();
    // initialize the para of the first cell
    PolygonPtrList pool1, pool2;
    GSOutputTimeLog(L"init: ");

    auto &ver1 = myMesh1->Vertex();
    auto &tri1 = myMesh1->Triangle();
    int i = 0;
    for (auto &titr: tri1)
    {
        mMesh1.emplace_back(ver1[titr[0]], ver1[titr[1]], ver1[titr[2]]);
        mMesh1.back().index = i;
        mMesh1.back().mpMesh = mesh1;
        mMesh1.back().mTriId = i;
        pool1.push_back(i++);
    }
    delete myMesh1;

    auto &ver2 = myMesh2->Vertex();
    auto &tri2 = myMesh2->Triangle();
    i = 0;
    for (auto &titr: tri2)
    {
        mMesh2.emplace_back(ver2[titr[0]], ver2[titr[1]], ver2[titr[2]]);
        mMesh2.back().mpMesh = mesh2;
        mMesh2.back().mTriId = i;
        pool2.push_back(i++);
    }
    delete myMesh2;

    for (auto &meshe: mMesh1) meshe.pMeshData = &meshe;
    for (auto &meshe: mMesh2) meshe.pMeshData = &meshe;

    Box3 initBox(Box3::BOX_MIRROR_SCALE);

    mesh1->NormalizeCoord(&bbox);
    mesh2->NormalizeCoord(&bbox);

    GSOutputTimeLog(L"start Iteration: ");
    PerformIteration(pool1, pool2, initBox, &mpRoot);

    if (*output) delete *output;
    auto &outputPtr = *output;

    GSOutputTimeLog(L"end Iteration: ");
    outputPtr = CollectPolygons(mesh1, mesh2);

    GSOutputTimeLog(L"end collection: ");
    mesh1->DenormalizeCoord();
    mesh2->DenormalizeCoord();
    outputPtr->DenormalizeCoord(&bbox);
    outputPtr->GenAABB(false);

    auto t1 = clock();
    long t = t1-t0;
    wchar_t ch[32];
    wsprintf(ch, L"time: %d\n", t);
    WriteConsole(GetStdHandle(STD_OUTPUT_HANDLE), ch, wcslen(ch), 0, 0);
}