int clipLine(int x1, int y1, int x2, int y2, int * x3, int * y3, int * x4, int * y4) { int code1, code2, codeout; int accept=0, done=0; code1 = findRegion(x1,y1); code2 = findRegion(x2,y2); do { if(!(code1 | code2)) accept = done = 1; //trivial accept else if(code1 & code2) done = 1; //trivial reject else { int x,y; codeout = code1 ? code1 : code2; if(codeout & 1) { //top x = x1 + (x2-x1) * (ATAS-y1)/(y2-y1); y = ATAS; } else if(codeout & 2) { //bottom x = x1 + (x2-x1) * (BAWAH-y1)/(y2-y1); y = BAWAH; } else if(codeout & 4) { //right y = y1 + (y2-y1) * (KANAN-x1)/(x2-x1); x = KANAN; } else { //left y = y1 + (y2-y1) * (KIRI-x1)/(x2-x1); x = KIRI; } if(codeout == code1){ x1 = x; y1 = y; code1 = findRegion(x1,y1); } else { x2 = x; y2 = y; code2 = findRegion(x2,y2); } } } while(done == 0); if(accept) { (*x3) = x1; (*x4) = x2; (*y3) = y1; (*y4) = y2; } else { //should never get into this (*x3) = (*x4) = (*y3) = (*y4) = 0; } return accept; }
void LookAlikeMainPrivate::confirmFace(QUrl picture, QString& contact) { //Confirm in Face Recognizer database QString urnImage = urnFromUrl(picture); XQFaceRegion region = findRegion(contact, urnImage); region.setFaceId(contact); //Update XMP metadata image QString fileName = picture.toLocalFile(); QImage image(fileName); //Scale face to image dimensions QSize originalSize = image.size(); QSize thumbnailSize = region.sourceImageSize(); QRect rect = region.faceRect(); QRect scaledRect = scaleRect(rect, thumbnailSize, originalSize); QuillMetadataRegion metadataRegion; metadataRegion.setArea(scaledRect); metadataRegion.setType(QuillMetadataRegion::RegionType_Face); QString contactName = m_faceDatabaseProvider->getContactName(contact); metadataRegion.setName(contactName); metadataRegion.setExtension("nco:PersonContact", contact); QuillMetadataRegionList regionList; regionList.append(metadataRegion); saveMetadataRegionList(fileName, regionList); }
std::string PolyRegions::findRegionName(double lat, double lon) const { GeoFeature *region = findRegion(lat, lon); if ( region ) return region->name(); return ""; }
bool CCSRegions::addIfNew(CCSRegion* pRegion) { if (findRegion(pRegion) != -1) return true; return addRegion(pRegion); }
/** * Get value of precalculated spline in the point @x */ T getValue(T x) const { T x0; int i = findRegion(x, x0); /* TODO: check for asm equivalent */ return m_a[i] + m_b[i] *(x - x0) + 0.5 * m_c[i] *(x - x0) *(x - x0) + (1 / 6.0)* m_d[i] *(x - x0) *(x - x0) *(x - x0); }
void BkgFitterTracker::SetRegionProcessOrder (const CommandLineOpts &inception_state) { analysis_compute_plan.region_order.resize (numFitters); int numBeads; int zeroRegions = 0; for (int i=0; i<numFitters; ++i) { numBeads = sliced_chip[i]->GetNumLiveBeads(); if (numBeads == 0) zeroRegions++; analysis_compute_plan.region_order[i] = beadRegion (i, numBeads); } std::sort (analysis_compute_plan.region_order.begin(), analysis_compute_plan.region_order.end(), sortregionProcessOrderVector); int nonZeroRegions = numFitters - zeroRegions; printf("Number of live bead regions (nonZeroRegions): %d\n",nonZeroRegions); if (analysis_compute_plan.gpu_work_load != 0) { int gpuRegions = int (analysis_compute_plan.gpu_work_load * float (nonZeroRegions)); if (gpuRegions > 0) analysis_compute_plan.lastRegionToProcess = gpuRegions; } // bestRegion is used for beads_bestRegion output to hdf5 file if (nonZeroRegions>0) { int r = inception_state.bkg_control.pest_control.bkgModelHdf5Debug_region_r; int c = inception_state.bkg_control.pest_control.bkgModelHdf5Debug_region_c; if (r >= 0 && c >= 0) { int reg = findRegion(r,c); //cout << "SetRegionProcessOrder... findRegion(" << x << "," << y << ") => bestRegion=" << reg << endl << flush; if (reg>=0) bestRegion = beadRegion(reg,sliced_chip[reg]->GetNumLiveBeads()); else bestRegion = analysis_compute_plan.region_order[0]; } else bestRegion = analysis_compute_plan.region_order[0]; bestRegion_region = sliced_chip[bestRegion.first]->get_region(); sliced_chip[bestRegion.first]->isBestRegion = true; //cout << "SetRegionProcessOrder... bestRegion_region.row=" << bestRegion_region->row << " bestRegion_region.col=" << bestRegion_region->col << endl << flush; } else { bestRegion = beadRegion(0,0); bestRegion_region = NULL; } printf("BkgFitterTracker::SetRegionProcessOrder... bestRegion=(%d,%d)\n", bestRegion.first,bestRegion.second); // Now that we have a best region, we can init h5. InitBeads_BestRegion( inception_state ); }
std::vector<Region *>* HSV_Region_Processor_Min_Alloc::processFrame(cv::Mat &frame) { cv::Mat hsvFrame; cv::cvtColor(frame, hsvFrame, cv::COLOR_BGR2HSV); double regX=0, regY=0, regSize=0; for (int i = 0; i<hsvFrame.rows; i++) { const cv::Vec3b* row = hsvFrame.ptr<cv::Vec3b>(i); for (int j = 0; j<hsvFrame.cols; j++) { if (isBlue(row[j])) { findRegion(hsvFrame, i, j, regX, regY, regSize); if (regSize != -1) { regionList->push_back(new Region(regX, regY, regSize, BLUE, BLOB)); } } } } return regionList; }
static INVF_MODE decisionAlgorithm(const DETECTOR_PARAMETERS* detectorParams, DETECTOR_VALUES detectorValues, int transientFlag, INVF_MODE prevInvfMode, int* prevRegionSbr, int* prevRegionOrig ) { int invFiltLevel, regionSbr, regionOrig, regionNrg; const float *quantStepsSbr = detectorParams->quantStepsSbr; const float *quantStepsOrig = detectorParams->quantStepsOrig; const float *nrgBorders = detectorParams->nrgBorders; const int numRegionsSbr = detectorParams->numRegionsSbr; const int numRegionsOrig = detectorParams->numRegionsOrig; const int numRegionsNrg = detectorParams->numRegionsNrg; float quantStepsSbrTmp[MAX_NUM_REGIONS]; float quantStepsOrigTmp[MAX_NUM_REGIONS]; float origQuotaMeanFilt; float sbrQuotaMeanFilt; float nrg; /* counting previous operations */ origQuotaMeanFilt = (float) (ILOG2*3.0*log(detectorValues.origQuotaMeanFilt+EPS)); sbrQuotaMeanFilt = (float) (ILOG2*3.0*log(detectorValues.sbrQuotaMeanFilt+EPS)); nrg = (float) (ILOG2*1.5*log(detectorValues.avgNrg+EPS)); memcpy(quantStepsSbrTmp,quantStepsSbr,numRegionsSbr*sizeof(float)); memcpy(quantStepsOrigTmp,quantStepsOrig,numRegionsOrig*sizeof(float)); /* quantStepsSbrTmp[*prevRegionSbr] quantStepsOrigTmp[*prevRegionOrig] */ if(*prevRegionSbr < numRegionsSbr) { quantStepsSbrTmp[*prevRegionSbr] = quantStepsSbr[*prevRegionSbr] + hysteresis; } if(*prevRegionSbr > 0) { quantStepsSbrTmp[*prevRegionSbr - 1] = quantStepsSbr[*prevRegionSbr - 1] - hysteresis; } if(*prevRegionOrig < numRegionsOrig) { quantStepsOrigTmp[*prevRegionOrig] = quantStepsOrig[*prevRegionOrig] + hysteresis; } if(*prevRegionOrig > 0) { quantStepsOrigTmp[*prevRegionOrig - 1] = quantStepsOrig[*prevRegionOrig - 1] - hysteresis; } regionSbr = findRegion(sbrQuotaMeanFilt, quantStepsSbrTmp, numRegionsSbr, *prevRegionSbr); regionOrig = findRegion(origQuotaMeanFilt, quantStepsOrigTmp, numRegionsOrig, *prevRegionOrig); regionNrg = findRegion(nrg,nrgBorders,numRegionsNrg, 0); *prevRegionSbr = regionSbr; *prevRegionOrig = regionOrig; if(transientFlag == 1) { invFiltLevel = detectorParams->regionSpaceTransient[regionSbr][regionOrig]; } else { invFiltLevel = detectorParams->regionSpace[regionSbr][regionOrig]; } invFiltLevel = max(invFiltLevel + detectorParams->EnergyCompFactor[regionNrg],0); return (INVF_MODE) (invFiltLevel); }
void* wsbrk (INTERNAL_SSIZE_T size) { void* tmp; if (size > 0) { if (gAddressBase == 0) { gAllocatedSize = max (RESERVED_SIZE, AlignPage (size)); gNextAddress = gAddressBase = (INTERNAL_SIZE_T)VirtualAlloc (NULL, gAllocatedSize, MEM_RESERVE, PAGE_NOACCESS); } else if (AlignPage (gNextAddress + size) > (gAddressBase + gAllocatedSize)) { INTERNAL_SIZE_T new_size = max (NEXT_SIZE, AlignPage (size)); void* new_address = (void*)(gAddressBase+gAllocatedSize); do { new_address = findRegion (new_address, new_size); if (new_address == 0) return (void*)-1; gAddressBase = gNextAddress = (INTERNAL_SIZE_T)VirtualAlloc (new_address, new_size, MEM_RESERVE, PAGE_NOACCESS); // repeat in case of race condition // The region that we found has been snagged // by another thread } while (gAddressBase == 0); ASSERT (new_address == (void*)gAddressBase); gAllocatedSize = new_size; if (!makeGmListElement ((void*)gAddressBase)) return (void*)-1; } if ((size + gNextAddress) > AlignPage (gNextAddress)) { void* res; res = VirtualAlloc ((void*)AlignPage (gNextAddress), (size + gNextAddress - AlignPage (gNextAddress)), MEM_COMMIT, PAGE_READWRITE); if (res == 0) return (void*)-1; } tmp = (void*)gNextAddress; gNextAddress = (INTERNAL_SIZE_T)tmp + size; return tmp; } else if (size < 0) { INTERNAL_SIZE_T alignedGoal = AlignPage (gNextAddress + size); /* Trim by releasing the virtual memory */ if (alignedGoal >= gAddressBase) { VirtualFree ((void*)alignedGoal, gNextAddress - alignedGoal, MEM_DECOMMIT); gNextAddress = gNextAddress + size; return (void*)gNextAddress; } else { VirtualFree ((void*)gAddressBase, gNextAddress - gAddressBase, MEM_DECOMMIT); gNextAddress = gAddressBase; return (void*)-1; } } else { return (void*)gNextAddress; } }
void MapModuleNoticeContainer:: initUsingCC( const vector<MapModuleNotice*>& oldVector ) { // This method should only be used for the old index.db. // Go through all the notices for ( uint32 i = 0; i < oldVector.size(); i++ ) { MapModuleNotice* notice = oldVector[i]; addNotice( notice, true ); // True means that regions should be faked. } // Build the ItemIDTrees // We know that the top-regions only contain countries. // Save all the overview maps in a map sorted by cc. // WARNING: This will not work when there is more than // one overview map per region,. map<StringTable::countryCode, uint32> overviewMaps; typedef multimap<StringTable::countryCode, uint32> underviewMapMap_t; underviewMapMap_t underviewMaps; for( uint32 i = 0; i < oldVector.size(); ++i ) { MapModuleNotice* notice = m_allNotices[i]; if ( MapBits::isCountryMap(notice->getMapID()) ) { overviewMaps[m_allNotices[i]->getCountryCode()] = MapBits::countryToOverview(notice->getMapID()); } else if ( MapBits::isUnderviewMap( notice->getMapID() ) ) { underviewMaps.insert(make_pair(m_allNotices[i]->getCountryCode(), notice->getMapID())); } } // Loop over the found overview maps. for( map<StringTable::countryCode, uint32>::iterator it(overviewMaps.begin()); it != overviewMaps.end(); ++it ) { // Add the top level. ItemIDTree* idTree = findRegion( it->first )->getItemIDTreeForWriting(); idTree->addMap( MAX_UINT32, it->second ); // Add to or internal tree of all maps too. m_mapTree.addMap( MAX_UINT32, it->second ); // Get the range of underview maps with the same county code pair<underviewMapMap_t::const_iterator, underviewMapMap_t::const_iterator> range = underviewMaps.equal_range( it->first ); for ( underviewMapMap_t::const_iterator ut(range.first); ut != range.second; ++ut ) { // Add it to the tree of the region idTree->addMap( it->second, ut->second); // Also add it to our tree of maps. m_mapTree.addMap( it->second, ut->second ); } } #ifdef DEBUG_LEVEL_4 for(uint32 i = 0; i < m_allNotices.size(); ++i ) { mc2dbg << "Overview maps for " << m_allNotices[i]->getMapID() << endl; vector<uint32> overviewIDs; m_mapTree.getOverviewMapsFor(m_allNotices[i]->getMapID(), overviewIDs); for(uint32 j = 0; j < overviewIDs.size(); ++j ) { mc2dbg << " " << j << "=" << overviewIDs[j] << endl; } } #endif #ifdef DEBUG_LEVEL_4 // Print stuff mc2dbg << "MAP_HIERARCHY" << endl; set<uint32> mapIDs; m_mapTree.getTopLevelMapIDs(mapIDs); for(set<uint32>::const_iterator it = mapIDs.begin(); it != mapIDs.end(); ++it) { mc2dbg << "TopLevelMap :" << hex << *it << dec << " contains " << endl; set<IDPair_t> items; m_mapTree.getContents(*it, items); for( set<IDPair_t>::iterator it = items.begin(); it != items.end(); ++it ) { mc2dbg << " " << it->getMapID() << ":" << hex << it->getItemID() << dec << endl; } } #endif }
static INVF_MODE decisionAlgorithm(const DETECTOR_PARAMETERS* detectorParams, DETECTOR_VALUES detectorValues, int transientFlag, INVF_MODE prevInvfMode, int* prevRegionSbr, int* prevRegionOrig ) { int invFiltLevel, regionSbr, regionOrig, regionNrg; const float *quantStepsSbr = detectorParams->quantStepsSbr; const float *quantStepsOrig = detectorParams->quantStepsOrig; const float *nrgBorders = detectorParams->nrgBorders; const int numRegionsSbr = detectorParams->numRegionsSbr; const int numRegionsOrig = detectorParams->numRegionsOrig; const int numRegionsNrg = detectorParams->numRegionsNrg; float quantStepsSbrTmp[MAX_NUM_REGIONS]; float quantStepsOrigTmp[MAX_NUM_REGIONS]; float origQuotaMeanFilt; float sbrQuotaMeanFilt; float nrg; COUNT_sub_start("decisionAlgorithm"); INDIRECT(6); MOVE(3); PTR_INIT(3); /* counting previous operations */ ADD(3); MULT(3); TRANS(3); origQuotaMeanFilt = (float) (ILOG2*3.0*log(detectorValues.origQuotaMeanFilt+EPS)); sbrQuotaMeanFilt = (float) (ILOG2*3.0*log(detectorValues.sbrQuotaMeanFilt+EPS)); nrg = (float) (ILOG2*1.5*log(detectorValues.avgNrg+EPS)); FUNC(2); LOOP(1); PTR_INIT(2); MOVE(1); STORE(numRegionsSbr); memcpy(quantStepsSbrTmp,quantStepsSbr,numRegionsSbr*sizeof(float)); FUNC(2); LOOP(1); PTR_INIT(2); MOVE(1); STORE(numRegionsOrig); memcpy(quantStepsOrigTmp,quantStepsOrig,numRegionsOrig*sizeof(float)); PTR_INIT(2); /* quantStepsSbrTmp[*prevRegionSbr] quantStepsOrigTmp[*prevRegionOrig] */ ADD(1); BRANCH(1); if(*prevRegionSbr < numRegionsSbr) { ADD(1); STORE(1); quantStepsSbrTmp[*prevRegionSbr] = quantStepsSbr[*prevRegionSbr] + hysteresis; } BRANCH(1); if(*prevRegionSbr > 0) { ADD(1); STORE(1); quantStepsSbrTmp[*prevRegionSbr - 1] = quantStepsSbr[*prevRegionSbr - 1] - hysteresis; } if(*prevRegionOrig < numRegionsOrig) { ADD(1); STORE(1); quantStepsOrigTmp[*prevRegionOrig] = quantStepsOrig[*prevRegionOrig] + hysteresis; } BRANCH(1); if(*prevRegionOrig > 0) { ADD(1); STORE(1); quantStepsOrigTmp[*prevRegionOrig - 1] = quantStepsOrig[*prevRegionOrig - 1] - hysteresis; } FUNC(4); regionSbr = findRegion(sbrQuotaMeanFilt, quantStepsSbrTmp, numRegionsSbr, *prevRegionSbr); FUNC(4); regionOrig = findRegion(origQuotaMeanFilt, quantStepsOrigTmp, numRegionsOrig, *prevRegionOrig); FUNC(4); regionNrg = findRegion(nrg,nrgBorders,numRegionsNrg, 0); MOVE(2); *prevRegionSbr = regionSbr; *prevRegionOrig = regionOrig; ADD(1); BRANCH(1); if(transientFlag == 1){ INDIRECT(1); MOVE(1); invFiltLevel = detectorParams->regionSpaceTransient[regionSbr][regionOrig]; } else{ INDIRECT(1); MOVE(1); invFiltLevel = detectorParams->regionSpace[regionSbr][regionOrig]; } INDIRECT(1); ADD(2); BRANCH(1); MOVE(1); invFiltLevel = max(invFiltLevel + detectorParams->EnergyCompFactor[regionNrg],0); COUNT_sub_end(); return (INVF_MODE) (invFiltLevel); }
static INVF_MODE decisionAlgorithm(const DETECTOR_PARAMETERS *detectorParams, /*!< Struct with the detector parameters. */ DETECTOR_VALUES *detectorValues, /*!< Struct with the detector values. */ INT transientFlag, /*!< Flag indicating if there is a transient present.*/ INT* prevRegionSbr, /*!< The previous region in which the Sbr value was. */ INT* prevRegionOrig /*!< The previous region in which the Orig value was. */ ) { INT invFiltLevel, regionSbr, regionOrig, regionNrg; /* Current thresholds. */ const FIXP_DBL *quantStepsSbr = detectorParams->quantStepsSbr; const FIXP_DBL *quantStepsOrig = detectorParams->quantStepsOrig; const FIXP_DBL *nrgBorders = detectorParams->nrgBorders; const INT numRegionsSbr = detectorParams->numRegionsSbr; const INT numRegionsOrig = detectorParams->numRegionsOrig; const INT numRegionsNrg = detectorParams->numRegionsNrg; FIXP_DBL quantStepsSbrTmp[MAX_NUM_REGIONS]; FIXP_DBL quantStepsOrigTmp[MAX_NUM_REGIONS]; /* Current detector values. */ FIXP_DBL origQuotaMeanFilt; FIXP_DBL sbrQuotaMeanFilt; FIXP_DBL nrg; /* 0.375 = 3.0 / 8.0; 0.31143075889 = log2(RELAXATION)/64.0; 0.625 = log(16)/64.0; 0.6875 = 44/64.0 */ origQuotaMeanFilt = (fMultDiv2(FL2FXCONST_DBL(2.f*0.375f), (FIXP_DBL)(CalcLdData(max(detectorValues->origQuotaMeanFilt,(FIXP_DBL)1)) + FL2FXCONST_DBL(0.31143075889f)))) << 0; /* scaled by 1/2^9 */ sbrQuotaMeanFilt = (fMultDiv2(FL2FXCONST_DBL(2.f*0.375f), (FIXP_DBL)(CalcLdData(max(detectorValues->sbrQuotaMeanFilt,(FIXP_DBL)1)) + FL2FXCONST_DBL(0.31143075889f)))) << 0; /* scaled by 1/2^9 */ /* If energy is zero then we will get different results for different word lengths. */ nrg = (fMultDiv2(FL2FXCONST_DBL(2.f*0.375f), (FIXP_DBL)(CalcLdData(detectorValues->avgNrg+(FIXP_DBL)1) + FL2FXCONST_DBL(0.0625f) + FL2FXCONST_DBL(0.6875f)))) << 0; /* scaled by 1/2^8; 2^44 -> qmf energy scale */ FDKmemcpy(quantStepsSbrTmp,quantStepsSbr,numRegionsSbr*sizeof(FIXP_DBL)); FDKmemcpy(quantStepsOrigTmp,quantStepsOrig,numRegionsOrig*sizeof(FIXP_DBL)); if(*prevRegionSbr < numRegionsSbr) quantStepsSbrTmp[*prevRegionSbr] = quantStepsSbr[*prevRegionSbr] + hysteresis; if(*prevRegionSbr > 0) quantStepsSbrTmp[*prevRegionSbr - 1] = quantStepsSbr[*prevRegionSbr - 1] - hysteresis; if(*prevRegionOrig < numRegionsOrig) quantStepsOrigTmp[*prevRegionOrig] = quantStepsOrig[*prevRegionOrig] + hysteresis; if(*prevRegionOrig > 0) quantStepsOrigTmp[*prevRegionOrig - 1] = quantStepsOrig[*prevRegionOrig - 1] - hysteresis; regionSbr = findRegion(sbrQuotaMeanFilt, quantStepsSbrTmp, numRegionsSbr); regionOrig = findRegion(origQuotaMeanFilt, quantStepsOrigTmp, numRegionsOrig); regionNrg = findRegion(nrg,nrgBorders,numRegionsNrg); *prevRegionSbr = regionSbr; *prevRegionOrig = regionOrig; /* Use different settings if a transient is present*/ invFiltLevel = (transientFlag == 1) ? detectorParams->regionSpaceTransient[regionSbr][regionOrig] : detectorParams->regionSpace[regionSbr][regionOrig]; /* Compensate for low energy.*/ invFiltLevel = max(invFiltLevel + detectorParams->EnergyCompFactor[regionNrg],0); return (INVF_MODE) (invFiltLevel); }
/** * Determine the approximate closest points of two polygons. * @param self First QPolygonF. * @param other Second QPolygonF. * @return QLineF::p1() returns point of \a self; * QLineF::p2() returns point of \a other. */ QLineF closestPoints(const QPolygonF& self, const QPolygonF& other) { const QRectF& selfRect = self.boundingRect(); const QRectF& otherRect = other.boundingRect(); Uml::Region::Enum region = findRegion(selfRect, otherRect); if (region == Uml::Region::Center) return QLineF(); if (self.size() < 3 || other.size() < 3) return QLineF(); QLineF result; const int selfLastIndex = self.size() - 1 - (int)self.isClosed(); const int otherLastIndex = other.size() - 1 - (int)other.isClosed(); QPointF selfPoint(self.at(selfLastIndex)); QPointF otherPoint(other.at(otherLastIndex)); QLineF selfLine, otherLine; int i; switch (region) { case Uml::Region::North: // Find other's line with largest Y values otherLine = findLine(other, Y, Largest, selfRect); // Find own line with smallest Y values selfLine = findLine(self, Y, Smallest, otherRect); // Use the middle value of the X values result.setLine(middle(selfLine.p2().x(), selfLine.p1().x()), selfLine.p1().y(), middle(otherLine.p2().x(), otherLine.p1().x()), otherLine.p1().y()); break; case Uml::Region::South: // Find other's line with smallest Y values otherLine = findLine(other, Y, Smallest, selfRect); // Find own line with largest Y values selfLine = findLine(self, Y, Largest, otherRect); // Use the middle value of the X values result.setLine(middle(selfLine.p2().x(), selfLine.p1().x()), selfLine.p1().y(), middle(otherLine.p2().x(), otherLine.p1().x()), otherLine.p1().y()); break; case Uml::Region::West: // Find other's line with largest X values otherLine = findLine(other, X, Largest, selfRect); // Find own line with smallest X values selfLine = findLine(self, X, Smallest, otherRect); // Use the middle value of the Y values result.setLine(selfLine.p1().x(), middle(selfLine.p2().y(), selfLine.p1().y()), otherLine.p1().x(), middle(otherLine.p2().y(), otherLine.p1().y())); break; case Uml::Region::East: // Find other's line with smallest X values otherLine = findLine(other, X, Smallest, selfRect); // Find own line with largest X values selfLine = findLine(self, X, Largest, otherRect); // Use the middle value of the Y values result.setLine(selfLine.p1().x(), middle(selfLine.p2().y(), selfLine.p1().y()), otherLine.p1().x(), middle(otherLine.p2().y(), otherLine.p1().y())); break; case Uml::Region::NorthWest: // Find other's point with largest X and largest Y value for (i = 0; i < otherLastIndex; ++i) { QPointF current(other.at(i)); if (current.x() + current.y() >= otherPoint.x() + otherPoint.y()) { otherPoint = current; } } // Find own point with smallest X and smallest Y value for (i = 0; i < selfLastIndex; ++i) { QPointF current(self.at(i)); if (current.x() + current.y() <= selfPoint.x() + selfPoint.y()) { selfPoint = current; } } result.setPoints(selfPoint, otherPoint); break; case Uml::Region::SouthWest: // Find other's point with largest X and smallest Y value for (i = 0; i < otherLastIndex; ++i) { QPointF current(other.at(i)); if (current.x() >= otherPoint.x() && current.y() <= otherPoint.y()) { otherPoint = current; } } // Find own point with smallest X and largest Y value for (i = 0; i < selfLastIndex; ++i) { QPointF current(self.at(i)); if (current.x() <= selfPoint.x() && current.y() >= selfPoint.y()) { selfPoint = current; } } result.setPoints(selfPoint, otherPoint); break; case Uml::Region::NorthEast: // Find other's point with smallest X and largest Y value for (i = 0; i < otherLastIndex; ++i) { QPointF current(other.at(i)); if (current.x() <= otherPoint.x() && current.y() >= otherPoint.y()) { otherPoint = current; } } // Find own point with largest X and smallest Y value for (i = 0; i < selfLastIndex; ++i) { QPointF current(self.at(i)); if (current.x() >= selfPoint.x() && current.y() <= selfPoint.y()) { selfPoint = current; } } result.setPoints(selfPoint, otherPoint); break; case Uml::Region::SouthEast: // Find other's point with smallest X and smallest Y value for (i = 0; i < otherLastIndex; ++i) { QPointF current(other.at(i)); if (current.x() + current.y() <= otherPoint.x() + otherPoint.y()) { otherPoint = current; } } // Find own point with largest X and largest Y value for (i = 0; i < selfLastIndex; ++i) { QPointF current(self.at(i)); if (current.x() + current.y() >= selfPoint.x() + selfPoint.y()) { selfPoint = current; } } result.setPoints(selfPoint, otherPoint); break; default: // Error break; } return result; }