fix issue on save custom attribute on ply, add pssibility to setDescription on python function

This commit is contained in:
alemuntoni 2021-10-25 13:53:50 +02:00
parent 77097029db
commit 3ac31eaaa0
4 changed files with 28 additions and 5 deletions

View File

@ -57,6 +57,11 @@ QString pymeshlab::Function::description() const
return funDescription;
}
void pymeshlab::Function::setDescription(const QString& newDescription)
{
funDescription = newDescription;
}
unsigned int pymeshlab::Function::parametersNumber() const
{
return parameters.size();

View File

@ -45,6 +45,7 @@ public:
QString pythonFunctionName() const;
QString meshlabFunctionName() const;
QString description() const;
void setDescription(const QString& newDescription);
unsigned int parametersNumber() const;
QStringList pythonFunctionParameters() const;
bool contains(const QString& pythonParameter) const;

View File

@ -95,7 +95,24 @@ void pymeshlab::FunctionSet::loadIOPlugin(IOPlugin* iop)
QString pythonFilterName = outputFormat.toLower();
Function f(pythonFilterName, originalFilterName, "Save " + outputFormat + " format.");
RichParameterList rps = iop->initSaveParameter(outputFormat, *dummyMeshDocument.mm());
if (outputFormat.toUpper() == "PLY"){
f.setDescription(
"Ply files also support saving custom attributes. You'll need to add an "
"additional boolean parameter for each one of that you want to save, and use "
"only non-capital letters for parameter names. These parameters have a prefix "
"for each type of custom attribute:</br>"
"- ``__ca_vs__``: Custom Attribute Vertex Scalar;</br>"
"- ``__ca_vp__``: Custom Attribute Vertex Point;</br>"
"- ``__ca_fs__``: Custom Attribute Face Scalar;</br>"
"- ``__ca_fp__``: Custom Attribute Face Point;</br>"
"For example, if your mesh has a custom per vertex scalar attribute called "
"'MyAttribute', you can save it in a ply file by calling:</br>"
"``ms.save_current_mesh(file_name='myfile.ply', __ca_vs__myattribute=True)`` "
"</br>"
"You can check the parameters available on a mesh by calling the MeshSet "
"method :py:meth:`pmeshlab.MeshSet.filter_parameter_values`, with first "
"parameter ``ply``.");
}
//filename parameter
QString sv = "file_name." + outputFormat;
RichSaveFile of("file_name", sv, outputFormat, "File Name", "The name of the file to save");

View File

@ -414,25 +414,25 @@ void BaseMeshIOPlugin::save(const QString &formatName, const QString &fileName,
// if pname starts with __CA_VS__, it is a PLY per-vertex scalar custom attribute
if (pname.startsWith("__CA_VS__")) {
if (par.getBool(pname)) { // if it is true, add to save list
pi.addPerVertexScalarAttribute(qUtf8Printable(pname.mid(4)), scalarPlyType);
pi.addPerVertexScalarAttribute(qUtf8Printable(pname.mid(9)), scalarPlyType);
}
}
// if pname starts with __CA_VP__, it is a PLY per-vertex point3m custom attribute
else if (pname.startsWith("__CA_VP__")) {
if (par.getBool(pname)) { // if it is true, add to save list
pi.addPerVertexPoint3mAttribute(qUtf8Printable(pname.mid(5)), scalarPlyType);
pi.addPerVertexPoint3mAttribute(qUtf8Printable(pname.mid(9)), scalarPlyType);
}
}
// if pname starts with __CA_FS__, it is a PLY per-face scalar custom attribute
else if (pname.startsWith("__CA_FS__")) {
if (par.getBool(pname)) { // if it is true, add to save list
pi.addPerFaceScalarAttribute(qUtf8Printable(pname.mid(4)), scalarPlyType);
pi.addPerFaceScalarAttribute(qUtf8Printable(pname.mid(9)), scalarPlyType);
}
}
// if pname starts with __CA_FP__, it is a PLY per-face point3m custom attribute
else if (pname.startsWith("__CA_FP__")) {
if (par.getBool(pname)) {
pi.addPerFacePoint3mAttribute(qUtf8Printable(pname.mid(5)), scalarPlyType);
pi.addPerFacePoint3mAttribute(qUtf8Printable(pname.mid(9)), scalarPlyType);
}
}
}