From 62a16d1141e8bcfac66886d97ec34155fb5af9c1 Mon Sep 17 00:00:00 2001 From: eulaliecoevoet Date: Thu, 17 Mar 2022 15:39:48 -0400 Subject: [PATCH 1/3] [python3] fixes warnings --- python3/src/splib3/numerics/quat_test.py | 23 +++---------------- .../src/stlib3/physics/collision/collision.py | 2 +- .../src/stlib3/physics/rigid/RigidObject.py | 2 +- python3/src/stlib3/scene/contactheader.py | 2 +- python3/src/stlib3/visuals/visualmodel.py | 2 +- 5 files changed, 7 insertions(+), 24 deletions(-) diff --git a/python3/src/splib3/numerics/quat_test.py b/python3/src/splib3/numerics/quat_test.py index 3c27293..27d5fa7 100644 --- a/python3/src/splib3/numerics/quat_test.py +++ b/python3/src/splib3/numerics/quat_test.py @@ -2,8 +2,8 @@ from math import sin, cos, pi from quat import * -class Quat_test(unittest.TestCase): +class Quat_test(unittest.TestCase): def test_equal(self): q1 = Quat() @@ -14,7 +14,6 @@ def test_equal(self): self.assertEqual(q1,[0.,0.,0.,1.]) self.assertNotEqual(q1,[0.707,0.,0.,0.707]) - def test_constructors(self): q = Quat() self.assertEqual(q,[0.,0.,0.,1.]) @@ -25,40 +24,32 @@ def test_constructors(self): q = Quat([0.707,0.,0.,0.707]) self.assertEqual(q,[0.707,0.,0.,0.707]) - -## PUBLICS METHODS - +# PUBLICS METHODS def test_getNorm(self): q = Quat() self.assertEqual(q.getNorm(), 1.) - def test_normalize(self): q = Quat(1.,0.,2.,2.) q.normalize() self.assertEqual(q, [1./3.,0.,2./3.,2./3.]) - def test_realPart(self): q = Quat() self.assertEqual(q.getRe(), 1.) - def test_imaginaryPart(self): q = Quat(1.,2.,3.,4.) self.assertEqual(q.getIm()[0], 1.) self.assertEqual(q.getIm()[1], 2.) self.assertEqual(q.getIm()[2], 3.) - def test_flip(self): q = Quat(0.707,0.,0.,-0.707) q.flip() self.assertEqual(q, [-0.707,0.,0.,0.707]) - - def test_conjugate(self): q = Quat() self.assertEqual(q.getConjugate(), q) @@ -66,7 +57,6 @@ def test_conjugate(self): q = Quat(0.5,0.5,0.5,0.5) self.assertEqual(q.getConjugate(), [-0.5,-0.5,-0.5,0.5]) - def test_getInverse(self): q = Quat() self.assertEqual(q.getInverse(), q) @@ -77,7 +67,6 @@ def test_getInverse(self): q = Quat(1.,1.,1.,1.) self.assertEqual(q.getInverse(), [-0.25,-0.25,-0.25,0.25]) - def test_getAxisAngle(self): q = Quat.createFromAxisAngle([1.,0.,0.],pi/3.) results = q.getAxisAngle() @@ -86,7 +75,6 @@ def test_getAxisAngle(self): self.assertEqual(results[0][2], 0.) self.assertAlmostEqual(results[1], pi/3.) - def test_getEulerAngles(self): q = Quat.createFromEuler([-pi/4.,0.,0.]) e = q.getEulerAngles() @@ -94,15 +82,12 @@ def test_getEulerAngles(self): self.assertEqual(e[1], 0.) self.assertEqual(e[2], 0.) - -## STATIC METHODS - +# STATIC METHODS def test_createFromAxisAngle(self): q = Quat.createFromAxisAngle([1.,0.,0.],pi/2.) self.assertEqual(q, [sin(pi/4.),0.,0.,cos(pi/4.)]) - def test_createFromEuler(self): q = Quat.createFromEuler([pi/2.,0.,0.]) self.assertEqual(q, [sin(pi/4.),0.,0.,cos(pi/4.)]) @@ -113,7 +98,6 @@ def test_createFromEuler(self): q = Quat.createFromEuler([0.,pi/2.,0.],"syxz") self.assertEqual(q, [sin(pi/4.),0.,0.,cos(pi/4.)]) - def test_createFromEuler_against_rotateFromQuat(self): q1 = Quat.createFromEuler([pi/2.,-pi/2.,0.],"rxyz") q2 = Quat.createFromEuler([pi/2.,0.,0.],"sxyz") @@ -135,7 +119,6 @@ def test_createFromEuler_against_rotateFromQuat(self): q2.rotateFromQuat(q4) self.assertEqual(q1,q2) - def test_rotateFromEuler(self): q = Quat.createFromAxisAngle([1., 0., 0.], pi/2.) q.rotateFromEuler([0.,-pi/2.,0.]) diff --git a/python3/src/stlib3/physics/collision/collision.py b/python3/src/stlib3/physics/collision/collision.py index 109dcd7..7d7e6bf 100644 --- a/python3/src/stlib3/physics/collision/collision.py +++ b/python3/src/stlib3/physics/collision/collision.py @@ -4,7 +4,7 @@ def loaderFor(name): if name.endswith(".obj"): - return "MeshObjLoader" + return "MeshOBJLoader" elif name.endswith(".stl"): return "MeshSTLLoader" elif name.endswith(".vtk"): diff --git a/python3/src/stlib3/physics/rigid/RigidObject.py b/python3/src/stlib3/physics/rigid/RigidObject.py index 4aadfb9..8de9ef3 100644 --- a/python3/src/stlib3/physics/rigid/RigidObject.py +++ b/python3/src/stlib3/physics/rigid/RigidObject.py @@ -70,7 +70,7 @@ def RigidObject(name="RigidObject", def addCollisionModel(inputMesh=surfaceMeshFileName): objectCollis = object.addChild('collision') objectCollis.addObject('RequiredPlugin', name='SofaMeshCollision') - objectCollis.addObject('MeshObjLoader', name="loader", + objectCollis.addObject('MeshOBJLoader', name="loader", filename=inputMesh, triangulate=True, scale=uniformScale) diff --git a/python3/src/stlib3/scene/contactheader.py b/python3/src/stlib3/scene/contactheader.py index 85c9c1d..2c55cb5 100644 --- a/python3/src/stlib3/scene/contactheader.py +++ b/python3/src/stlib3/scene/contactheader.py @@ -33,7 +33,7 @@ def ContactHeader(applyTo, alarmDistance, contactDistance, frictionCoef=0.0): applyTo.addObject('BVHNarrowPhase') applyTo.addObject('RuleBasedContactManager', responseParams="mu="+str(frictionCoef), - name='Response', response='FrictionContact') + name='Response', response='FrictionContactConstraint') applyTo.addObject('LocalMinDistance', alarmDistance=alarmDistance, contactDistance=contactDistance, angleCone=0.01) diff --git a/python3/src/stlib3/visuals/visualmodel.py b/python3/src/stlib3/visuals/visualmodel.py index 48958e8..0d87de6 100644 --- a/python3/src/stlib3/visuals/visualmodel.py +++ b/python3/src/stlib3/visuals/visualmodel.py @@ -21,7 +21,7 @@ def init(self): if path.endswith('.stl'): self.addObject('MeshSTLLoader', name='loader',filename=path) elif path.endswith('.obj'): - self.addObject('MeshObjLoader', name='loader',filename=path) + self.addObject('MeshOBJLoader', name='loader',filename=path) else: print("Extension not handled in STLIB/python3/stlib3/visuals for file: "+str(path)) From 64d21ba193ee6866f08dd6df6087f924bbdb8147 Mon Sep 17 00:00:00 2001 From: Damien Marchal Date: Fri, 1 Apr 2022 14:57:00 +0200 Subject: [PATCH 2/3] Update rigidification.py --- python3/src/stlib3/physics/mixedmaterial/rigidification.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python3/src/stlib3/physics/mixedmaterial/rigidification.py b/python3/src/stlib3/physics/mixedmaterial/rigidification.py index 8574c7d..e0d89f6 100644 --- a/python3/src/stlib3/physics/mixedmaterial/rigidification.py +++ b/python3/src/stlib3/physics/mixedmaterial/rigidification.py @@ -122,7 +122,7 @@ def mfilter(si, ai, pts): sourceObject.removeObject(sourceObject.solver) if "integration" in sourceObject.objects: sourceObject.removeObject(sourceObject.integration) - if "correction" in sourceObject: + if "correction" in sourceObject.objects: sourceObject.removeObject(sourceObject.correction) sourceObject.addObject("SubsetMultiMapping", name="mapping", template="Vec3,Vec3", From 2b41d7f84ef1ee0d7184d4fc4e21d7a9684262c1 Mon Sep 17 00:00:00 2001 From: Damien Marchal Date: Fri, 1 Apr 2022 14:58:19 +0200 Subject: [PATCH 3/3] Update scene.py --- python3/src/stlib3/scene/scene.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/python3/src/stlib3/scene/scene.py b/python3/src/stlib3/scene/scene.py index 91cce09..4f3af94 100644 --- a/python3/src/stlib3/scene/scene.py +++ b/python3/src/stlib3/scene/scene.py @@ -89,13 +89,14 @@ def addSettings(plugins=plugins, repositoryPaths=repositoryPaths): root.gravity.value = gravity root.dt.value = dt + root.addObject('VisualStyle') root.addMainHeader = addMainHeader root.addSettings = addSettings root.addSolver = addDefaultSolver root.addContact = addContactHeader root.addModelling = addModelling root.addSimulation = addSimulation - + return root