-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add function read obj lines. update readme and licenses
- Loading branch information
Showing
11 changed files
with
577 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
BSD 2-Clause License | ||
|
||
Copyright (c) 2008, Danil Kirsanov | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
|
||
1. Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
|
||
2. Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
OpenMesh is licensed under the 3-clause BSD License. See the LICENSE file for the complete license. | ||
|
||
/* ========================================================================= * | ||
* * | ||
* OpenMesh * | ||
* Copyright (c) 2001-2015, RWTH-Aachen University * | ||
* Department of Computer Graphics and Multimedia * | ||
* All rights reserved. * | ||
* www.openmesh.org * | ||
* * | ||
*---------------------------------------------------------------------------* | ||
* This file is part of OpenMesh. * | ||
*---------------------------------------------------------------------------* | ||
* * | ||
* Redistribution and use in source and binary forms, with or without * | ||
* modification, are permitted provided that the following conditions * | ||
* are met: * | ||
* * | ||
* 1. Redistributions of source code must retain the above copyright notice, * | ||
* this list of conditions and the following disclaimer. * | ||
* * | ||
* 2. Redistributions in binary form must reproduce the above copyright * | ||
* notice, this list of conditions and the following disclaimer in the * | ||
* documentation and/or other materials provided with the distribution. * | ||
* * | ||
* 3. Neither the name of the copyright holder nor the names of its * | ||
* contributors may be used to endorse or promote products derived from * | ||
* this software without specific prior written permission. * | ||
* * | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * | ||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * | ||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * | ||
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER * | ||
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * | ||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * | ||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * | ||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * | ||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * | ||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * | ||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * | ||
* * | ||
* ========================================================================= *\ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
Copyright (c) 2016 Wenzel Jakob <[email protected]>, All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
|
||
1. Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
|
||
2. Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
|
||
3. Neither the name of the copyright holder nor the names of its contributors | ||
may be used to endorse or promote products derived from this software | ||
without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
|
||
Please also refer to the file .github/CONTRIBUTING.md, which clarifies licensing of | ||
external contributions to this project including patches, pull requests, etc. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
include LICENSE | ||
include LICENSE.* | ||
include README.md | ||
include CMakeLists.txt | ||
graft src | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# Setup MeshUtility | ||
|
||
## TL;DR | ||
``` | ||
pip install numpy scipy networkx matplotlib openmesh | ||
conda install -c conda-forge igl meshplot | ||
git clone --recurse-submodules https://github.com/zishun/MeshUtility.git | ||
python setup.py install | ||
``` | ||
|
||
## Dependencies | ||
|
||
<details> | ||
<summary> | ||
<b> | ||
Python: | ||
</b> | ||
</summary> | ||
|
||
* numpy | ||
* scipy | ||
* networkx | ||
* matplotlib | ||
* openmesh | ||
* libigl Python bindings | ||
* meshplot: only for jupyter notebook | ||
|
||
</details> | ||
|
||
|
||
|
||
Install with | ||
```shell | ||
pip install numpy scipy networkx matplotlib openmesh | ||
conda install -c conda-forge igl meshplot | ||
``` | ||
|
||
<details> | ||
<summary> | ||
<b> | ||
C++: | ||
</b> | ||
</summary> | ||
* Eigen | ||
* OpenMesh | ||
* libigl | ||
* geodesic: Danil Kirsanov's implementation of MMP algorithm. | ||
* ShapeOp | ||
</details> | ||
|
||
All have been included here directly or as submodules. | ||
|
||
## Build | ||
1. Clone the repo: ```git clone --recurse-submodules https://github.com/zishun/MeshUtility.git``` | ||
2. ```python setup.py install``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
Author: Zishun Liu <[email protected]> | ||
Date: Feb 16, 2021 | ||
""" | ||
import numpy as np | ||
|
||
|
||
def write_obj_lines(fn, verts, lines): | ||
|
@@ -34,3 +35,37 @@ def write_obj_lines(fn, verts, lines): | |
for line in lines: | ||
for i in range(len(line)-1): | ||
f.write('l %d %d\n' % (line[i]+1, line[i+1]+1)) | ||
|
||
|
||
def read_obj_lines(fn): | ||
""" | ||
Read polylines from an obj file. | ||
Parameters | ||
---------- | ||
fn : str | ||
path to the output obj file | ||
Returns | ||
------- | ||
verts : numpy.array | ||
vertex coordinates (n x 3) | ||
lines : numpy.array (m x 2) | ||
edge segments | ||
""" | ||
verts = [] | ||
segs = [] | ||
with open(fn, 'r') as f: | ||
lines = f.readlines() | ||
for i in range(len(lines)): | ||
s = lines[i].split() | ||
if (len(s) == 0): | ||
continue | ||
if (s[0] == 'v'): | ||
verts.append([float(s[1]), float(s[2]), float(s[3])]) | ||
elif (s[0] == 'l'): | ||
L = list(map(lambda x: int(x), s[1:])) | ||
segs.extend([[L[i], L[i+1]] for i in range(len(L)-1)]) | ||
|
||
verts_mat = np.array(verts) | ||
segs_mat = np.array(segs)-1 # 1-indexed -> 0-indexed | ||
return verts_mat, segs_mat |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters