CloudCompare / CloudComPy

Python wrapper for CloudCompare
Other
265 stars 38 forks source link

filterBySFValue does not support Meshes #176

Open N4VDI opened 1 week ago

N4VDI commented 1 week ago

Currently filterBySFValue does not seem to support Mesh, only Point Clouds. On a mesh entity it throws an error

incompatible function arguments. The following argument types are supported:
    1. (arg0: float, arg1: float, arg2: _cloudComPy.ccPointCloud) -> _cloudComPy.ccPointCloud

CloudCompare does support filtering by scalar field values for Meshes https://www.cloudcompare.org/doc/wiki/index.php/Scalar_fields%5CFilter_by_Value (since 2.13 alpha?) Would be nice if CloudComPy also supports it via the filterBySFValue API

(already posted in Gitlab issues-2, but as this seems to be the preferred place (again) for issues also creating it here, sorry for the dup.)

prascle commented 4 days ago

Hello, I am sorry, i did not see your post on GitLab.

The CloudComPy Gitlab repository was created as a backup when I had problems with my Github account. Gitlab did not send me an email notification for your issue, I will fix my Gitlab configuration and maintain an up to date backup on Giltab. Anyway, Github is the prefered place for issues.

You are right, filterBySFValue does not support meshes, only clouds. I will add the necessary methods for meshes in the next release.

It is possible to do something similar, but not equivalent, with the cloud associated to the mesh. In the following example, the cloud associated to the mesh is filtered, and a mesh is built on this cloud. The holes are meshed, which is not the case with the CloudCompare method.

import os
import sys
import math

os.environ["_CCTRACE_"]="ON"

from gendata import getSampleCloud, dataDir
import cloudComPy as cc

cloud = cc.loadPointCloud(getSampleCloud(5.0))
cloud.exportCoordToSF(False, False, True)
mesh=cc.ccMesh.triangulate(cloud, cc.TRIANGULATION_TYPES.DELAUNAY_2D_AXIS_ALIGNED, dim=2)

mesh1=mesh.cloneMesh()
cloud1=mesh1.getAssociatedCloud()
filterCloud1=cloud1.filterPointsByScalarValue(0.4, 3, False)
filterMesh1=cc.ccMesh.triangulate(filterCloud1, cc.TRIANGULATION_TYPES.DELAUNAY_2D_AXIS_ALIGNED, dim=2)

cc.SaveEntities([cloud, cloud1, filterCloud1, mesh, mesh1, filterMesh1], os.path.join(dataDir, "filterMesh.bin"))

Best regards, Paul

N4VDI commented 1 day ago

Hello, np, I understand the tech problems you had.

Yes, looked at the workaround, but found that for the use case the surface/mesh reconstruction from point cloud was not ideal, introducing too much artifacts and/or need for (manual) tweaking. Tried with Delaunay and qPoissonRecon methods.

Thanks for taking it up in the next release, looking forward to it!