Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FlagDuplicatePoints #171

Open
Group5AAU opened this issue May 15, 2024 · 1 comment
Open

FlagDuplicatePoints #171

Group5AAU opened this issue May 15, 2024 · 1 comment

Comments

@Group5AAU
Copy link

Hello!

We are trying to use the functions '.GeometricalAnalysisTools.FlagDuplicatePoints' and 'filterPointsByScalarValue' to remove duplicate points from our point cloud.
Does anyone know which arrays or values to use?

image

It sort of works, but it no where near removes as many points as it does when manually using the tool 'Remove duplicate points' within CloudCompare itself.

Hope anyone can help :)

Best Regards!

@prascle
Copy link
Collaborator

prascle commented May 16, 2024

Hello,

I can't reproduce the problem: in the following test, I create a cloud with random duplicate points and remove the duplicates (here, I've chosen 1.e-3 as the distance criterion), then save the original cloud and the cloud without duplicates. Using CloudCompare, I remove the duplicate points from the original cloud with the same criterion: I get the same cloud as the one calculated by CloudCompy.

The only parameter you need to choose is the distance criterion, which depends on your problem. For the filter, I use 0. for min and max.

Can you provide a dataset and a script to reproduce the problem ?
Best regards,
Paul

import sys
import math
import numpy as np

os.environ["_CCTRACE_"]="ON" # only if you want C++ debug traces

import cloudComPy as cc

# --- generate a set of coords and a scalar field

npts = 1000000
phi = 2*np.pi*np.random.random((npts))
theta = 2*np.pi*np.random.random((npts))
r = 5 + 0.3*np.sin(2*2*np.pi*phi + 3*2*np.pi*theta)
x = np.float32(r*np.sin(phi)*np.cos(theta))
y = np.float32(r*np.sin(phi)*np.sin(theta))
z = np.float32(r*np.cos(phi))
coords = np.column_stack((x,y,z))
dr = np.float32(np.sqrt(x*x + y*y + z*z) -5)

# --- create the pointCloud, add the scalar field

cloud = cc.ccPointCloud("boule")
cloud.coordsFromNPArray_copy(coords)
cloud.addScalarField("delta")
sf = cloud.getScalarField(0)
sf.fromNpArrayCopy(dr)

# --- remove the duplicates (distances < 1.e-3)

dupSFindex = cloud.addScalarField("DuplicateFlags")
cloud.setCurrentScalarField(dupSFindex)
ret = cc.GeometricalAnalysisTools.FlagDuplicatePoints(cloud, 1.e-3) # identify duplicated points
noDuplCloud = cloud.filterPointsByScalarValue(0., 0., outside=False) # remove duplicated pts

cc.SaveEntities([cloud, noDuplCloud], "boules.bin")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants