本文整理汇总了C++中TRegion::getSubregionCount方法的典型用法代码示例。如果您正苦于以下问题:C++ TRegion::getSubregionCount方法的具体用法?C++ TRegion::getSubregionCount怎么用?C++ TRegion::getSubregionCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TRegion
的用法示例。
在下文中一共展示了TRegion::getSubregionCount方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: stroke_autofill_learn
void stroke_autofill_learn(const TVectorImageP &imgToLearn, TStroke *stroke) {
if (!imgToLearn || !stroke || stroke->getControlPointCount() == 0) return;
TVectorImage appImg;
TStroke *appStroke = new TStroke(*stroke);
appImg.addStroke(appStroke);
appImg.findRegions();
double pbx, pby;
double totalArea = 0;
pbx = pby = 0;
if (!regionsReference.isEmpty()) regionsReference.clear();
int i, j, index = 0;
for (i = 0; i < (int)imgToLearn->getRegionCount(); i++) {
TRegion *currentRegion = imgToLearn->getRegion(i);
for (j = 0; j < (int)appImg.getRegionCount(); j++) {
TRegion *region = appImg.getRegion(j);
if (contains(region, currentRegion)) {
scanRegion(currentRegion, index, regionsReference, region->getBBox());
index++;
int k, subRegionCount = currentRegion->getSubregionCount();
for (k = 0; k < subRegionCount; k++) {
TRegion *subRegion = currentRegion->getSubregion(k);
if (contains(region, subRegion))
scanSubRegion(subRegion, index, regionsReference,
region->getBBox());
}
}
}
}
QMap<int, Region>::Iterator it;
for (it = regionsReference.begin(); it != regionsReference.end(); it++) {
pbx += it.value().m_barycentre.x;
pby += it.value().m_barycentre.y;
totalArea += it.value().m_area;
}
if (totalArea > 0)
referenceB = TPointD(pbx / totalArea, pby / totalArea);
else
referenceB = TPointD(0.0, 0.0);
}
示例2: rect_autofill_learn
void rect_autofill_learn(const TVectorImageP &imgToLearn, const TRectD &rect)
{
if (rect.getLx() * rect.getLy() < MIN_SIZE) return;
double pbx, pby;
double totalArea = 0;
pbx = pby = 0;
if (!regionsReference.isEmpty()) regionsReference.clear();
int i, index = 0, regionCount = imgToLearn->getRegionCount();
for (i = 0; i < regionCount; i++) {
TRegion *region = imgToLearn->getRegion(i);
if (rect.contains(region->getBBox())) {
scanRegion(region, index, regionsReference, rect);
index++;
}
int j, subRegionCount = region->getSubregionCount();
for (j = 0; j < subRegionCount; j++) {
TRegion *subRegion = region->getSubregion(j);
if (rect.contains(subRegion->getBBox()))
scanSubRegion(subRegion, index, regionsReference, rect);
}
}
QMap<int, Region>::Iterator it;
for (it = regionsReference.begin(); it != regionsReference.end(); it++) {
pbx += it.value().m_barycentre.x;
pby += it.value().m_barycentre.y;
totalArea += it.value().m_area;
}
if (totalArea > 0)
referenceB = TPointD(pbx / totalArea, pby / totalArea);
else
referenceB = TPointD(0.0, 0.0);
}
示例3: stroke_autofill_apply
bool stroke_autofill_apply(const TVectorImageP &imgToApply, TStroke *stroke,
bool selective) {
if (!imgToApply || !stroke || stroke->getControlPointCount() == 0)
return false;
TVectorImage appImg;
TStroke *appStroke = new TStroke(*stroke);
appImg.addStroke(appStroke);
appImg.findRegions();
if (regionsReference.size() <= 0) return false;
double pbx, pby;
double totalArea = 0;
pbx = pby = 0.0;
if (!regionsWork.isEmpty()) regionsWork.clear();
int i, j, index = 0;
for (i = 0; i < (int)imgToApply->getRegionCount(); i++) {
TRegion *currentRegion = imgToApply->getRegion(i);
for (j = 0; j < (int)appImg.getRegionCount(); j++) {
TRegion *region = appImg.getRegion(j);
if (contains(region, currentRegion)) {
scanRegion(currentRegion, index, regionsWork, region->getBBox());
index++;
int k, subRegionCount = currentRegion->getSubregionCount();
for (k = 0; k < subRegionCount; k++) {
TRegion *subRegion = currentRegion->getSubregion(k);
if (contains(region, subRegion))
scanSubRegion(subRegion, index, regionsWork, region->getBBox());
}
}
}
}
if (regionsWork.size() <= 0) return false;
QMap<int, Region>::Iterator it;
for (it = regionsWork.begin(); it != regionsWork.end(); it++) {
pbx += it.value().m_barycentre.x;
pby += it.value().m_barycentre.y;
totalArea += it.value().m_area;
}
workB = TPointD(pbx / totalArea, pby / totalArea);
std::vector<MatchingProbs> probVector;
RegionDataList::Iterator refIt, workIt;
for (refIt = regionsReference.begin(); refIt != regionsReference.end();
refIt++)
for (workIt = regionsWork.begin(); workIt != regionsWork.end(); workIt++)
assignProbs(probVector, refIt.value(), workIt.value(), refIt.key(),
workIt.key());
bool filledRegions = false;
for (refIt = regionsReference.begin(); refIt != regionsReference.end();
refIt++) {
int to = 0, from = 0;
int valore = 0;
do
valore = match(probVector, from, to);
while ((regionsWork[to].m_match != -1 ||
regionsReference[from].m_match != -1) &&
valore > 0);
if (valore > AMB_TRESH) {
regionsWork[to].m_match = from;
regionsReference[from].m_match = to;
regionsWork[to].m_styleId = regionsReference[from].m_styleId;
TRegion *reg = regionsWork[to].m_region;
if (reg && (!selective || selective && reg->getStyle() == 0)) {
reg->setStyle(regionsWork[to].m_styleId);
filledRegions = true;
}
}
}
return filledRegions;
}
示例4: rect_autofill_apply
bool rect_autofill_apply(const TVectorImageP &imgToApply, const TRectD &rect,
bool selective) {
if (rect.getLx() * rect.getLy() < MIN_SIZE) return false;
if (regionsReference.size() <= 0) return false;
double pbx, pby;
double totalArea = 0;
pbx = pby = 0.0;
if (!regionsWork.isEmpty()) regionsWork.clear();
int i, index = 0, regionCount = imgToApply->getRegionCount();
for (i = 0; i < regionCount; i++) {
TRegion *region = imgToApply->getRegion(i);
TRectD bbox = region->getBBox();
if (rect.contains(bbox)) {
scanRegion(region, index, regionsWork, rect);
index++;
}
int j, subRegionCount = region->getSubregionCount();
for (j = 0; j < subRegionCount; j++) {
TRegion *subRegion = region->getSubregion(j);
if (rect.contains(subRegion->getBBox()))
scanSubRegion(subRegion, index, regionsWork, rect);
}
}
if (regionsWork.size() <= 0) return false;
QMap<int, Region>::Iterator it;
for (it = regionsWork.begin(); it != regionsWork.end(); it++) {
pbx += it.value().m_barycentre.x;
pby += it.value().m_barycentre.y;
totalArea += it.value().m_area;
}
workB = TPointD(pbx / totalArea, pby / totalArea);
std::vector<MatchingProbs> probVector;
RegionDataList::Iterator refIt, workIt;
for (refIt = regionsReference.begin(); refIt != regionsReference.end();
refIt++)
for (workIt = regionsWork.begin(); workIt != regionsWork.end(); workIt++)
assignProbs(probVector, refIt.value(), workIt.value(), refIt.key(),
workIt.key());
bool filledRegions = false;
for (refIt = regionsReference.begin(); refIt != regionsReference.end();
refIt++) {
int to = 0, from = 0;
int valore = 0;
do
valore = match(probVector, from, to);
while ((regionsWork[to].m_match != -1 ||
regionsReference[from].m_match != -1) &&
valore > 0);
if (valore > AMB_TRESH) {
regionsWork[to].m_match = from;
regionsReference[from].m_match = to;
regionsWork[to].m_styleId = regionsReference[from].m_styleId;
TRegion *reg = regionsWork[to].m_region;
if (reg && (!selective || selective && reg->getStyle() == 0)) {
reg->setStyle(regionsWork[to].m_styleId);
filledRegions = true;
}
}
}
return filledRegions;
}