Help using Geomerative and SVGs
in
Contributed Library Questions
•
2 years ago
Hello,
this being my first post here, i hope the matter won't sound too noobish and the problem will interest quite a few people. My programming knowledge isn't really advanced, so i guess i could say i'm an advanced noob for now :)
I'm currently working on an architectural project that involves distributing thousands of points within a shape (which is the shape of the ceiling of a building). Those points have to be organized according to a certain grid and avoid certain zones within that shape (seeing as they can only exist "on" the ceiling and can't exist where lights and fire extinguisher are).
I managed to build a quick mockup using a jpg as a map and having each pixel represent one element of the grid.This works pretty well, however i need to gain more precision and more flexibility.
I'd like to be able to load the svg file of the plan so as to be able to access the layer id of each path and have the points organise according and avoiding those paths with different rules per layers/paths. I believe this is possible with the Geomerative lib, as this is the one lib i've found that offers the more access to svg data and geometries. I've been looking into the tutorials and the example files to understand how that library works. I believe I grasped the concepts, but can't seem to understand how access data that is in the RShape where the SVG is loaded.
I do then manage to get access to every point information, but unfortunately only their x,y coordinates by using an RPoint[][] that contains all the paths and then going through each point in there. However those are ALL the points in my drawing and i'd like to be able to sort the paths and points.
I'd really be stocked if I could get some help on that if anyone fancies. I have spent the whole day looking for information and examples that would be close to what i'm trying to do to no avail.
Here's the very simple current code i'm at, but i'm very stuck, as i can't get further, until i access the SVG layer data.
- import geomerative.*;
- RShape shp;
- RPoint[][] pointPaths;
- void setup()
- {
- size(800,800);
- frameRate( 5 );
- smooth();
- //init Geomerative
- RG.init(this);
- shp = RG.loadShape("filename.svg");
- shp.centerIn(g);
- pointPaths = shp.getPointsInPaths();
- }
- void draw()
- {
- background(255);
- // center the svg
- translate(width/2, height/2);
- //draw the svg
- RG.shape(shp);
- // for each point access their info
- for (int i = 0; i<pointPaths.length; i++)
- {
- pointPaths[i][1].print();
- }
- }
1