void TessellatedSolid::SetMesh(TriangleMesh &mesh) { G4TessellatedSolid *ts = this->m_Solid; for (int i=0; i<mesh.Triangles().size(); ++i) { const Vector3i &trg = mesh.Triangles().at(i); G4TriangularFacet *facet = new G4TriangularFacet( DetectorsSolidPimpl::getG4Vector3f(mesh.Points().at(trg(0))), DetectorsSolidPimpl::getG4Vector3f(mesh.Points().at(trg(1))), DetectorsSolidPimpl::getG4Vector3f(mesh.Points().at(trg(2))), ABSOLUTE); ts->AddFacet((G4VFacet *)facet); } this->m_Logical->SetSolid(ts); }
int vec2Di::erode(const vec2Di& src, unsigned int w, unsigned int h) { if (w < 2) w = 2; if (h < 2) h = 2; int strel_w = (int)w; int strel_h = (int)h; vec2Di& trg = *this; int val; if (trg.is_size_equal(src) == false) return -1; for (unsigned int y = 0; y < height(); y++) { for (unsigned int x = 0; x < width(); x++) { val = INT_MAX; for (int j = -strel_h / 2; j <= strel_h / 2; j++) { for (int i = -strel_w / 2; i <= strel_w / 2; i++) { if (y + j < 0 || y + j > height() - 1) continue; if (x + i < 0 || x + i > width() - 1) continue; if (val > src(y + j, x + i)) val = src(y + j, x + i); } } trg(y, x) = val; } } return 0; }
void ThumbButton::OnRender(suic::DrawingContext * drawing) { // 先绘制背景 __super::OnRender(drawing); suic::TriggerPtr trg(suic::UIRender::GetTriggerByStatus(this, GetStyle())); suic::ImageBrushPtr bkgnd = trg->GetValue(_T("Glyph")); if (bkgnd) { suic::Rect rect = bkgnd->GetContentBrounds(); suic::Rect rc; if (rect.Width() <= RenderSize().cx && rect.Height() <= RenderSize().cy) { rc.left = (RenderSize().cx - rect.Width()) / 2; rc.right = rc.left + rect.Width(); rc.top = (RenderSize().cy - rect.Height()) / 2; rc.bottom = rc.top + rect.Height(); bkgnd->Draw(drawing, &rc); } } }
void StjTrgRaiseThresholdEtHTTest::testTwoTowersNotPass() { StjTrgMock trgSrc; trgSrc._runNumber = 1; trgSrc._eventId = 1; trgSrc._passed = true; trgSrc._hard = true; trgSrc._soft = true; trgSrc._towers.push_back(1); trgSrc._towerDsmAdc.push_back(0); trgSrc._towerAdc.push_back(0); trgSrc._towerEnergy.push_back(0); trgSrc._towerEt.push_back(3.4); trgSrc._towers.push_back(10); trgSrc._towerDsmAdc.push_back(0); trgSrc._towerAdc.push_back(0); trgSrc._towerEnergy.push_back(0); trgSrc._towerEt.push_back(2.5); StjTrgRaiseThresholdEtHT trg(&trgSrc, 4.0); CPPUNIT_ASSERT( ! trg.passed() ); CPPUNIT_ASSERT( trg.hard() ); CPPUNIT_ASSERT( ! trg.soft() ); CPPUNIT_ASSERT_EQUAL( (size_t)0, trg.towers().size() ); }
TransliteratorEntry* TransliteratorRegistry::find(UnicodeString& source, UnicodeString& target, UnicodeString& variant) { TransliteratorSpec src(source); TransliteratorSpec trg(target); TransliteratorEntry* entry; if (variant.length() != 0) { // Seek exact match in hashtable entry = findInDynamicStore(src, trg, variant); if (entry != 0) { return entry; } // Seek exact match in locale resources entry = findInStaticStore(src, trg, variant); if (entry != 0) { return entry; } } for (;;) { src.reset(); for (;;) { // Seek match in hashtable entry = findInDynamicStore(src, trg, NO_VARIANT); if (entry != 0) { return entry; } // Seek match in locale resources entry = findInStaticStore(src, trg, NO_VARIANT); if (entry != 0) { return entry; } if (!src.hasFallback()) { break; } src.next(); } if (!trg.hasFallback()) { break; } trg.next(); } return 0; }
void Trigger::load(const Aurora::GFF3Struct &trigger) { Common::UString temp = trigger.getString("ResRef"); if (!temp.empty()) { try { Common::ScopedPtr<Aurora::GFF3File> trg(new Aurora::GFF3File(temp, Aurora::kFileTypeTRG, MKTAG('T', 'R', 'G', ' '))); loadBlueprint(trg->getTopLevel()); } catch (Common::Exception &e) { e.add("Trigger \"%s\" has no blueprint", temp.c_str()); throw; } } loadInstance(trigger); }
void vec2Dc::inter2(const vec2Dc& src, vec2D& dst_grdx, vec2D& dst_grdy) { vec2Dc& trg = *this; float xrto = float(width() - 1) / float(src.width() - 1); //trg/src float yrto = float(height() - 1) / float(src.height() - 1); //arrange before srcx,srcy,frcx,frcy to speed calcs for (unsigned int y = 0; y < height(); y++) { float srcy = (float)y / yrto; float frcy = srcy - float((int)srcy); dst_grdy(0, y) = srcy; dst_grdy(1, y) = frcy; } for (unsigned int x = 0; x < width(); x++) { float srcx = (float)x / xrto; //position to take from src vec2D float frcx = srcx - float((int)srcx); //srcx=1.34 frcx=.34 dst_grdx(0, x) = srcx; dst_grdx(1, x) = frcx; } //arrange before srcx,srcy,frcx,frcy to speed calcs for (unsigned int y = 0; y < height(); y++) { for (unsigned int x = 0; x < width(); x++) { unsigned int sx = (unsigned int)dst_grdx(0, x); //x index to source unsigned int sy = (unsigned int)dst_grdy(0, y); //y index to source float tmp = src(sy, sx) * (1.0f - dst_grdy(1, y)) * (1.0f - dst_grdx(1, x)); //1-frcy 1-frcx if (dst_grdx(1, x) > 0.0f && sx + 1 < src.width()) tmp += src(sy, sx + 1) * (1.0f - dst_grdy(1, y)) * dst_grdx(1, x); //1-frcy frcx if (dst_grdy(1, y) > 0.0f && sy + 1 < src.height()) tmp += src(sy + 1, sx) * dst_grdy(1, y) * (1.0f - dst_grdx(1, x)); //frcy 1-frcx if ((dst_grdx(1, x) > 0.0f && dst_grdy(1, y) > 0.0f) && (sx + 1 < src.width() && sy + 1 < src.height())) tmp += src(sy + 1, sx + 1) * dst_grdy(1, y) * dst_grdx(1, x); //frcy frcx trg(y, x) = (int)tmp; } } }
void Slider::OnRender(suic::DrawingContext * drawing) { // 先绘制背景 suic::Rect rcdraw(0, 0, RenderSize().cx, RenderSize().cy); suic::TriggerPtr trg(GetStyle()->GetTrigger()); suic::ImageBrushPtr bkgnd(trg->GetValue(suic::BACKGROUND)); if (!bkgnd) { if (GetOrientation() == CoreFlags::Horizontal) { rcdraw.top = (RenderSize().cy - GetDesiredSize().cy) / 2; rcdraw.bottom = rcdraw.top + GetDesiredSize().cy; } else { rcdraw.left = (RenderSize().cx - GetDesiredSize().cx) / 2; rcdraw.right = rcdraw.left + GetDesiredSize().cx; } suic::UIRender::DrawBackground(drawing, trg, &rcdraw); } else { suic::Rect rect = bkgnd->GetContentBrounds(); if (GetOrientation() == CoreFlags::Horizontal) { rcdraw.top = (RenderSize().cy - rect.Height()) / 2; rcdraw.bottom = rcdraw.top + rect.Height(); } else { rcdraw.left = (RenderSize().cx - rect.Width()) / 2; rcdraw.right = rcdraw.left + rect.Width(); } bkgnd->Draw(drawing, &rcdraw); } }
void ProgressBar::OnRender(suic::DrawingContext * drawing) { // 先绘制背景 suic::Rect elemrect(0, 0, RenderSize().cx, RenderSize().cy); suic::TriggerPtr trg(suic::UIRender::GetTriggerByStatus(this, GetStyle())); suic::UIRender::DrawBackground(drawing, trg, &elemrect); // // 绘制进度条状态 // suic::ImageBrushPtr bkgnd(trg->GetValue(_T("Thumb"))); if (bkgnd) { suic::Rect rcdraw(elemrect); // 水平 if (GetOrientation() == CoreFlags::Horizontal) { LONG iOff = (LONG)((GetValue() - Minimum()) * (double)(rcdraw.right - rcdraw.left) / (Maximum() - Minimum())); rcdraw.right = rcdraw.left + iOff; } else { LONG iOff = (LONG)((double)(rcdraw.bottom - rcdraw.top) * (GetValue() - Minimum()) / (Maximum() - Minimum())); rcdraw.top = rcdraw.bottom - iOff; } if (!rcdraw.Empty()) { bkgnd->Draw(drawing, &rcdraw); } } suic::UIRender::DrawText(drawing, GetText(), trg, &elemrect , GetHorizontalContentAlignment(), GetVerticalContentAlignment()); }
/** * Top-level find method. Attempt to find a source-target/variant in * either the dynamic or the static (locale resource) store. Perform * fallback. * * Lookup sequence for ss_SS_SSS-tt_TT_TTT/v: * * ss_SS_SSS-tt_TT_TTT/v -- in hashtable * ss_SS_SSS-tt_TT_TTT/v -- in ss_SS_SSS (no fallback) * * repeat with t = tt_TT_TTT, tt_TT, tt, and tscript * * ss_SS_SSS-t/ * * ss_SS-t/ * * ss-t/ * * sscript-t/ * * * Here * matches the first variant listed. * * Caller does NOT own returned object. Return 0 on failure. */ TransliteratorEntry* TransliteratorRegistry::find(UnicodeString& source, UnicodeString& target, UnicodeString& variant) { TransliteratorSpec src(source); TransliteratorSpec trg(target); TransliteratorEntry* entry; // Seek exact match in hashtable. Temporary fix for ICU 4.6. // TODO: The general logic for finding a matching transliterator needs to be reviewed. // ICU ticket #8089 UnicodeString ID; TransliteratorIDParser::STVtoID(source, target, variant, ID); entry = (TransliteratorEntry*) registry.get(ID); if (entry != 0) { // std::string ss; // std::cout << ID.toUTF8String(ss) << std::endl; return entry; } if (variant.length() != 0) { // Seek exact match in hashtable entry = findInDynamicStore(src, trg, variant); if (entry != 0) { return entry; } // Seek exact match in locale resources entry = findInStaticStore(src, trg, variant); if (entry != 0) { return entry; } } for (;;) { src.reset(); for (;;) { // Seek match in hashtable entry = findInDynamicStore(src, trg, NO_VARIANT); if (entry != 0) { return entry; } // Seek match in locale resources entry = findInStaticStore(src, trg, NO_VARIANT); if (entry != 0) { return entry; } if (!src.hasFallback()) { break; } src.next(); } if (!trg.hasFallback()) { break; } trg.next(); } return 0; }