I am trying to learn sfepy. To that effect I want to solve the differential equation
On a triangle domain (2D).
There';s 2 things I don't understand from reading the docs.
How do I specify a single triangle mesh? The code seems to assume you already have the mesh file but it does not provide a link to it so I don;t know hwo to cosntruct my data.
I am having a ahrd time learning how to map the equation onto sfepy's syntax. i.e. I don;t really know how to specify the problem using the library even after followignt he tutorial.
I have the solution to your problem 1.
The example script linear_elastic_interactive.py, does mention the path to the mesh used on line 35, like this mesh = Mesh.from_file(data_dir + '/meshes/2d/rectangle_tri.mesh') . And the tutorial also mentions that "This file should be run from the top-level SfePy source directory so it can find the mesh file correctly". So if you navigate the source code, you can find the mesh here: link
Related
I have a network of polylines and point data that I am trying to split out into individual line segments based on a given starting point of the network. I know that this can be done using the ArcGIS network analyst extension but I am trying to use open source software. I think this can be done using Shapely Linear Referencing methods but I'm unsure. Any help would be greatly appreciated! I've included a diagram below of what I'm talking about.
I have made a Python script which takes a mesh and the index of a vertex to apply an operation. Unfortunately, Trimesh -the library I use to process the mesh- does not have an option to select an vertex by clicking on it.
Is it possible to visually select an vertex on the mesh, get the identifier on on that vertex and pass it to another script? Is it worth using a 3rd party program like Meshlab or Blender to select that input or am I missing a more obvious route?
Trimesh does not have a GUI, just some rendering tools. However, it has tons of features to programatically find vertices of interest if you are able to come up with rules or characteristics of it. The docs, source code examples, and issues all have useful implementations to browse through.
This borders on not answering "the question" but you do mention using third party tools as questions within your explanation, so...
I didn't get to implementing this in trimesh / Python. I used Meshlab to select the vertices I wanted, and manually copied the indices over to Python variables. Trimesh will re-order vertices as part of its optimization process. So if you go this route, be sure to use process=False to maintain vertex order. E.g.:
trimesh.load('./my.obj', process=False)
I have an .stl file and I want to write a python script to scale if. So for example, if I have a file with a cube of dimensions 2x2x2mm, and I have my scale set to 10, the script should spit out an stl file with a cube of dimensions 20x20x20mm.
I searched and found numpy-stl library for modifying stl files. However, I can't seem to find any function that scales an .stl. Can someone point me in the right direction as what to use?
I know this is an old question, but you should be able to directly modify the mesh.x, mesh.y and mesh.z attributes to accomplish this.
I also stumbled across this post while trying to get an answer to the same problem. I assume you are using numpy-stl.
My solution was to create a rotation matrix R using the scaling parameter instead of rotation angles and then use mesh.rotate_using_matrix(R,point=centroid).
Seems to work for me.
To frame this question: I am a complete beginner in terms of 3d rendering, and I would like to get my feet wet.
My goal is to create a command-line script (ideally in Python) which takes some kind of 3d model file (e.g. a sphere), maps a texture onto it, and outputs the result as an image file. That is, I would like my program to essentially be able to "do" the following:
From my reading, this appears to be something known as "uv mapping", but almost everything I've found on the subject in on how to do this using Blender, and I would prefer avoiding this: in a 2d analogy, it seems to me that Blender is like Photoshop where I'm looking for something like ImageMagick. Beyond that, I haven't been able to find much.
The closest I have found is this other stackoverflow question:
uv mapping works bad on low resolution (warning: lot of images)
But I don't quite understand what's going on there, because it doesn't import a 3d model at all -- it is my [perhaps mistaken?] understanding that EXR is a 2d image format.
Any guidance on how to get started would be greatly appreciated!
I want to develop a 3D file viewer in kivy and python that reads and displays .asc mesh files of the format:
x1,y1,z1
x2,y2,z2
........
xi,yi,zi
What I have thought so far is to use a method similar to beginShape() of Processing so as to begin drawing a 3D shape then use a for-loop to append each point respectively.
I have also found that kivy example which parses .obj files and then displays them. Do you have any ideas on how can I make a similar ascparser and try to display my files?
Any help is greatly appreciated
I have also found that kivy example which parses .obj files and then displays them. Do you have any ideas on how can I make a similar ascparser and try to display my files?
Your best strategy at the moment is probably to read the objparser and try to understand what it is doing. The important thing is building a list of points and normals, which are passed to opengl via a Mesh with a custom vertex_format and custom shaders. In principle it wouldn't be very hard to do the same thing for your own filetype just by comparison with the .obj code, though you will need some understanding of what's going on (you can read about opengl and read the kivy source, if you haven't already) to make significant changes.
This is really an advanced topic right now, Kivy has very few pre-built wrappers to 3d opengl rendering. The backend is fully capable (so the 3d rendering example isn't that complex, for instance), but you probably do need some understanding of what's going on to accomplish things like your own task.
There are also a few other examples of 3d rendering in Kivy, which you might find helpful. nskrypnik has several repositories doing just this (see kivy-trackball, kivy-3dpicking, kivy-rotation3d), and seems to have begun implementing a proper 3d api in the kivy3 repo, though this is not complete and I suggest it as something you can learn about by reading, not something that can necessarily do what you want right now. The other nice example I've seen is a 3d inspector POC by tito, though it's just a proof of concept and not a polished product.