Skip to content

Commit

Permalink
Merge pull request #7 from alemuntoni/master
Browse files Browse the repository at this point in the history
Renamings
  • Loading branch information
alemuntoni committed Jul 27, 2020
2 parents 57c05ae + 96ae944 commit e5c04c9
Show file tree
Hide file tree
Showing 29 changed files with 161 additions and 425 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ If you get the error ```urllib.error.URLError: SSL: CERTIFICATE_VERIFY_FAILED```
After installing PyMeshLab through pip:
```
python
>>> from pymeshlab import pymeshlabserver as pymls
>>> md = pymls.MeshDocument()
>>> import pymeshlab
>>> md = ml.MeshSet()
```
To run the tests:
```
Expand Down Expand Up @@ -53,7 +53,7 @@ or Windows:
```
.\install\windows\build_pymeshlab.ps1
```
these script will place the pymeshlabserver module inside the `pymeshlab` folder of this repository.
these script will place the meshlab module inside the `pymeshlab` folder of this repository.

For more details, please take a look at the [Github Actions Workflows](https://github.com/cnr-isti-vclab/PyMeshLab/tree/master/.github/workflows) that build and run tests automatically in all the platforms.
...
Expand Down
4 changes: 2 additions & 2 deletions install/linux/build_pymeshlab.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

cd "$(dirname "$(realpath "$0")")"; #move to script directory

cd ../../src/pymeshlabserver
qmake pymeshlabserver.pro
cd ../../src/pymeshlab
qmake pymeshlab.pro
make -j4


4 changes: 2 additions & 2 deletions install/linux/build_pymeshlab_debug.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

cd "$(dirname "$(realpath "$0")")"; #move to script directory

cd ../../src/pymeshlabserver
qmake pymeshlabserver.pro CONFIG+=debug
cd ../../src/pymeshlab
qmake pymeshlab.pro CONFIG+=debug
make -j4


4 changes: 2 additions & 2 deletions install/macos/build_pymeshlab.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
cd $DIR #move to script directory

cd ../../src/pymeshlabserver
qmake pymeshlabserver.pro
cd ../../src/pymeshlab
qmake pymeshlab.pro
make -j4


4 changes: 2 additions & 2 deletions install/windows/build_pymeshlab.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ $DIR = Get-Location

cd $PSScriptRoot #move to script directory

cd ..\..\src\pymeshlabserver
cd ..\..\src\pymeshlab

qmake pymeshlabserver.pro
qmake pymeshlab.pro
jom -j4

#going back to original location
Expand Down
1 change: 1 addition & 0 deletions pymeshlab/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .meshlab import *
36 changes: 36 additions & 0 deletions pymeshlab/tests/sample/cube.obj
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
####
#
# OBJ File Generated by Meshlab
#
####
# Object cube.obj
#
# Vertices: 8
# Faces: 12
#
####
v -0.500000 -0.500000 -0.500000
v 0.500000 -0.500000 -0.500000
v -0.500000 0.500000 -0.500000
v 0.500000 0.500000 -0.500000
v -0.500000 -0.500000 0.500000
v 0.500000 -0.500000 0.500000
v -0.500000 0.500000 0.500000
v 0.500000 0.500000 0.500000
# 8 vertices, 0 vertices normals

f 3 2 1
f 2 3 4
f 5 3 1
f 3 5 7
f 2 5 1
f 5 2 6
f 7 6 8
f 6 7 5
f 4 7 8
f 7 4 3
f 6 4 8
f 4 6 2
# 12 faces, 0 coords texture

# End of File
3 changes: 2 additions & 1 deletion pymeshlab/tests/samples_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ def test_output_path():
import os
path_sample = samples_absolute_path()
output_path = path_sample + 'test_output/'
os.mkdir(output_path)
if not os.path.exists(output_path):
os.mkdir(output_path)
return output_path

26 changes: 13 additions & 13 deletions pymeshlab/tests/test_load_sample.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
import pytest
from pymeshlab import pymeshlabserver as pymls
import pymeshlab as ml
from . import samples_common

def test_load_meshes():
print('\n')
base_path = samples_common.samples_absolute_path()
md = pymls.MeshDocument()
ms = ml.MeshSet()

md.load_mesh(base_path + "bone.ply")
ms.load_mesh(base_path + "bone.ply")

print(md.number_meshes())
print(ms.number_meshes())

md.load_mesh(base_path + "airplane.obj")
ms.load_mesh(base_path + "airplane.obj")

print(md.number_meshes())
print(ms.number_meshes())

assert md.number_meshes() == 2
assert ms.number_meshes() == 2

md.set_current_mesh(0)
ms.set_current_mesh(0)

print(md.current_mesh().vertex_number())
print(ms.current_mesh().vertex_number())

assert md.current_mesh().vertex_number() == 1872
assert ms.current_mesh().vertex_number() == 1872

md.set_current_mesh(1)
ms.set_current_mesh(1)

print(md.current_mesh().vertex_number())
print(ms.current_mesh().vertex_number())

assert md.current_mesh().vertex_number() == 7017
assert ms.current_mesh().vertex_number() == 7017
96 changes: 0 additions & 96 deletions pymeshlab/tests/test_point.py

This file was deleted.

10 changes: 5 additions & 5 deletions pymeshlab/tests/test_save_sample.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import pytest
from pymeshlab import pymeshlabserver as pymls
import pymeshlab as ml
from . import samples_common

def test_save_meshe():
def test_save_mesh():
print('\n')
base_path = samples_common.samples_absolute_path()
output_path = samples_common.test_output_path()
md = pymls.MeshDocument()
ms = ml.MeshSet()

md.load_mesh(base_path + "bone.ply")
ms.load_mesh(base_path + "bone.ply")

md.save_mesh(output_path + "bone_saved.obj")
ms.save_mesh(output_path + "bone_saved.obj")
File renamed without changes.
16 changes: 5 additions & 11 deletions src/pymeshlabserver/main.cpp → src/pymeshlab/main.cpp
Original file line number Diff line number Diff line change
@@ -1,35 +1,29 @@
#include "pypoint.h"
#include "pyboundingbox.h"
#include "pymesh.h"
#include "pymeshdocument.h"
#include "pymeshset.h"

namespace py = pybind11;

std::string getDoc() {
return R"pbdoc(
PyMeshLabServer Module
PyMeshLab Module
----------------------
.. currentmodule:: pymeshlabserver
.. currentmodule:: meshlab
This module contains a set of classes to
compute batch MeshLab operations.
.. autosummary::
:toctree: _generate
Point
BoundingBox
)pbdoc";
}

PYBIND11_MODULE(pymeshlabserver, m) {
PYBIND11_MODULE(meshlab, m) {
m.doc() = getDoc();

pymeshlab::initPoint(m); //Point Class
pymeshlab::initBoundingBox(m); //BoundingBox Class
pymeshlab::initMesh(m); //Mesh Class
pymeshlab::initMeshDocument(m); //MeshDocument Class
pymeshlab::initMeshSet(m); //MeshDocument Class

#ifdef PYMESHLAB_VERSION
m.attr("__version__") = PYMESHLAB_VERSION;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
#include "extendedmeshdocument.h"
#include "meshset.h"

#include "pymeshlabcommon.h"

namespace py = pybind11;

pymeshlab::ExtendedMeshDocument::ExtendedMeshDocument() :
pymeshlab::MeshSet::MeshSet() :
MeshDocument(), globalRPS(), pm()
{
QDir dir(QString::fromStdString(pymeshlab::getPluginsPath()));
pymeshlab::QDebugRedirect qdbr; //redirect qdebug to null, just for this scope
pm.loadPlugins(globalRPS, dir);
}

void pymeshlab::ExtendedMeshDocument::loadMesh(const std::string& filename, py::kwargs kwargs)
void pymeshlab::MeshSet::loadMesh(const std::string& filename, py::kwargs kwargs)
{
QFileInfo finfo(QString::fromStdString(filename));
if (!finfo.exists()){
Expand All @@ -25,7 +25,7 @@ void pymeshlab::ExtendedMeshDocument::loadMesh(const std::string& filename, py::
if (pm.allKnowInputFormats.contains(extension)){
MeshIOInterface* plugin = pm.allKnowInputFormats[extension];
int mask = 0; //todo: use this mask
RichParameterSet rps; //todo: use rps (example: needs this)
RichParameterSet rps;
plugin->initPreOpenParameter(extension, QString::fromStdString(filename), rps);
plugin->initOpenParameter(extension, *(this->mm()), rps);

Expand All @@ -45,15 +45,15 @@ void pymeshlab::ExtendedMeshDocument::loadMesh(const std::string& filename, py::
}
}

void pymeshlab::ExtendedMeshDocument::saveMesh(const std::string& filename, pybind11::kwargs kwargs)
void pymeshlab::MeshSet::saveMesh(const std::string& filename, pybind11::kwargs kwargs)
{
QFileInfo finfo(QString::fromStdString(filename));
QString extension = finfo.suffix().toLower();

if (pm.allKnowOutputFormats.contains(extension)){
MeshIOInterface* plugin = pm.allKnowOutputFormats[extension];
int mask = 0; //todo: use this mask
RichParameterSet rps; //todo: use rps (example: needs this)
RichParameterSet rps;
plugin->initSaveParameter(extension, *(this->mm()), rps);

updateRichParameterSet(kwargs, rps);
Expand All @@ -69,10 +69,25 @@ void pymeshlab::ExtendedMeshDocument::saveMesh(const std::string& filename, pybi
}
}

void pymeshlab::ExtendedMeshDocument::updateRichParameterSet(const pybind11::kwargs& kwargs, RichParameterSet& rps)
void pymeshlab::MeshSet::applyFilter(const std::string& filtername, pybind11::kwargs kwargs)
{
if (kwargs){

}

void pymeshlab::MeshSet::updateRichParameterSet(const pybind11::kwargs& kwargs, RichParameterSet& rps)
{
if (kwargs){
for (auto p : kwargs){
std::string key = p.first.cast<std::string>();
RichParameter* par = rps.findParameter(QString::fromStdString(key));
if (par){

}
else {
std::cerr << "Warning: parameter " << key << " not found\n";
//todo: manage python exception?
}
}
}
}

Expand Down
Loading

0 comments on commit e5c04c9

Please sign in to comment.