//--------------------------------------------------------- bool CShapes_Buffer::Get_Buffer_Points(CSG_Shape *pPoints, CSG_Shape *pBuffer, double Distance) { CSG_Shapes Part(SHAPE_TYPE_Polygon); CSG_Shape *pPart = Part.Add_Shape(); for(int iPart=0; iPart<pPoints->Get_Part_Count(); iPart++) { for(int iPoint=0; iPoint<pPoints->Get_Point_Count(iPart); iPoint++) { if( pBuffer->Get_Part_Count() == 0 ) { Add_Arc(pBuffer, pPoints->Get_Point(iPoint), Distance, 0.0, M_PI_360); } else { Add_Arc(pPart , pPoints->Get_Point(iPoint), Distance, 0.0, M_PI_360); SG_Polygon_Union(pBuffer, pPart); pPart->Del_Parts(); } } } return( true ); }
//--------------------------------------------------------- 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() ); }
//--------------------------------------------------------- bool CSG_Network::Add_Shape(CSG_Shape *pShape) { if( !pShape || !pShape->is_Valid() ) { return( false ); } //----------------------------------------------------- CSG_Shapes Part(SHAPE_TYPE_Line); CSG_Shape *pPart = Part.Add_Shape(); for(int iPart=0; iPart<pShape->Get_Part_Count(); iPart++) { if( pShape->Get_Point_Count(iPart) > 1 ) { bool bAscending = pShape->Get_Type() != SHAPE_TYPE_Polygon || ((CSG_Shape_Polygon *)pShape)->is_Lake(iPart) != ((CSG_Shape_Polygon *)pShape)->is_Clockwise(iPart); CSG_Point q, p = pShape->Get_Point(0, iPart, bAscending); pPart->Add_Point(p); for(int iPoint=1; iPoint<pShape->Get_Point_Count(iPart); iPoint++) { if( !p.is_Equal(q = pShape->Get_Point(iPoint, iPart, bAscending)) ) { p = q; pPart->Add_Point(p); } } if( pPart->Get_Point_Count(0) > 1 ) { _Add_Line(pPart, pShape->Get_Type()); } pPart->Del_Parts(); } } return( true ); }