Processing Geometry Suite (PGS) library

Hello everyone!

I’ve recently started exploring the fantastic Processing Geometry Suite (PGS) library and I’m really impressed by its capabilities. Right now, I’m trying to get the Mesh Smoothing example up and running, but I could use a bit of guidance.

I was able to successfully run the examples included in the project folder, but I noticed that some examples mentioned on the GitHub page—like Mesh Smoothing—aren’t included there. If anyone could help me understand how to access these additional examples or point me in the right direction to get Mesh Smoothing working, I’d be very grateful.

Thanks in advance for any help or tips you can share!

GitHub (library): GitHub - micycle1/PGS: Processing Geometry Suite

Mesh Smoothing Example:

Library author here.

Library structure is quite simple – all the illustrations on the Github readme live under their respectivePGS_ code file (“Meshing” –> PGS_Meshing).

You can see details about methods in the Javadocs ( PGS_Meshing (Processing Geometry Suite 2.0 API) ) or in an IDE.

So the method you’re after isPGS_Meshing.smoothMesh(...).

2 Likes

Hi Micycle

Thank you so much for your reply and for your work!

I gave it a try, it should be something like this?

Thank you!

import processing.javafx.*;
import micycle.pgs.*;
import micycle.pgs.PGS_Coloring.ColoringAlgorithm;
import java.util.List;
import org.tinfour.common.IIncrementalTin;

String leafPolyline = “ai`tvCagmtmAojbVgpiw@oijDucv[b__AoflYp`xn@{xq|B|hbNsheT|pcTqyfP\~es}@mxpmxp\\|rcHm_tK|lbGchfp@sriAuys\[u`oFutiYqdgKqypUe_rOieiPmn}Po{{IykyQywuCykrThd|@ulhYf_~GcchiAd~yg@q}yhA~hgq@iuovBf}oiBi~iSzniC{oqi@aosVs`cS{|nCklwUzhrC_qu|Bh@ogshAl}{@ogshAl`ai@}yhfB`sza@}hsY_yRao}YalcKyezHygiPv_lCsv}WjjlOkyk\\vqgbAgocoA|fmc@ymcy@f\~qVw\~vs@\~scFuatc@d_tGejtLjqgrBkusmA|dqaAslne@p{eJyrbQc_hAiazS}i|\]yn{k@}saCe}fRjwbFm\_\~Qbclc@i\~sg@zxmDcdaRozcFyg{Sgdpg@*qxt@`cbAa`sWdc{Kgq|TdrcS_viR\~amXit_K||daCkz{\\hjmXoazI`tcH{fbOnf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Qe{mZiywpCrqwDg_vgA_jsCwx~g@f|_@_va|AcmsHajhR}hsj@up}k@m_mI_uzT}f_H_f}v@mtjJscyQ{hyd@oiuTqonKki_Nc}wf@eru~Aa{mPky}RcqhWulqIyc_~@geyDelsR}xtFklaK_v~MsedE}ajWsciBetz~@sq|F_lze@eyjh@qlglAil_Bap~Ul}yEs~weAeb~Eec_Sgp`i@mqvYslyK_vbLu|jFqjpPwprAmi|W|ocHqpmzB}c\~AgpdY}hsHux\~RobsP{xmRyifTabiLscaVigkEguqoBfbdFof\~f@miyFakdMul|PwewBylzUt\`o\\k|y_Bndob@wqqqCz{nS{euv@|mnh@om|yAbzxAaimSwobCgtoR”;
PShape leaf;
PShape meshShape;

void setup() {
size(1000, 1000, FX2D);
smooth();

leaf = PGS_Conversion.fromEncodedPolyline(leafPolyline);
leaf = PGS_Transformation.translateCentroidTo(leaf, width / 2f, height / 2f);

meshShape = meshColorShape(leaf);
}

void draw() {
background(0, 0, 40);

// Apply mesh smoothing with animated iterations
int smoothIterations = (int)map(sin(frameCount \* 0.02), -1, 1, 1, 8);
PShape smoothedMesh = PGS_Meshing.smoothMesh(meshShape, smoothIterations, true);

// Display the smoothed mesh
shape(smoothedMesh);
}

public void mouseMoved() {
meshShape = meshColorShape(leaf);
}

PShape meshColorShape(PShape shape) {
List points = PGS_PointSet.poisson(0, 0, width, height, 45 + mouseX/33f, 10);
IIncrementalTin mesh = PGS_Triangulation.delaunayTriangulationMesh(shape, points, true, 1, true);

String[ ] palette;
if (mouseX > width/2) {
meshShape = PGS_Meshing.urquhartFaces(mesh, true);
palette = new String[ ] { “#563d7c”, “#0096d8”, “#f4e361”, “#f24679” };
} else {
meshShape = PGS_Meshing.edgeCollapseQuadrangulation(mesh, true);
palette = new String[ ] { “#07224f”, “#ed361a”, “#fc8405”, “#f7c72a” };
}

// Simple coloring without PGS_Coloring
if (mouseX > width/2) {
PGS_Conversion.setAllFillColor(meshShape, color(86, 61, 124, 150));
} else {
PGS_Conversion.setAllFillColor(meshShape, color(237, 54, 26, 150));
}
PGS_Conversion.setAllStrokeColor(meshShape, color(255), 1);
return meshShape;
}

Yeah looks alright.

Another simple example:

  var v = PGS_Voronoi.innerVoronoi(PGS_Morphology.simplify(leaf, 4), PGS_PointSet.poisson(0, 0, width, height, 50, 0));
  v = PGS_Meshing.smoothMesh(v, mouseX/2, true);
  shape(v);
2 Likes

Awesome, thank you Micycle!