//--------------------------------------------------------- bool CShapes_Buffer::Get_Buffers(CSG_Shapes *pShapes, int Field, CSG_Shapes *pBuffers, double Scale, bool bDissolve) { //----------------------------------------------------- double Distance; CSG_Shapes Part(SHAPE_TYPE_Polygon); CSG_Shape *pPart = Part.Add_Shape(), *pBuffer; Distance = Parameters("DIST_FIELD")->asDouble() * Scale; Scale = Parameters("DIST_SCALE")->asDouble() * Scale; if( !bDissolve ) { pBuffers->Create(SHAPE_TYPE_Polygon, CSG_String::Format(SG_T("%s [%s]"), pShapes->Get_Name(), _TL("Buffer")), pShapes); } else { pBuffers->Create(SHAPE_TYPE_Polygon, CSG_String::Format(SG_T("%s [%s]"), pShapes->Get_Name(), _TL("Buffer"))); pBuffers->Add_Field(_TL("ID"), SG_DATATYPE_Int); pBuffer = pBuffers->Add_Shape(); } //----------------------------------------------------- for(int iShape=0; iShape<pShapes->Get_Count() && Set_Progress(iShape, pShapes->Get_Count()); iShape++) { CSG_Shape *pShape = pShapes->Get_Shape(iShape); if( Field < 0 || (Distance = Scale * pShape->asDouble(Field)) > 0.0 ) { if( !bDissolve ) { pBuffer = pBuffers->Add_Shape(pShape, SHAPE_COPY_ATTR); } if( pBuffer->Get_Part_Count() == 0 ) { Get_Buffer(pShape, pBuffer, Distance); } else { Get_Buffer(pShape, pPart , Distance); SG_Polygon_Union(pBuffer, pPart); pPart->Del_Parts(); } } } //----------------------------------------------------- return( pBuffers->is_Valid() ); }
/* * Get a buffer for given filesystem block. */ int Get_FS_Buffer(struct FS_Buffer_Cache *cache, ulong_t fsBlockNum, struct FS_Buffer **pBuf) { int rc; Mutex_Lock(&cache->lock); rc = Get_Buffer(cache, fsBlockNum, pBuf); Mutex_Unlock(&cache->lock); return rc; }