STL Faces and Edges - openscad

Is it possible in OpenSCAD to access faces, normals, edges and connectivity of STL geometry?
I'd like to modify the STL geometry by iterating over each face and modifying it based on some local criteria.
If this is not possible in OpenSCAD, recommendations for an open tool or library are welcomed.
Thanks.

OpenSCAD does not support access to the geometry in that way yet. I would suggest a library like JSSTL to access the facets, although that will depend on the language you would like to implement your app in.

Related

Best Way to approach a 3D customisable Globe in Flutter?

following question:
I'm currently working on a Travel App and I thought of the idea of implementing an 3D Globe that can be rotated by the user. I thought of the Globe as a basic White Sphere with the borders of the countries visible as a stroke. All countries that have been visited should be filled with a color.
I thought of implementing it with the unity widget, but I'd like to maintain a lightweight feeling.
Is there a way to emulate js or WebGL?
What do you think is the best way to approach this?
Thank you for your time
Linus
You can use webview_flutter, I played with it a little bit to display planet models in javascript library three.js. Thanks to it you can use it like standard js instance of it with only one drawback that I didn't try to solve: I was unable to run it in browser mode as Flutter needs to emulate js itself by platform speciffic way. There is option to load js/html code from local assets but then you will not be able to load models in js directly as you will face cors policy restrictions, then the only way is to pass models as json from flutter code. It works pretty well, supports two way communication between js and flutter so you can also add events to model etc.

What happened to this Mapbox Tile image?

