コード例 #1
0
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the          #
#  GNU General Public License for more details.                          #
#                                                                        #
#          Copyright 2020 Paul RASCLE www.openfields.fr                  #
#                                                                        #
##########################################################################

import os
import sys
import math
from gendata import getSampleCloud, getSamplePoly, dataDir, isCoordEqual, createSymbolicLinks
import cloudComPy as cc

createSymbolicLinks()  # required for tests on build, before cc.initCC.init
cc.initCC()  # to do once before using plugins or dealing with numpy
cloud = cc.loadPointCloud(getSampleCloud(5.0))

tr1 = cc.ccGLMatrix()
tr1.initFromParameters(0.1, 0.2, 0.3, (8.0, 0.0, 0.0))
box = cc.ccBox((1., 2., 3.), tr1, "aBox")
if box.getName() != 'aBox':
    raise RuntimeError
if box.size() != 12:
    raise RuntimeError

tr2 = cc.ccGLMatrix()
tr2.initFromParameters(0.5, (0., 1., 0.), (5.0, 6.0, 3.0))
cone = cc.ccCone(3., 1., 2., 0., 0., tr2, "aCone", 12)
if cone.getName() != 'aCone':
    raise RuntimeError
if cone.size() != 48:
コード例 #2
0
ファイル: test012.py プロジェクト: prascle/CloudComPy
#                                                                        #
#          Copyright 2020 Paul RASCLE www.openfields.fr                  #
#                                                                        #
##########################################################################

import os
import sys
import math
from gendata import getSampleCloud, getSampleCloud2, dataDir, isCoordEqual, createSymbolicLinks
import cloudComPy as cc

createSymbolicLinks()  # required for tests on build, before cc.initCC

cc.initCC()  # to do once before using plugins or dealing with numpy

cloud1 = cc.loadPointCloud(getSampleCloud2(3.0, 0, 0.1))
cloud1.setName("cloud1")
tr1 = cc.ccGLMatrix()
tr1.initFromParameters(0.2 * math.pi, (1., 1., 1.), (0.0, 0.0, 10.0))
cloud1.applyRigidTransformation(tr1)

plane = cc.ccPlane.Fit(cloud1)
equation = plane.getEquation()
eqRef = [
    0.4032580554485321, -0.2757962644100189, 0.8725361824035645,
    8.782577514648438
]
for i in range(4):
    if not math.isclose(equation[i], eqRef[i], rel_tol=1.e-3):
        raise RuntimeError
コード例 #3
0
#  GNU General Public License for more details.                          #
#                                                                        #
#          Copyright 2020 Paul RASCLE www.openfields.fr                  #
#                                                                        #
##########################################################################

import os
import sys
import math
from gendata import getSampleCloud, dataDir
import numpy as np
import cloudComPy as cc

cc.initCC()  # Sto do once before using plugins or dealing with numpy

cloud = cc.loadPointCloud(getSampleCloud(2.0))
ok = cloud.exportCoordToSF(True, True, True)

# --- access to ScalarField by name

dic = cloud.getScalarFieldDic()
dic  # {'Coord. X': 0, 'Coord. Y': 1, 'Coord. Z': 2}
sf0 = cloud.getScalarField(dic['Coord. X'])
if sf0.getName() != 'Coord. X':
    raise RuntimeError
sf1 = cloud.getScalarField('Coord. Y')
if sf1.getName() != 'Coord. Y':
    raise RuntimeError

# --- check write and read ply format
コード例 #4
0
ファイル: test010.py プロジェクト: CloudCompare/CloudComPy
#  GNU General Public License for more details.                          #
#                                                                        #
#          Copyright 2020 Paul RASCLE www.openfields.fr                  #
#                                                                        #
##########################################################################

import os
import sys
import math
from gendata import getSampleCloud, getSamplePoly, dataDir, isCoordEqual, createSymbolicLinks
import cloudComPy as cc

createSymbolicLinks()  # required for tests on build, before cc.initCC.init
cc.initCC()  # to do once before using plugins or dealing with numpy

cloud1 = cc.loadPointCloud(getSampleCloud(5.0))
cloud1.setName("cloud1")

cloud2ref = cc.loadPointCloud(getSampleCloud(5.0, 9.0))
cloud2ref.setName("cloud2_reference")

cloud2 = cloud2ref.cloneThis()
tr1 = cc.ccGLMatrix()
# -------------------- z -- y -- x
tr1.initFromParameters(0.0, 0.0, 0.1, (0.0, 0.0, 0.3))
cloud2.applyRigidTransformation(tr1)
cloud2.setName("cloud2_transformed")

