KoColorConversionSystem::KoColorConversionSystem() : d(new Private) { // Create the Alpha 8bit d->alphaNode = new Node; d->alphaNode->modelId = AlphaColorModelID.id(); d->alphaNode->depthId = Integer8BitsColorDepthID.id(); d->alphaNode->crossingCost = 1000000; d->alphaNode->isInitialized = true; d->alphaNode->isGray = true; // <- FIXME: it's a little bit hacky as alpha doesn't really have color information d->graph[ NodeKey(d->alphaNode->modelId, d->alphaNode->depthId, "Dummy profile")] = d->alphaNode; Vertex* v = createVertex(d->alphaNode, d->alphaNode); v->setFactoryFromSrc(new KoCopyColorConversionTransformationFactory(AlphaColorModelID.id(), Integer8BitsColorDepthID.id(), "")); }
/// return the index of the MHM domain of a fracture int TPZFracSet::MHMDomain(TPZFracture &frac) { TPZManVector<REAL,3> x1(3), x2(3), xmid(3); fNodeVec[frac.fNodes[0]].GetCoordinates(x1); fNodeVec[frac.fNodes[1]].GetCoordinates(x2); std::pair<uint32_t,uint32_t> key0 = NodeKey(frac.fNodes[0]); std::pair<uint32_t,uint32_t> key1 = NodeKey(frac.fNodes[1]); if(key0.first == key1.first && key0.first%fMHMSpacingInt[0] == 0) { return -1; } if(key0.second == key1.second && key0.second%fMHMSpacingInt[1] == 0) { return -1; } for (int i=0; i<3; i++) { xmid[i] = (x1[i]+x2[i])*0.5-fLowLeft[i]; } int numfacex = (fTopRight[0]-fLowLeft[0])/fMHMSpacing[0]; int numx = (xmid[0])/fMHMSpacing[0]; int numy = (xmid[1])/fMHMSpacing[1]; return numy*numfacex+numx; }
/// add the cornernodes of the MHM mesh void TPZFracSet::AddMHMNodes() { int64_t nfrac = fFractureVec.NElements(); int numx = (fTopRight[0]-fLowLeft[0])/fMHMSpacing[0]; int numy = (fTopRight[1]-fLowLeft[1])/fMHMSpacing[1]; for (int i=0; i<=numx; i++) { for (int j=0; j<=numy; j++) { TPZManVector<REAL,3> co(3,0.); co[0] = fLowLeft[0]+i*fMHMSpacing[0]; co[1] = fLowLeft[1]+j*fMHMSpacing[1]; TPZGeoNode node; node.SetCoord(co); int64_t index = InsertNode(node); fNodeVec[index].GetCoordinates(co); std::pair<uint32_t, uint32_t> p1 = NodeKey(co); if (p1.first % fMHMSpacingInt[0] != 0 || p1.second%fMHMSpacingInt[1] != 0) { DebugStop(); } } } // build the datastructure for horizontal and vertical lines fHorizontalLines.Resize(numy+1); fVerticalLines.Resize(numx+1); int64_t nnodes = fNodeVec.NElements(); for (int64_t in=0; in<nnodes; in++) { TPZManVector<REAL,3> co(3); fNodeVec[in].GetCoordinates(co); uint64_t locprev = GetLoc(fNodeVec[in]); std::pair<uint32_t, uint32_t> p1 = NodeKey(co); if (p1.first%fMHMSpacingInt[0] == 0) { int line = p1.first/fMHMSpacingInt[0]; REAL coprev = fNodeVec[in].Coord(0); REAL conew = line*fTol*fMHMSpacingInt[0]; fNodeVec[in].SetCoord(0, conew); uint64_t locafter = GetLoc(fNodeVec[in]); if (locprev != locafter) { DebugStop(); } fVerticalLines[line][co[1]] = in; } if (p1.second%fMHMSpacingInt[1] == 0) { int line = p1.second/fMHMSpacingInt[1]; REAL coprev = fNodeVec[in].Coord(1); REAL conew = line*fTol*fMHMSpacingInt[1]; fNodeVec[in].SetCoord(1, conew); uint64_t locafter = GetLoc(fNodeVec[in]); if (locprev != locafter) { DebugStop(); } fHorizontalLines[line][co[0]] = in; } } int64_t nhor = fHorizontalLines.NElements(); for (int64_t hor = 0; hor < nhor; hor++) { for (auto it = fHorizontalLines[hor].begin(); it != fHorizontalLines[hor].end(); it++) { auto it2 = it; it2++; if (it2 == fHorizontalLines[hor].end()) { continue; } TPZManVector<int64_t,2> nodes(2); nodes[0] = it->second; nodes[1] = it2->second; int64_t index; int matid = matid_MHM_line; if (hor == 0 || hor == nhor-1) { matid = matid_BC; } TPZFracture frac = TPZFracture(nfrac++, matid, nodes[0], nodes[1]); frac.fFracPerm = 0; frac.fPhysicalName="MHMLine"; if (hor == 0 || hor == nhor-1) { frac.fPhysicalName = "BC"; } index = fFractureVec.AllocateNewElement(); fFractureVec[index] = frac; } } int64_t nver = fVerticalLines.NElements(); for (int64_t ver = 0; ver < nver; ver++) { for (auto it = fVerticalLines[ver].begin(); it != fVerticalLines[ver].end(); it++) { auto it2 = it; it2++; if (it2 == fVerticalLines[ver].end()) { continue; } TPZManVector<int64_t,2> nodes(2); nodes[0] = it->second; nodes[1] = it2->second; int matid = matid_MHM_line; if (ver==0 || ver==nver-1) { matid = matid_BC; } int64_t index; TPZFracture frac = TPZFracture(nfrac++, matid, nodes[0], nodes[1]); frac.fFracPerm = 0.; frac.fPhysicalName = "MHMLine"; if (ver == 0 || ver == nver-1) { frac.fPhysicalName = "BC"; } index = fFractureVec.AllocateNewElement(); fFractureVec[index] = frac; } } }
/// Split fractures by the MHM grid void TPZFracSet::SplitFracturesByMHM() { int64_t nfrac = fFractureVec.NElements(); for (int64_t ifr=0; ifr<nfrac; ifr++) { std::pair<uint32_t,uint32_t> p1,p2; TPZManVector<REAL,3> co1(3),co2(3); int64_t no1 = fFractureVec[ifr].fNodes[0]; int64_t no2 = fFractureVec[ifr].fNodes[1]; fNodeVec[no1].GetCoordinates(co1); fNodeVec[no2].GetCoordinates(co2); p1 = NodeKey(fFractureVec[ifr].fNodes[0]); p2 = NodeKey(fFractureVec[ifr].fNodes[1]); int64_t domain1 = p1.first/fMHMSpacingInt[0]; int64_t domain2 = p2.first/fMHMSpacingInt[0]; if(p2.first > p1.first && p2.first % fMHMSpacingInt[0] == 0) domain2--; if (domain2<domain1) { DebugStop(); } while (domain2 > domain1) { REAL frac = ((domain2)*fMHMSpacing[0]-co1[0])/(co2[0]-co1[0]); SplitFractures(ifr, frac, -1, -1.); fNodeVec[fFractureVec[ifr].fNodes[1]].GetCoordinates(co2); std::pair<uint32_t, uint32_t> pc = NodeKey(co2); if (pc.first%fMHMSpacingInt[0] != 0) { DebugStop(); } domain2--; } } nfrac = fFractureVec.NElements(); for (int64_t ifr=0; ifr<nfrac; ifr++) { std::pair<uint32_t,uint32_t> p1,p2; TPZManVector<REAL,3> co1(3),co2(3); fNodeVec[fFractureVec[ifr].fNodes[0]].GetCoordinates(co1); fNodeVec[fFractureVec[ifr].fNodes[1]].GetCoordinates(co2); p1 = NodeKey(fFractureVec[ifr].fNodes[0]); p2 = NodeKey(fFractureVec[ifr].fNodes[1]); int64_t domain1 = p1.second/fMHMSpacingInt[1]; int64_t domain2 = p2.second/fMHMSpacingInt[1]; if (domain1 < domain2) { if(p2.second % fMHMSpacingInt[1] == 0) domain2--; if (domain2<domain1) { DebugStop(); } while (domain2 > domain1) { fNodeVec[fFractureVec[ifr].fNodes[1]].GetCoordinates(co2); REAL frac = ((domain2)*fMHMSpacing[1]-co1[1])/(co2[1]-co1[1]); SplitFractures(ifr, frac, -1, -1.); fNodeVec[fFractureVec[ifr].fNodes[1]].GetCoordinates(co2); std::pair<uint32_t, uint32_t> pc = NodeKey(co2); if (pc.second%fMHMSpacingInt[1] != 0) { DebugStop(); } domain2--; } } else if(domain1 > domain2) { if(p1.second % fMHMSpacingInt[1] == 0) domain1--; while (domain1 > domain2) { REAL frac = ((domain2+1)*fMHMSpacing[0]-co1[1])/(co2[1]-co1[1]); SplitFractures(ifr, frac, -1, -1.); fNodeVec[fFractureVec[ifr].fNodes[1]].GetCoordinates(co2); std::pair<uint32_t, uint32_t> pc = NodeKey(co2); if (pc.second%fMHMSpacingInt[1] != 0) { DebugStop(); } domain2++; } } } }