So I'm attempting to get Mapbox working with my Leaflet implementation (using React Leaflet), and my spidey sense is telling me something is off.
The URL:
https://api.mapbox.com/v4/mapbox.mapbox-streets-v8/11/568/825#2x.jpg?access_token=pk.eyJ1IjoiamFtaWxsZXI2MTkiLCJhIjoiY2t3Y3JnbG5uMzZ2MzJ1bmhyaHhpczJpcCJ9.3X8OkNioN_C8CN15YPmDDQ
Note: I created the access_token used above for this SO question, and will be deleted soon. So the link may not work when you see this, which is why I used SO's handy dandy image upload!
I assume this has something to do with how the tile coordinates and/or zoom is being calculated, but really, I don't have a damn clue in the world.
Using mapbox.mapbox-streets-v4 as the tileset_id produces results that are better, but still bad. I haven't yet been able to load a stylesheet either...
What gives?
As it turns out I was correct in my hunch that it had something to do with how the tiles were being generated by Leaflet. And while I'll probably never know the specific reasons behind it, I was able to solve it. The secret sauce ended up being mapbox-gl-leaflet.
I threw together a super simple example on Code Sandbox showing the successful implementation of Mapbox tiles as a React component within React Leaflet. It's pretty snazzy, IMO, even if you have to import a few hundred different packages (doubly if using TS) to make it all work 😕
https://codesandbox.io/s/sharp-payne-m3hll
NOTE: To see the codesandbox link working, you'll need to supply your own Mapbox API key. The API key from above won't work (even if it was still valid, which it may or may not be depending on how much I care to do anything about it...)
The mapbox.mapbox-streets-v11 tileset from Mapbox is originally intended to be used as vector data, e.g. with Mapbox Vector Tiles API : https://docs.mapbox.com/help/glossary/vector-tiles-api/
The only difference with your URL is the requested format mvt (instead of jpg). And no #2x resolution modifier.
What may be confusing is that the vector tilesets can also be requested as raster, by specifying a raster format like jpg or png through Mapbox Raster Tiles API https://docs.mapbox.com/help/glossary/raster-tiles-api/.
Mapbox server then generates an image from the vector data. But in the case of the streets tileset, it has a lot of data in hand, and it renders all of it, making it appear messed up.
Mapbox provides 5 default tilesets (https://docs.mapbox.com/studio-manual/reference/tilesets/), some of them are raster only (typically Satellite mapbox.satellite) while others are originally vector, but can also be generated as raster (Streets, Terrain, Terrain-RGB/elevation, Traffic).
Unfortunately Leaflet does not handle vector data built-in. If you really need to use vector data, you have to use plugins like Leaflet.VectorGrid or Mapbox GL Leaflet, or another switch to another mapping library.

Cartoon style map

Our university has had an agency create a very pretty printed map* for a special purpose.
In the early stages of the project, I suggested that they make the map in true proportions, and in vector format, so that a digital version might be more easily made in future. The future is looming, and it's looking like I'm going to have to come up with something!
I've begun toying with ways of doing this. One option is to make a suitable base layer and add the buildings as individual svg files - it sounds like a LOT of work.
I wondered if anyone had suggestions about how I should approach this. Is mapbox even the right tool?
* apparently, I don't have the 'reputation' required to embed an image!
There have been a number of impressive cartonish and artistically stylized maps made with Mapbox GL JS and Mapbox Studio Classic.
https://www.mapbox.com/blog/pencil-drawn-style/
http://dessine-moi-une-ville.makina-corpus.net/#15/43.5933/1.4514
http://a.tiles.mapbox.com/v3/aj.Sketchy2/page.html#6/33.962/-6.405
https://www.mapbox.com/gallery/#map-7
https://www.mapbox.com/gallery/#map-20
I've begun toying with ways of doing this. One option is to make a suitable base layer and add the buildings as individual svg files - it sounds like a LOT of work.
This sounds like the one good way to go about adding individual building illustrations. Other options include using one or many image sources.
Good luck! Can't wait to see what you make!

How do I use ICC profiles on the iPad/iPhone?

right now I'm implementing a basic PDF viewer, and I came across the problem that some files are displayed with wrong (too intense, too bright) colors for text and vector graphics when rendered on the device and in the simulator.
Since I have access to calibration hardware, I could create ICC profiles for the device with test data.
The only question I have now: Is there a way to use ICC profiles to aid the rendering of PDF data on the iPad's screen?
If someone wonders: I plan to target iOS 4.x on the iPad and possibly on the iPhone.
Thanks in advance!
I worked around this issue (of having PDFs render in different colors than pre-computed preview bitmaps) by generating all PDFs using sRGB (you can select this, for instance, in InDesign export settings).
Right now, iOS lacks a system-wide CMS like ColorSync.
What I would try to do is:
calibrate your iPad,
calculate the color transform from the ICC profile your calibrator gives you,
run that transform on the color values you display from the PDF data.
See where that gets you. There may be a lot of variance across the displays you are targeting (maybe different manufacturer batches == slightly different whitepoints, or something) but maybe that will assuage your problem.
... Which, since unlike some people, you're not defining that problem for 'perfect color reproduction in iOS' and as such, your problem is most likely quite solvable.
Bruce Lindbloom has a lot of color-conversion math (constants, definitions, etc) and his site is a great place to start, for this sort of thing.
http://www.brucelindbloom.com/
Since most Cocoa devs can depend on ColorSync, I haven't run across any relevant color transformation examples in Obj-C. There are plenty in Python that I know of -- python-colormath is a good example, with legible implementations of many of Mr. Lindbloom's matrices and transformations:
http://code.google.com/p/python-colormath/
... you may also be able to embed OpenCV in your iOS project. OpenCV has native matrix data structures and other useful things for you, if you are doing this kind of thing:
http://www.cs.iit.edu/~agam/cs512/lect-notes/opencv-intro/
This is an area of interest for me, so let me know if you'd like me to elaborate on any of what I've provided. Good luck.

Visualize Friend of a Friend (foaf) graph

I wrote a script to export twitter friends as foaf rdf description. Now I'm looking for a tool to visualize the friend networks. I tried http://foafscape.berlios.de/ but for 300+ Nodes it is really slow and does a bad job on auto formatting.
Any hints for good graph visualization tools? It's ok if they do not support foaf directly, but they should be able to use images for graph nodes and be able to display large graphs. Linux support would be nice.
Oh, and I'm searching for an interactive tool where I can move nodes by hand.
Update: Thanks for your input. I know graphviz and for static images it is really great. But for large datasets I need to be able to select nodes and highlight all neighbours.
Prefuse looks great: http://prefuse.org/gallery/graphview/
trough prefuse I found vizster, which is exactly what I search (just need to find some sourcecode) http://jheer.org/vizster/
perhaps the prefuse visualization toolkit might help you. It's based on Java and has many sample apps including a graph viewer.
You could try Graphviz. It runs on Linux, Windows and Mac OS X and it will generate an image (PNG, PS, etc) of the graph. You will have to transform your foaf data into its own custom language, but it's pretty easy to learn.
I don't know of any program that auto-generates graph visualizations and allows you to interactively adjust nodes, but Graphviz is a really popular tool for graph visualization. It can export to SVG so you can edit the result in your favorite vector graphics editor.
As recommended by other posters, definitely Graphviz. It takes an input file, let's call it foaf.dot, in the following format:
graph G {
"George Formby" [shape=custom, shapefile="file:formby.png"];
"Michael Jackson" [shape=custom, shapefile="file:jackson.png"];
"George Formby" -- "Michael Jackson";
"Fred Flinstone" -- "Michael Jackson";
"Michael Jackson" -- "Steve McQueen";
}
Note that this file describes an undirected graph (hopefully your friendships are reciprocal). The syntax for directed graphs is similar.
In order to output your graph to a pdf file (assuming that you have already installed graphviz) run the following command
dot -Tpdf foaf.dot > foaf.pdf
Graphviz supports a number of output formats other than pdf, see its documentation for details.
I find that the 'dot' program usually provides the best output results, however graphviz contains a total of 5 layout programs. From the documentation:
dot - filter for drawing directed graphs
neato - filter for drawing undirected graphs
twopi - filter for radial layouts of graphs
circo - filter for circular layout of graphs
fdp - filter for drawing undirected graphs
I previously recommended Graphviz, but thought I should add another recommendation now that I have used Gephi, a newer tool than a lot of the stuff here. It's a very powerful interactive graph exploration tool which I have found much more usable and much faster than a lot of the alternatives here.
Try using Google Social Graph. In one of the talks at dConstruct08 last week there was a social graph showing the friend connections of Robert Scoble.
http://code.google.com/apis/socialgraph/
http://dconstruct.org/2008
If you're using Java, you could use JGraph.
I know Adobe Flex has a few graph visualization components out there, and of course that would enable the app to run on Flash which has an excellent penetration rate into your potential userbase. I'd Google up the Flex SpringGraph component, and check that out. There are a ton of graphing components in the wild for Flex, both paid and free versions.
Just one SpringGraph off the top of my head:
http://www.adobe.com/cfusion/exchange/index.cfm?event=extensionDetail&extid=1048510
check this forum: http://goosebumps4all.net/34all/bb/forumdisplay.php?fid=28
for some flare examples, there is a friend of a friend graph around there.
have you tried the Python-based IDE NodeBox (1.0)? That's what I used to generate these: http://givememydata.com/#images
vizster looks cool though, I'll check out that.
For large graphs, Gephi (http://gephi.org/) is very popular. It is highly customisable, with lots of layout and presentation options.