cc.SaveEntities([cloud1, cloud2ref, cloud2],
                os.path.join(dataDir, "clouds2.bin"))
コード例 #5
0
#  GNU General Public License for more details.                          #
#                                                                        #
#          Copyright 2020 Paul RASCLE www.openfields.fr                  #
#                                                                        #
##########################################################################

import os
import sys
import math
from gendata import getSampleCloud, dataDir
import numpy as np
import cloudComPy as cc

cc.initCC()  # Sto do once before using plugins or dealing with numpy

cloud1 = cc.loadPointCloud(getSampleCloud(2.0))

ok = cloud1.exportCoordToSF(False, False, True)
if not ok:
    raise RuntimeError

res = cloud1.hasScalarFields()
print("hasScalarField: %s" % res)
if not res:
    raise RuntimeError

n = cloud1.getNumberOfScalarFields()
print("number of saclar fields: %s" % n)
if n != 1:
    raise RuntimeError
コード例 #6
0
"""

import numpy as np
import cloudComPy as cc
import time
import colorsys
from sklearn.ensemble import RandomForestClassifier
from sklearn.neural_network import MLPClassifier
from sklearn. impute import SimpleImputer
from imblearn.under_sampling import RandomUnderSampler
cc.initCC()  # to do once before using plugins or dealing with numpy


# %%
fp = R'C:\Users\lweidner\OneDrive - BGC Engineering Inc\Projects\Zion NP\CableMnt.bin'
cloud = cc.loadPointCloud(fp)
print('...loaded cloud with size: ',cloud.size())
radii = [1.5,1.0,0.5]
minDistDownsample = 0.4
useColor = 1
useGeometry = 1
# %% downsample raw point cloud using min space between points
print('...downsampling')
params = cc.SFModulationParams()
refCloud = cc.CloudSamplingTools.resampleCloudSpatially(cloud, minDistDownsample, params)
print('...finished downsampling')
(subsampledCloud, res) = cloud.partialClone(refCloud)
octree = subsampledCloud.computeOctree()
print('...downsampled cloud and computed octree, new cloud has size: ',subsampledCloud.size())
labelSf = subsampledCloud.getScalarField(0)
label = labelSf.toNpArrayCopy()
コード例 #7
0
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the          #
#  GNU General Public License for more details.                          #
#                                                                        #
#          Copyright 2020 Paul RASCLE www.openfields.fr                  #
#                                                                        #
##########################################################################

import os
import sys
import math
from gendata import getSampleCloud, dataDir, isCoordEqual
import cloudComPy as cc

cc.initCC()  # to do once before using plugins or dealing with numpy

cloud = cc.loadPointCloud(getSampleCloud(5.0))
cloud.translate((1000, 2000, 3000))
res = cc.SavePointCloud(cloud, os.path.join(dataDir, "res1.xyz"))
if res:
    raise RuntimeError

cloud = cc.loadPointCloud(os.path.join(dataDir, "res1.xyz"))
coords = cloud.toNpArray()
if not isCoordEqual(coords[0], (995., 1995., 2999.8987)):
    raise RuntimeError

cloud1 = cc.loadPointCloud(os.path.join(dataDir, "res1.xyz"),
                           cc.CC_SHIFT_MODE.XYZ, 0, -1000, -2000, -3000)
coords1 = cloud1.toNpArray()
if not isCoordEqual(coords1[0], (-5., -5., -0.10131836)):
    raise RuntimeError
コード例 #8
0
ファイル: test001.py プロジェクト: prascle/CloudComPy
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the          #
#  GNU General Public License for more details.                          #
#                                                                        #
#          Copyright 2020 Paul RASCLE www.openfields.fr                  #
#                                                                        #
##########################################################################

import os
import sys
import math
from gendata import getSampleCloud, dataDir, isCoordEqual
import cloudComPy as cc

cc.initCC()  # to do once before using plugins or dealing with numpy

cloud = cc.loadPointCloud(getSampleCloud(5.0))
namecloud = cloud.getName()
print("cloud name: %s" % namecloud)
if namecloud != "dataSample_5 - Cloud":
    raise RuntimeError

npts = cloud.size()
print("cloud.size %s" % npts)
if npts != 1000000:
    raise RuntimeError

res = cloud.hasScalarFields()
print("hasScalarField: %s" % res)
if res:
    raise RuntimeError