Commit 9d3fb221 authored by Jan Möbius's avatar Jan Möbius

Python test for grouping

parent 0019dddf
......@@ -11,5 +11,6 @@ if(BUILD_TESTING)
# ========================================================================
run_local_script_test("dataType.ofp")
run_local_script_test("group.ofp")
endif()
core.clearAll()
# Group 20 Objects
for i in range(0,20):
primitivesgenerator.addSphere()
datacontrol.setAllTarget()
list = datacontrol.getTargetObjects("TriangleMesh");
print("Target mesh ids: ")
print(list)
# Check, if group was created
groupid = datacontrol.groupObjects(list)
if groupid == -1:
print("Unable to create a group with 20 objects")
core.exitFailure()
else:
print("Group created with id: " + str(groupid))
if datacontrol.groupCount() != 1:
print("Group 20 Objects failed")
print("unexpected group count")
print("number of groups: " + str(datacontrol.groupCount()) )
print("expected number of groups: 1")
core.exitFailure()
else:
print("Grouping successfull")
datacontrol.clearAllTarget()
# Group Object and Group
id = primitivesgenerator.addSphere()
list = [groupid,id]
datacontrol.groupObjects(list)
if datacontrol.groupCount() != 2:
print("Group Object and Group failed")
print("unexpected group count")
print("number of groups: " + str(datacontrol.groupCount()) )
print("expected number of groups: 2")
core.exitFailure()
else:
print("Grouping successfull. Groupcount:" + str(datacontrol.groupCount()))
datacontrol.clearAllTarget()
# Group multiple Groups
id = primitivesgenerator.addSphere()
id2 = primitivesgenerator.addSphere()
list = [id2,id]
groupid2 = datacontrol.groupObjects(list)
if datacontrol.groupCount() != 3 :
print("Group multiple Groups failed")
print("unexpected group count")
print("number of groups: " + str(datacontrol.groupCount()) )
print("expected number of groups: 3")
core.exitFailure()
else:
print("Grouping successfull. Groupcount:" + str(datacontrol.groupCount()))
# Ungroup
datacontrol.unGroupObject(groupid2)
if datacontrol.groupCount() != 2:
print("Ungroup failed")
print("unexpected group count")
print("number of groups: " + str(datacontrol.groupCount()))
print("expected number of groups: 2")
core.exitFailure()
else:
print("Ungrouping successfull. Groupcount:" + str(datacontrol.groupCount()))
# add object to existing group
core.clearAll()
id1 = primitivesgenerator.addSphere()
id2 = primitivesgenerator.addSphere()
id3 = primitivesgenerator.addSphere()
groupid = datacontrol.groupObjects([id1,id2])
datacontrol.addObjectToGroup(id3,groupid)
# Can be done, if all objects are in the same group
datacontrol.groupObjects([id1,id2,id3])
if datacontrol.groupCount() != 2:
print("Add to Group failed.")
print("unexpected group count")
print("number of groups: " + str(datacontrol.groupCount()))
print("expected number of groups: 2")
core.exitFailure()
else:
print("Grouping with group successfull. Groupcount:" + str(datacontrol.groupCount()))
if (datacontrol.addObjectToGroup(id3,id2)) :
print("Could add an object to an object which is not a Group.")
core.exitFailure();
else:
print("Grouping successfully failed (This is intended!)")
# Get group elements
id1 = primitivesgenerator.addSphere()
id2 = primitivesgenerator.addSphere()
elements = [id1,id2]
groupid = datacontrol.groupObjects(elements)
resultList = datacontrol.getGroupElements(groupid)
if resultList.size != len(elements) :
print("error: getGroupElements")
print("number of received elements is: "+ str(len(elements)) + " expected was: " + str(resultList.size) )
core.exitFailure();
else:
print("Element count correct after grouping")
for i in range(0,len(elements)):
if not elements[i] in resultList:
print("error: getGroupElements")
print("Item not in list!")
print("Element: " + str(elements[i]))
print("List:")
print(resultList)
core.exitFailure();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment