// Secondary algorithm to determine transfer pairs and close pairs inline void defineTransferAndClose( Box* b1, Box* b2, int L ) { // If leaf level, these boxes are a close pair if( L == tree.numLevels() ) { getLevel(L).addClose( b1, b2 ); return; } // For all the children of b1 for( int k1 = 0; k1 < tree.BRANCH; ++k1 ) { // Get the k1th child of b1 Box* child1 = getBox( tree.child(b1->n, k1), L+1 ); if( child1 == NULL ) continue; // For all the children of b2 for( int k2 = 0; k2 < tree.BRANCH; ++k2 ) { // Get the k2th child of b2 Box* child2 = getBox( tree.child(b2->n, k2), L+1 ); if( child2 == NULL ) continue; // Determine the transfer vector between the two children Vec3 r0 = child1->center - child2->center; if( r0.mag() > 1.8 * tree.getBoxSize(L+1) ) { // These two are not neighbors so they are a transfer pair getLevel(L+1).addTransfer( child1, child2 ); } else { // These two are neighbors so recurse defineTransferAndClose( child1, child2, L+1 ); } } } }
// Constructor MLFMM_Env( FUNC K_, vector<Vec3>& p, int levels_ = 4, double eps = 1e-4 ) : K(K_), sourcefield( p ), // Copy the charge positions tree( p, levels_ ), // Create the tree levels( levels_+1 ) // Initialize vector of levels { cerr << tree << endl; int nLevels = tree.numLevels(); // Construct each Level and give it the boxes it owns for( int L = 2; L <= nLevels; ++L ) { levels[L] = Level<DIM>( tree.getBoxSize(L) ); for( int n = 0; n < (1 << (DIM*L)); ++n ) { Box* b = getBox(n,L); if( b != NULL ) getLevel(L).addBox(b); } } // Recursively build transfer and close lists from rootbox defineTransferAndClose(getBox(0,0), 0); cerr << "Transfer and Close Lists Built" << endl; // Compute the quadrature for each level of the tree for( int L = 2; L <= nLevels; ++L ) { getLevel(L).defineQuadrature( K, eps ); } cout << "Quadrature Defined" << endl; // Compute the transfer functions for each level of the tree for( int L = 2; L <= nLevels; ++L ) { getLevel(L).defineTransfers(); } cout << "Transfer Functions Defined" << endl; // Compute the translation operators for each level of the tree for( int L = 2; L < nLevels; ++L ) { getLevel(L).defineTranslations(); } cout << "Translation Functions Defined" << endl; // Define the interpolators and anterpolators required for each level for( int L = 2; L <= nLevels; ++L ) { if( L != 2 ) getLevel(L).defineInterp( getLevel(L-1).getQuad() ); if( L != nLevels ) getLevel(L).defineAnterp( getLevel(L+1).getQuad() ); } cout << "Reterpolators Defined" << endl; cout << "Initialization Done" << endl; }
AFRT & ABST::getFragmentRunTable(uint32_t no) { static Box result; if (no >= getFragmentRunTableCount()) { static Box res; return (AFRT &)res; } uint32_t tempLoc = 29 + getStringLen(29) + 1 + 1; for (unsigned int i = 0; i < getServerEntryCount(); i++) { tempLoc += getStringLen(tempLoc) + 1; } tempLoc++; for (unsigned int i = 0; i < getQualityEntryCount(); i++) { tempLoc += getStringLen(tempLoc) + 1; } tempLoc += getStringLen(tempLoc) + 1; //DrmData tempLoc += getStringLen(tempLoc) + 1; //MetaData for (unsigned int i = getInt8(tempLoc++); i != 0; --i) { tempLoc += getBoxLen(tempLoc); } tempLoc++; for (unsigned int i = 0; i < no; i++) { tempLoc += getBoxLen(tempLoc); } return (AFRT &)getBox(tempLoc); }
bool Picture::contains (PointObj& po, Graphic* gs) { if (!IsEmpty()) { Iterator i; FullGraphic gstemp; Transformer ttemp; BoxObj b; getBox(b, gs); if (b.Contains(po)) { gstemp.SetTransformer(&ttemp); for (First(i); !Done(i); Next(i)) { Graphic* gr = GetGraphic(i); concatGraphic(gr, gr, gs, &gstemp); if (containsGraphic(gr, po, &gstemp)) { gstemp.SetTransformer(nil); return true; } } gstemp.SetTransformer(nil); /* to avoid deleting ttemp explicitly*/ } } return false; }
std::streamoff ossimJp2Info::getGeotiffBox( std::ifstream& str, std::vector<ossim_uint8>& box ) const { std::streamoff boxPos = 0; if ( str.good() ) { const ossim_uint32 UUID_TYPE = 0x75756964; boxPos = getBox( UUID_TYPE, false, str, box ); if ( boxPos && ( box.size() >= GEOTIFF_UUID_SIZE) ) { const ossim_uint8 GEOTIFF_UUID[GEOTIFF_UUID_SIZE] = { 0xb1, 0x4b, 0xf8, 0xbd, 0x08, 0x3d, 0x4b, 0x43, 0xa5, 0xae, 0x8c, 0xd7, 0xd5, 0xa6, 0xce, 0x03 }; if( memcmp( (char*)&box.front(), GEOTIFF_UUID, GEOTIFF_UUID_SIZE) != 0) { boxPos = 0; box.clear(); } } } return boxPos; }
bool Picture::intersects (BoxObj& userb, Graphic* gs) { if (!IsEmpty()) { Iterator i; FullGraphic gstemp; Transformer ttemp; BoxObj b; getBox(b, gs); if (b.Intersects(userb)) { gstemp.SetTransformer(&ttemp); for (First(i); !Done(i); Next(i)) { Graphic* gr = GetGraphic(i); concatGraphic(gr, gr, gs, &gstemp); if (intersectsGraphic(gr, userb, &gstemp)) { gstemp.SetTransformer(nil); return true; } } gstemp.SetTransformer(nil); /* to avoid deleting ttemp explicitly*/ } } return false; }
Hit BVH::BVHNode::trace(const AABB_Ray & aabb_ray, const Ray & ray, Amount minT) { Hit retHit(ray); //First check to see if this hit intersects with this node. Amount thisT = getBox().intersect(aabb_ray); if(thisT > 0 && (thisT < minT || minT < 0)) { if(this->left != nullptr) { Hit hLeft = this->left->trace(aabb_ray,ray,minT); if(hLeft.didHit() && (hLeft.getT() < minT || minT < 0)) { retHit = hLeft; minT = hLeft.getT(); } } if(this->right != nullptr) { Hit hRight = this->right->trace(aabb_ray,ray,minT); if(hRight.didHit() && (hRight.getT() < minT || minT < 0)) { retHit = hRight; } } } return retHit; }
void SpecialZone::onTick(const int slot_id) { PlayerSlot &slot = PlayerManager->get_slot(slot_id); Object *o = slot.getObject(); if (o == NULL) return; v2<float> pos, vel; o->get_position(pos); o->get_velocity(vel); v2<int> left_pos, right_pos; o->get_position(left_pos); o->get_position(right_pos); right_pos += o->size.convert<int>(); v2<int> c_pos(position.x, position.y); c_pos += size / 2; int o_z = getBox(o->get_z()); //LOG_DEBUG(("zone zbox: %d, object zbox: %d", position.z, o_z)); if (name == "right") { if (right_pos.x >= c_pos.x && o_z != (position.z + 1) && vel.x > 0) o->set_zbox((position.z + 1) * 2000); if (right_pos.x < c_pos.x && o_z != position.z && vel.x < 0) o->set_zbox(position.z * 2000); } else if (name == "left") { if (left_pos.x < c_pos.x && o_z != (position.z + 1) && vel.x < 0) o->set_zbox((position.z + 1) * 2000); if (left_pos.x >= c_pos.x && o_z != position.z && vel.x > 0) o->set_zbox(position.z * 2000); } //LOG_DEBUG(("delta left: %d, %d, delta right: %d, %d", left_pos.x - c_pos.x, left_pos.y - c_pos.y, right_pos.x - c_pos.x, right_pos.y - c_pos.y)); }
uint32_t containerBox::getContentCount() { int res = 0; unsigned int tempLoc = 0; while (tempLoc < boxedSize() - 8) { res++; tempLoc += Box(getBox(tempLoc).asBox(), false).boxedSize(); } return res; }
void HTMLElementImp::setScrollTop(int y) { Block* block = dynamic_cast<Block*>(getBox()); if (!block) return; float overflow = block->getScrollHeight() - block->height; scrollTop = std::max(0, std::min(y, static_cast<int>(overflow))); block->setFlags(Box::NEED_REPAINT); }
void HTMLElementImp::setScrollLeft(int x) { Block* block = dynamic_cast<Block*>(getBox()); if (!block) return; float overflow = block->getScrollWidth() - block->width; scrollLeft = std::max(0, std::min(x, static_cast<int>(overflow))); block->setFlags(Box::NEED_REPAINT); }
const QString& LeitnerSystem::getNextBox( QString& previousBox ) { for( int i = 0; i < m_boxes.count(); i++ ) { if( m_boxes[i].getVocabCount() > 0 ) return getBox( i ); } return QString::null; }
void BSplineSelection::drawClipped (Canvas* c, Coord l, Coord b, Coord r, Coord t, Graphic* gs) { BoxObj box; getBox(box, gs); BoxObj clipBox(l, b, r, t); if (clipBox.Intersects(box)) { draw(c, gs); } }
bool console::miniParser::getGUInput(wxString expression) { exp = expression; patternNormalize(exp); switch (_wait4type) { case telldata::tn_pnt : return getPoint(); case telldata::tn_box : return getBox(); case TLISTOF(telldata::tn_pnt): return getList(); default: return false;// unexpected type } }
PointCoordinateType ccClipBox::computeArrowsScale() { PointCoordinateType scale = m_box.getDiagNorm() / 10; if (m_entityContainer.getChildrenNumber() != 0) { scale = std::max<PointCoordinateType>(scale, getBox().getDiagNorm() / 25); } return scale; }
void Graphic::eraseClipped ( Canvas* c, Coord left, Coord bottom, Coord right, Coord top, Graphic* gs ) { BoxObj thisBox; BoxObj clipBox(left, bottom, right, top); getBox(thisBox, gs); if (clipBox.Intersects(thisBox)) { erase(c, gs); } }
boolean MultiLine::s_contains (PointObj& po, Graphic* gs) { MultiLineObj &ml = *_pts; PointObj pt (&po); BoxObj b; getBox(b, gs); if (b.Contains(po)) { invTransform(pt._x, pt._y, gs); return ml.Contains(pt); } return false; }
void Trap::draw() { Object::draw(); GraphicsManager &graphics_manager = GraphicsManager::getInstance(); Box box = getBox(); std::stringstream curPos; curPos << "Hero Position: " << getPosition().getX() << " , " << getPosition().getY() << " "; curPos << "Height: " << box.getVertical() << " , " << "Width: " << box.getHorizontal(); /* graphics_manager.drawString(Position(0, 24), curPos.str(), LEFT_JUSTIFIED);*/ // GraphicsManager &graphics_manager = GraphicsManager::getInstance(); // graphics_manager.drawCh(getPosition(), HERO_CHAR, COLOR_BLUE); }
// cf. http://www.w3.org/TR/cssom-view/#scroll-an-element-into-view void HTMLElementImp::scrollIntoView(bool top) { if (html::Window window = getOwnerDocument().getDefaultView()) { if (Box* box = getBox()) { int x = box->getX() + box->getMarginLeft(); int y = box->getY() + box->getMarginTop(); if (!top) y += box->getBorderHeight(); window.scroll(x, y); } } }
boolean MultiLine::f_contains (PointObj& po, Graphic* gs) { BoxObj b; PointObj pt (&po); getBox(b, gs); if (b.Contains(pt)) { FillPolygonObj fp (x(), y(), count()); invTransform(pt._x, pt._y, gs); return fp.Contains(pt); } return false; }
//-------------------------------------------------------------- string ofxMuiBox::boxToString() { // THE GUI BOX! // __________________________________________________________ // |BOX - RENDERED AS A FILLED QUAD | // | CORNER CAN BE ANYWHERE INSIDE OF PARENT | // | (SCREEN OR PANEL OR OBJECT | // | ____________________________________________________ | // | M |BORDER BOX - RENDERED AS A FRAME | | // | A | CORNER ALWAYS @ 0,0 | | // | A | | | // | R | B | | // | G | O __________________________________________ | | // | I | R |PADDING BOX - RENDERED AS A FILLED QUAD | | | // | N | D | CORNER ALWAYS @ 0,0 | | | // | N | D | | | | // | | E | P ___________________________________ | | | // | | R | A |CONTENT BOX - RENDERD BY OBJECT | | | | // | | | D | | | | | // | | | D | CORNER ALWAYS @ 0,0 | | | | // | | | I | | | | | // | | | N | ___________________________ | | | | // | | | G | | | | | | | // | | | | | CORNER CAN BE ANYWHERE | | | | | // | | | | | INSIDE THE CONTENT BOX | | | | | // | | | | | | | | | | // | | | | | HIT BOX - | | | | | // | | | | | RENDERED BY OBJECT | | | | | // | | | | | This is the "hot" zone" | | | | | stringstream ss; ss << "[BOX : " << ofToString(getBox().getX(),0,3,' ') << "/" << ofToString(getBox().getY(),0,3,' ') << "," << ofToString(getBox().getWidth(),0,3,' ') << "/" << ofToString(getBox().getHeight(),0,3,' ') << "]" << endl; ss << "[BORDER : " << ofToString(getBorderBox().getX(),0,3,' ') << "/" << ofToString(getBorderBox().getY(),0,3,' ') << "," << ofToString(getBorderBox().getWidth(),0,3,' ') << "/" << ofToString(getBorderBox().getHeight(),0,3,' ') << "]" << endl; ss << "[PADDING: " << ofToString(getPaddingBox().getX(),0,3,' ') << "/" << ofToString(getPaddingBox().getY(),0,3,' ') << "," << ofToString(getPaddingBox().getWidth(),0,3,' ') << "/" << ofToString(getPaddingBox().getHeight(),0,3,' ') << "]" << endl; ss << "[HIT BOX: " << ofToString(getHitBox().getX(),0,3,' ') << "/" << ofToString(getHitBox().getY(),0,3,' ') << "," << ofToString(getHitBox().getWidth(),0,3,' ') << "/" << ofToString(getHitBox().getHeight(),0,3,' ') << "]" << endl; return ss.str(); }
bool OpenBSpline::f_contains (PointObj& po, Graphic* gs) { PointObj pt (&po); BoxObj b; getBox(b, gs); if (b.Contains(pt)) { invTransform(pt._x, pt._y, gs); FillPolygonObj fp; fp.ClosedSplineToPolygon(_x, _y, _count); return fp.Contains(pt); } return false; }
Box & containerFullBox::getContent(uint32_t no) { static Box ret = Box((char *)"\000\000\000\010erro", false); if (no > getContentCount()) { return ret; } unsigned int i = 0; int tempLoc = 4; while (i < no) { tempLoc += getBoxLen(tempLoc); i++; } return getBox(tempLoc); }
bool OpenBSpline::s_contains (PointObj& po, Graphic* gs) { PointObj pt (&po); BoxObj b; getBox(b, gs); if (b.Contains(pt)) { invTransform(pt._x, pt._y, gs); MultiLineObj ml; ml.SplineToMultiLine(_x, _y, _count); return ml.Contains(pt); } return false; }
// Main algorithm to determine transfer pairs and close pairs // Two boxes are transfers if their parents are neighbors and they aren't // Two boxes are close if they are leaf level and are neighbors inline void defineTransferAndClose( Box* b, int L ) { // For all the children of b for( int k1 = 0; k1 < tree.BRANCH; ++k1 ) { // Get the k1th child of b Box* child1 = getBox( tree.child(b->n, k1), L+1 ); if( child1 == NULL ) continue; // For all the other children of b for( int k2 = k1+1; k2 < tree.BRANCH; ++k2 ) { // Get the k2th child of b Box* child2 = getBox( tree.child(b->n, k2), L+1 ); if( child2 == NULL ) continue; // Call the neighbor routine on each pair of children defineTransferAndClose( child1, child2, L+1 ); } // If the child is not at the leaf level, recurse on the child if( L+1 != tree.numLevels() ) defineTransferAndClose( child1, L+1 ); } }
void drawFilledPolygon(point* verticies, int numberOfVerticies, unsigned char shade) { int x, y; box myBox; if(getSetting() == 0) { return; } myBox = getBox(verticies, numberOfVerticies); for(y = myBox.topL.y; y <= myBox.botR.y; y++){ for(x = myBox.topL.x; x <= myBox.botR.x; x++){ if(pointInPolygon(verticies, numberOfVerticies, makePoint(x, y))) { drawPoint(makePoint(x, y), shade); } } } drawPolygon(verticies, numberOfVerticies, 0xF); }
void HTMLElementImp::handleMouseMove(events::Event event) { events::MouseEvent mouse = interface_cast<events::MouseEvent>(event); unsigned short buttons = mouse.getButtons(); if (buttons & 1) { Block* block = dynamic_cast<Block*>(getBox()); if (block && block->canScroll()) { setScrollTop(getScrollTop() + moveY - mouse.getScreenY()); setScrollLeft(getScrollLeft() + moveX - mouse.getScreenX()); event.preventDefault(); } } moveX = mouse.getScreenX(); moveY = mouse.getScreenY(); }
int parsercmd::cmdSTRUCT::execute() { telldata::tell_var *ustrct; if (TLISALIST( (*_arg)() )) ustrct = getList(); else { const telldata::tell_type *stype = CMDBlock->getTypeByID( (*_arg)() ); assert(NULL != stype); switch( (*_arg)() ) { case telldata::tn_pnt: ustrct = getPnt(); break; case telldata::tn_box: ustrct = getBox(); break; default:ustrct = new telldata::user_struct(stype, OPstack); } } OPstack.push(ustrct); return EXEC_NEXT; }
boolean BSplineSelection::intersects (BoxObj& userb, Graphic* gs) { BoxObj b; getBox(b, gs); if (b.Intersects(userb)) { if (intersectsGraphic(ifillbspline, userb, gs)) { return true; } else if (intersectsGraphic(bspline, userb, gs)) { return true; } else if (LeftAints(lx0, ly0, lx1, ly1, userb, gs)) { return true; } else if (RightAints(rx0, ry0, rx1, ry1, userb, gs)) { return true; } } return false; }
boolean BSplineSelection::contains (PointObj& po, Graphic* gs) { BoxObj b; getBox(b, gs); if (b.Contains(po)) { if (containsGraphic(ifillbspline, po, gs)) { return true; } else if (containsGraphic(bspline, po, gs)) { return true; } else if (LeftAcont(lx0, ly0, lx1, ly1, po, gs)) { return true; } else if (RightAcont(rx0, ry0, rx1, ry1, po, gs)) { return true; } } return false; }