YSRESULT YsShellExt_RoundUtil3d::CalculateRoundingAll(const YsShell &shl,const double radius) { YsArray <unsigned int> vtKeyArray; YsArray <HalfRoundCorner *> cornerPtrArray; for(auto &corner : cornerArray) { vtKeyArray.Append(shl.GetSearchKey(corner.fromVtHd)); cornerPtrArray.Append(&corner); } YsQuickSort <unsigned int,HalfRoundCorner *> (vtKeyArray.GetN(),vtKeyArray,cornerPtrArray); YsArray <HalfRoundCorner *> cornerPerVertex; for(YSSIZE_T idx=0; idx<cornerPtrArray.GetN(); ++idx) { cornerPerVertex.Append(cornerPtrArray[idx]); if(cornerPtrArray.GetN()-1==idx || vtKeyArray[idx]!=vtKeyArray[idx+1]) { if(YSOK!=CalculateRoundingPerVertex(shl,cornerPerVertex,radius)) { return YSERR; } cornerPerVertex.CleanUp(); } } return YSOK; }
YsArray <const YsShellExt_RoundUtil3d::HalfRoundCorner *> YsShellExt_RoundUtil3d::MakeSortedHalfRoundCorner(const YsShell &shl) const { YsArray <unsigned int> vtKeyArray; YsArray <const HalfRoundCorner *> cornerPtrArray; for(auto &corner : cornerArray) { vtKeyArray.Append(shl.GetSearchKey(corner.fromVtHd)); cornerPtrArray.Append(&corner); } YsQuickSort <unsigned int,const HalfRoundCorner *> (vtKeyArray.GetN(),vtKeyArray,cornerPtrArray); return cornerPtrArray; }
YSRESULT YsShellExt_RoundUtil::SetUpRoundPolygon(const YsShell &shl,YsShellPolygonHandle plHd,const YsShellVertexStore *roundVtx) { YsArray <YsShellVertexHandle> plVtHd; shl.GetPolygon(plVtHd,plHd); for(YSSIZE_T idx=0; idx<plVtHd.GetN(); ++idx) { const YsShellVertexHandle fromVtHd=plVtHd[idx]; if(NULL==roundVtx || YSTRUE==roundVtx->IsIncluded(fromVtHd)) { const YsShellVertexHandle toVtHd[2]= { plVtHd.GetCyclic(idx-1), plVtHd.GetCyclic(idx+1) }; AddRoundCorner(shl,fromVtHd,toVtHd); } } targetPlKeyArray.Append(shl.GetSearchKey(plHd)); return YSOK; }