Metadata-Version: 2.1
Name: stl_obj_convertor
Version: 0.1.0
Summary: For converting .stl files to .obj and .obj files to .stl
Author: Shivam Kadukar
License: UNKNOWN
Platform: UNKNOWN
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Topic :: Education
Classifier: Topic :: Education :: Testing
Classifier: Topic :: Education :: Computer Aided Instruction (CAI)
Classifier: Topic :: Multimedia :: Graphics :: 3D Modeling
Classifier: Topic :: Multimedia :: Graphics :: Viewers
Classifier: Topic :: Scientific/Engineering
Classifier: Topic :: Text Processing
Requires-Python: >=3.9.0
Description-Content-Type: text/markdown
License-File: LICENSE

# .STL to .Obj and .Obj to .Stl convertor

:vulcan_salute: Hi, I am _Shivam Kadukar_. I am a self though programmer and this is my first project of making a python package.

## Table of Contents

- [Introduction](#pointright-introduction)
- [Installation](#pointright-installation)
- [TechnologiesUsed](#pointright-technologies-used)
- [Contributors](#pointright-contributors)
- [Development](#pointright-development)
- [FAQs](#pointright-faqs)

### :point_right: Introduction

This python package converts .stl file to .obj file format and vice versa.

#### .stl File

The STL file format provides two different ways of storing information about the triangular facets that tile the object surface. These are called ASCII encoding and binary encoding. In both formats, the information of each triangle is stored as:

- The coordinates of the vertices.
- The components of the unit normal vector to the triangle. The normal vector should point outwards with respect to the 3D model.

![.stl image](https://drive.google.com/file/d/1b7PQoW2i7TMO6fnQ1ZKLANFzlbRjNjVS/view?usp=sharing)

#### .stl file format

An ASCII STL file begins with the line

> _solid name_

where name is an optional string (though if name is omitted there must still be a space after solid). The file continues with any number of triangles, each represented as follows:

>_facet normal ni nj nk_
>\______ _outer loop_
>\_________ _vertex v1x v1y v1z_
>\_________ _vertex v2x v2y v2z_
>\_________ _vertex v3x v3y v3z_
>\______ _endloop_
>_endfacet_
> _endsolid name_

You can read more about .Stl files [here](https://en.wikipedia.org/wiki/STL_(file_format) ".stl file wikipedia")

#### .obj file

An OBJ file is a standard 3D image format that can be exported and opened by various 3D image editing programs. It contains a three-dimensional object, which includes 3D coordinates, texture maps, polygonal faces, and other object information

![.obj file](https://drive.google.com/file/d/1-n_sfsstoW0M4KcH51z1je9igcfJKTOf/view?usp=sharing)

#### .obj file format

An OBJ file may contain vertex data, free-form curve/surface attributes, elements, free-form curve/surface body statements, connectivity between free-form surfaces, grouping and display/render attribute information. The most common elements are geometric vertices, texture coordinates, vertex normals and polygonal faces:

Anything following a hash character (#) is a comment.
\# this is a comment

>\# List of geometric vertices, with (x, y, z [,w]) coordinates, w is optional and defaults to 1.0.
>_v 0.123 0.234 0.345 1.0_
>_v ..._
>_..._
\# List of texture coordinates, in (u, [,v ,w]) coordinates, these will vary between 0 and 1. v, w are optional and default to 0.
>_vt 0.500 1 [0]_
>_vt ..._
>_...
\# Li_st of vertex normals in (x,y,z) form; normals might not be unit vectors.
>_vn 0.707 0.000 0.707_
>_vn ..._
>_..._
\# Parameter space vertices in ( u [,v] [,w] ) form; free form geometry statement ( see below )
>_vp 0.310000 3.210000 2.100000_
>_vp ..._
>_...
\# Polygonal face element (see below)
>_f 1 2 3_
>_f 3/1 4/2 5/3_
>_f 6/4/1 3/5/3 7/6/5_
>_f 7//1 8//2 9//3_
>_f ..._
>_..._
\# Line element (see below)
>_l 5 8 1 2 4 9_

You can read more about .obj files [here](https://en.wikipedia.org/wiki/Wavefront_.obj_file ".obj File Wikipedia")

### :point_right: Installation

``` python
pip install stl-obj-convertor
```

### :point_right: How to use this convertor?

To use this convertor, run the following command

``` python
from stl-obj-convertor import convertor
```

You will have to give to inputs, The file you want to convert.
(ex - E:\\cctech\\assignment 1 stl_obj_convertor\\data\\cube.stl)

And, the location and the name of the converted file
(ex - E:\\cctech\\assignment 1 stl_obj_convertor\\data\\new.obj)

The convertor will check the file type, if the file is .stl type then it will run .stl to .obj conversion and if the file is .obj type then it will run .obj to .stl conversion. 

Note - Make sure the file to read i.e. the first input is either a .stl file or a .obj file any other file type will result in an error.

To run the test suite, run the following command

```python
python -m unittest
```

This command will run all the tests present in the test suite of this package.

### :point_right: Technologies used

This package does not requires any third party python libraries and functionalites to work except which comes with
python 3.0 or greater.

This version of the package uses regular expressions (_regex_) python module to search for patterns which are explained in .stl and .obj file formats.

#### :point_right: Development

[x] __Phase 1__: Created the converter using procedural code format and tested on simple geometries like a cube, etc.

[x] __Phase 2__: Recreated the convertor code in Oops format and tested on more complex geometries like a teapot, liver, ferrari, etc.

[x] __Phase 3__: Wrote Test Suite for the project and published as a python package. (version 1.0.0)

[] __Phase 4__: Level up your code to include a geometry finder which, for instance, returns the connected vertices from a given vertice. Various possible inputs & outputs are as follows:
  \- Input: vertice Output: vertices, edges, faces
  \- Input: edge Output: vertices, edges, faces
  \- Input: face Output: vertices, edges, faces

[] __Phase 5__: To conserve memory, use file streaming methods to convert from one format to another. Simultaneous read and write of the files.

### :point_right: Contributors

| Name         | Contact             |
|--------------|---------------------|
|Shivam Kadukar|shivamk2802@gmail.com|

### :point_right: FAQs

1) Does this convertor binary .stl file to .obj?
Ans - No, The current version of this convertor package can only converts ASCII .stl to .obj.
    But, the feature will be added in next version of the package.




