Coder Social home page Coder Social logo

python-admesh's Introduction

About this release and repository:

ADMesh was released as an application in 1995/96. Not much happened since then. As the code of this project might bring use for others, this "fork" was created to provide a shared library. Once done that, I've collected lots of bugfixes from the world around us.

No further development will be done, but bugs will be resolved, if possible.

Don't patch this project downstream but use this code, so all can benefit from the changes. Pull requests are welcome, but be sure to generate no warnings.

Grab the 0.98.5 tarball: https://github.com/admesh/admesh/releases/download/v0.98.5/admesh-0.98.5.tar.gz

About ADMesh:

ADMesh is a program for processing triangulated solid meshes. Currently, ADMesh only reads the STL file format that is used for rapid prototyping applications, although it can write STL, VRML, OFF, and DXF files.

Additional information regarding the underlying algorithms of ADMesh can be found in Anthony Martin's Masters Thesis available from here:

http://www.varlog.com/admesh-htm/ADMeshThesis.zip

Features:

  • Read and write binary and ASCII STL files
  • Check STL files for flaws (i.e. unconnected facets, bad normals)
  • Repair facets by connecting nearby facets that are within a given tolerance
  • Fill holes in the mesh by adding facets.
  • Repair normal directions (i.e. facets should be CCW)
  • Repair normal values (i.e. should be perpendicular to facet with length=1)
  • Remove degenerate facets (i.e. facets with 2 or more vertices equal)
  • Translate in x, y, and z directions
  • Rotate about the x, y, and z axes
  • Mirror about the xy, yz, and xz planes
  • Scale the part by a factor
  • Merge 2 STL files into one
  • Write an OFF file
  • Write a VRML file
  • Write a DXF file
  • Calculate the volume of a part

ADMesh outputs the following statistics after processing:

================= Results produced by ADMesh version 0.98.5 =================
Input file         : sphere.stl
File type          : Binary STL file
Header             : Processed by ADMesh version 0.98.5
============== Size ==============
Min X = -1.334557, Max X = 1.370952
Min Y = -1.377953, Max Y = 1.377230
Min Z = -1.373225, Max Z = 1.242838
========= Facet Status ========== Original ============ Final ====
Number of facets                 :  3656                3656
Facets with 1 disconnected edge  :    18                   0
Facets with 2 disconnected edges :     3                   0
Facets with 3 disconnected edges :     0                   0
Total disconnected facets        :    21                   0
=== Processing Statistics ===     ===== Other Statistics =====
Number of parts       :     1        Volume   :  10.889216
Degenerate facets     :     0
Edges fixed           :    24
Facets removed        :     0
Facets added          :     0
Facets reversed       :     0
Backwards edges       :     0
Normals fixed         :     0

There are two different algorithms used for fixing unconnected facets. The first algorithm finds an unconnected edge, and then checks nearby within a given tolerance for another unconnected edge. It then fixes edges within tolerance. Some meshes can be completely fixed just using this method. If there are still unconnected facets after this "nearby check" has been done, then a second algorithm is used. This algorithm just fills any holes in the mesh by adding facets until all of the holes are filled. Using these two algorithms, almost any imperfect STL file can be "fixed" 100% so that there are 0 unconnected facets. Whether the resulting mesh is what you really want is another question since there is no way for ADMesh to add information that isn't there.

At this point ADMesh is only command-line driven and has no windowing capabilities. This should make it extremely easy to port to any UNIX-like system, and it shouldn't have any problems compiling on Windows NT, and some people have had success compiling it under DOS or Windows using DJGPP.

ADMesh was developed on a 486/66 with 16Mb running the Linux operating system. It has also been compiled and run on the following systems: SunOS 4.1.3 IRIX 5.2 Please let me know about successes or failures with other systems.

On my Linux system with 16Mb of memory, I can easily process files that have up to about 200,000 facets. Files larger than this can be processed, but the system begins to slow down significantly due to swapping. A system with more memory will be able to process greater numbers of facets more easily. Following are some indications of process times:

  • 40,000 facets: 10 seconds
  • 80,000 facets: 20 seconds
  • 160,000 facets: 50 seconds
  • 320,000 facets: 13 minutes (heavy swapping occurred)

Note that those times were calculated around 1996.

ADMesh is free but copyrighted software. It is distributed under the terms of the GNU General Public License (GPL). Details of the GPL are in the file COPYING that comes with the ADMesh software package.

python-admesh's People

Contributors

hroncok avatar sumpfralle avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

python-admesh's Issues

Mac - problem with installation

Hi,
i had a problem with installation on my mac. It looks like method get_header from autogen.py doesn't work with clang (it could not find cc1 command).

0.98.4 fails to compile

There is a problem with compiling the latest version. It fails with the following message:

cythoning admesh.pyx to admesh.c

Error compiling Cython file:
------------------------------------------------------------
...

    def __next__(self):
        if self._iterindex >= len(self):
            raise StopIteration
        self._iterindex += 1
        return self._c_stl_file.facet_start[self._iterindex - 1]
                                          ^
------------------------------------------------------------

admesh.pyx:41:43: Cannot convert 'stl_facet' to Python object

Error compiling Cython file:
------------------------------------------------------------
...

    def facet_stats(self, facet, first):
        """stl_facet_stats"""
        if not self._opened:
            raise AdmeshError('STL not opened')
        stl_facet_stats(&self._c_stl_file, facet, first)
                                               ^
------------------------------------------------------------

admesh.pyx:419:48: Cannot convert Python object to 'stl_facet'
building 'admesh' extension

Data input: parse STL and facet import

This is a question and/or a feature request.

Currently I use python-admesh for loading a mesh from a named file:

admesh.Stl("filename.stl")

Question 1: read from stream

In order to support other input methods (e.g. download via http), I would like to read data from a stream (i.e. something that supports the "read" method):

# fictional code
open_file = open("filename.stl", "rb")
mesh = admesh.Stl()
mesh.read_from(open_file)

Question 2: add facets manually #13

Additionally I would like to export a mesh as an STL file. This mesh consists of facets, that I am using (and processing) inside of my application. Thus I would appreciate something like this:

# fictional code
mesh = admesh.Stl()
for vertices, normal in my_facets:
    mesh.add_facet(vertices, normal)

Both approaches are currently not possible with python-admesh - correct?
Would these operations be within admesh's scope? If yes: do you have suggestions, how to implement these?

Python3 admesh issue

Python2 binding is working fine. The problem is with python3:

python3 -c'from admesh import Stl; stl = Stl("block.stl")'
Traceback (most recent call last):
File "", line 1, in
File "admesh.pyx", line 21, in admesh.Stl.cinit (admesh.c:1394)
File "admesh.pyx", line 25, in admesh.Stl.open (admesh.c:1466)
TypeError: expected bytes, str found

block.stl is from admesh source tarball

https://github.com/admesh/admesh/blob/master/block.stl

Thanks

get_size() and calculate_volume() methods return None

Hi,

I installed python-admesh 0.98.2 on Mac OS X Yosemite. I tried to get the size and volume of an still file from python but all I get is None
I ran following code in python:

    from admesh import Stl
    stl = Stl('test/block.stl')
    print stl.get_size()
    print stl.calculate_volume()

However I get the stats when I run admesh test/block.stl no problem.
Am I missing something here?

Thanks

Deepcopy doesn't work

Attempting to make a deep copy and modify it

from copy import deepcopy

stl = admesh.Stl('hellskull.stl')
stl_copy = deepcopy(stl)
stl_copy.rotate_z(5)

results in admesh.AdmeshError: STL not opened.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.