# # # 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: raise RuntimeError
# # ########################################################################## 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 cc.SaveEntities([cloud1, plane], os.path.join(dataDir, "cloudsFit.bin"))