I hope that I understood your question correctly.
Let's assume there one layer "polygons"
with its corresponding attribute table accordingly, see image below.
And of course there are some gaps or overlaps.
Below I am suggesting a step-by-step process of how to simplify only the subset of polygons, while maintaining no gaps or overlaps between two adjacent resulting polygons.
Step 1. Divide your original layer into "good" and "bad" features. I used 'Extract by expression'
, e.g. "id" IN (2,3)
and "id" NOT IN (2,3)
. However, you can use any other available technique to separate your features.
Step 2. Converting polygons into lines with 'Polygons to lines'
.
Step 3. Applying 'Line intersections'
where lines intersect themself. In addition exploit 'Delete duplicate geometries'
.
Step 4. Proceed further with 'Points to path'
.
Step 5. Apply 'Dissolve'
to your "bad" features.
Step 6. Use 'Delete holes'
Step 7. Here work with 'Split with lines'
between the result of Step 6 and Step 4.
Step 8. Because of the inconsistent attributes evoked on the previous steps some extra paces on how to achieve correct attributes are required. I will probably extract geocentroids from the result of the Step 7, then apply 'Join attributes by location'
and afterwards a basic 'Join'
between polygons with correct geometries and points with correct attributes.
Step 9. Merging "good" features with the result of Step 8 via 'Merge vector layers'
. And of course some basic attributes adjustment is a plus.
If you need straight lines for the step Step 4. then there are a couple of more steps have to be applied.
Step 4.1. Dissolve your paths with 'Dissolve'
.
Step 4.2. Attaining a straight line by means of a "Virtual Layer"
through Layer > Add Layer > Add/Edit Virtual Layer...
apply this query
SELECT setsrid(make_line(start_point(geometry), end_point(geometry)), #put your srid here)
FROM "Paths"
There are might be better options with lines simplification algorithms, did not check that yet.
P.S. IMHO this algorithm is better to implement in a Graphical Modeler.
References: