Example #1
0
		public void MirrorTests()
		{
			{
				Box leftBox = new Box(10, 20, 30, "leftBox", createCentered: false);
				CsgObject rightBox = new Box(11, 21, 31, "rightBox", createCentered: false);
				rightBox = new Align(rightBox, Face.Left, leftBox, Face.Right);
				CsgObject union = new Union(leftBox, rightBox);
				Assert.IsTrue(union.XSize == 21, "Correct XSize");
				AxisAlignedBoundingBox unionBounds = union.GetAxisAlignedBoundingBox();
				Assert.IsTrue(unionBounds.minXYZ == new Vector3(), "MinXYZ at 0");
				Assert.IsTrue(union.GetAxisAlignedBoundingBox().maxXYZ == new Vector3(21, 21, 31), "MaxXYZ correct");
			}

			{
				Box leftBox = new Box(10, 20, 30, "leftBox", createCentered: false);
				CsgObject rightBox = leftBox.NewMirrorAccrossX(name: "rightBox");
				rightBox = new Align(rightBox, Face.Left, leftBox, Face.Right);
				CsgObject union = new Union(leftBox, rightBox);
				Assert.IsTrue(union.XSize == 20, "Correct XSize");
				AxisAlignedBoundingBox unionBounds = union.GetAxisAlignedBoundingBox();
				Assert.IsTrue(unionBounds.minXYZ == new Vector3(), "MinXYZ at 0");
				Assert.IsTrue(union.GetAxisAlignedBoundingBox().maxXYZ == new Vector3(20, 20, 30), "MaxXYZ correct");
			}

			{
				Box frontBox = new Box(10, 20, 30, createCentered: false);
				CsgObject backBox = frontBox.NewMirrorAccrossY();
				backBox = new Align(backBox, Face.Front, frontBox, Face.Back);
				CsgObject union = new Union(frontBox, backBox);
				Assert.IsTrue(union.YSize == 40, "Correct YSize");
				AxisAlignedBoundingBox unionBounds = union.GetAxisAlignedBoundingBox();
				Assert.IsTrue(unionBounds.minXYZ == new Vector3(), "MinXYZ at 0");
				Assert.IsTrue(union.GetAxisAlignedBoundingBox().maxXYZ == new Vector3(10, 40, 30), "MaxXYZ correct");
			}
		}
Example #2
0
 public CsgObject DoCopyAndFlatten(Union objectToProcess)
 {
     Union unionCopy = new Union(objectToProcess.Name);
     foreach (CsgObject copiedObject in objectToProcess.allObjects)
     {
         unionCopy += DoCopyAndFlatten((dynamic)copiedObject);
     }
     return unionCopy;
 }
Example #3
0
		public string GetScadOutputRecursive(Union objectToProcess, int level = 0)
		{
			StringBuilder totalString = new StringBuilder();
			totalString.Append("union()" + AddNameAsComment(objectToProcess) + "\n{\n");
			foreach (CsgObject objectToOutput in objectToProcess.AllObjects)
			{
				totalString.Append(GetScadOutputRecursive((dynamic)objectToOutput, level + 1) + "\n");
			}
			totalString.Append("}");

			return ApplyIndent(totalString.ToString(), level);
		}
Example #4
0
		public PolygonMesh.Mesh CsgToMeshRecursive(Union objectToProcess)
		{
			PolygonMesh.Mesh primary = CsgToMeshRecursive((dynamic)objectToProcess.AllObjects[0]);
			for (int i = 1; i < objectToProcess.AllObjects.Count; i++)
			{
				PolygonMesh.Mesh add = CsgToMeshRecursive((dynamic)objectToProcess.AllObjects[i]);
				primary = PolygonMesh.Csg.CsgOperations.Union(primary, add);
			}

			return primary;
		}
		public IPrimitive GetIPrimitiveRecursive(Union objectToProcess)
		{
			List<IPrimitive> items = new List<IPrimitive>();
			foreach (CsgObject copiedObject in objectToProcess.AllObjects)
			{
				items.Add(GetIPrimitiveRecursive((dynamic)copiedObject));
			}

			return BoundingVolumeHierarchy.CreateNewHierachy(items);
		}
Example #6
0
 public void RenderToGlRecursive(Union objectToProcess)
 {
     // do whatever we might need to do for the renderer
     foreach (CsgObject objectToOutput in objectToProcess.AllObjects)
     {
         RenderToGlRecursive((dynamic)objectToOutput);
     }
 }
		public string LookForNamedPartRecursive(Union objectToProcess, Matrix4X4 accumulatedMatrix)
		{
			StringBuilder totalString = new StringBuilder();
			foreach (CsgObject objectToOutput in objectToProcess.allObjects)
			{
				totalString.Append(LookForNamedPartRecursive((dynamic)objectToOutput, accumulatedMatrix));
			}

			return totalString.ToString();
		}