private void quick_check_Click(object sender, EventArgs e) { setup(); RayTracer.findComponentsVisible(); highlightComponents(); teardown(); }
public static bool extendFlagOverRangeOfMotion(Component2 component) { // what we want to do is lengthen the flag (if we can), then move it through all positions. // if we get to a position where we can't see it anymore, we want to lengthen the flag again and // restart the simulation. Extrusion e = new Extrusion(component, RayTracer.camera, swApp, swDoc, swAssembly, swFeatureMgr); if (e.isValid()) { bool completeSimulation = false; int positionsTested = 0; double originalMateValue = getMateValue(component); while (!completeSimulation && !somethingIntersects(component)) { // we can extrude this thing if (!cameraIntersects(component)) { e.extendBy(e.distanceFromFlagToCamera()); completeSimulation = false; positionsTested = 0; if (somethingIntersects(component)) { break; } } positionsTested += 1; // move to a new position moveToPosition(component, positionsTested, originalMateValue); completeSimulation = isSimulationComplete(component.Name2, positionsTested); } moveToPosition(component, 0, originalMateValue); if (!completeSimulation) { e.restoreToDefaultDepth(); } else { return(true); } } else { // we have something like a scroll wheel or trackball // these things don't need to be simulated return(RayTracer.rawRaysSeeComponentInCurrentConfig(component)); } return(false); }
private void createMirrorExtrusion(ReflectionPoint reflectionPoint) { RayTracer.startSketch(); RayTracer.visualizePoint(reflectionPoint.location); /*swDoc.SketchManager.CreateCenterRectangle(reflectionPoint.xyz[0], reflectionPoint.xyz[1], reflectionPoint.xyz[2], * reflectionPoint.xyz[0] + (inchesToMeters(1) * (1 - reflectionPoint.nxnynz[0])), * reflectionPoint.xyz[1] + (inchesToMeters(1) * (1 - reflectionPoint.nxnynz[1])), * reflectionPoint.xyz[2] + (inchesToMeters(1) * (1 - reflectionPoint.nxnynz[2])));*/ RayTracer.finishSketch("place mirror for " + reflectionPoint.component.Name2); return; /* * double mirrorWidth = inchesToMeters(1); * double[] pointLocation = putInMainBodySpace(reflectionPoint); * * double[] surfaceNormal = reflectionPoint.nxnynz; * * // select the main body, because that is what we want to draw on * mainBody.Select(false); * int status = 0; * swAssembly.EditPart2(true, false, ref status); * swSelectionMgr.SetSelectionPoint2(1, -1, pointLocation[0], pointLocation[1], pointLocation[2]); * swSketchMgr.AddToDB = true; * swSketchMgr.InsertSketch(true); * * swSketchMgr.CreateCenterRectangle(pointLocation[0], pointLocation[1], pointLocation[2], * pointLocation[0] + .5 * mirrorWidth * (1 - surfaceNormal[0]), * pointLocation[1] + .5 * mirrorWidth * (1 - surfaceNormal[1]), * pointLocation[2] + .5 * mirrorWidth * (1 - surfaceNormal[2])); * * swSketchMgr.AddToDB = false; * * swFeatureMgr.FeatureExtrusion2(true, false, false, * 0, 0, 0.00254, 0.00254, * false, false, false, false, * 0, 0, * false, false, false, false, true, true, true, * 0, 0, * false); * * * if(generatedMirrorExtrusions == null) { * generatedMirrorExtrusions = new List<IFeature>(); * } * generatedMirrorExtrusions.Add(swSelectionMgr.GetSelectedObject6(1, -1) as IFeature); * * swDoc.ClearSelection2(true); * swAssembly.EditAssembly();*/ }
public static bool reflectRaysOverRangeOfMotion(Component2 component) { // what we want to do is reflect rays while moving through all positions. // if we get to a position where we can't see it anymore, we want to call it a day // TODO : we could probably try lengthening the flag here and checking Extrusion e = new Extrusion(component, RayTracer.camera, swApp, swDoc, swAssembly, swFeatureMgr); if (e.isValid()) { bool completeSimulation = false; int positionsTested = 0; double originalMateValue = getMateValue(component); while (!completeSimulation && (RayTracer.reflectedRayCanSeeComponent(component) != null)) { positionsTested += 1; // move to a new position moveToPosition(component, positionsTested, originalMateValue); completeSimulation = isSimulationComplete(component.Name2, positionsTested); } moveToPosition(component, 0, originalMateValue); if (completeSimulation) { return(true); } } else { // we have something like a scroll wheel or trackball // these things don't need to be simulated return(RayTracer.reflectedRayCanSeeComponent(component) != null); } return(false); }
private bool placeMirror(Component2 swComponent) { // intutively, what we want to do: // look to see if any camera rays hit the object as-is, then no worries // if not, look to see if any camera rays reflecting off the main body hit the object // if yes, put a mirror in that spot // if no, we fail and cry if (!Simulator.reflectRaysOverRangeOfMotion(swComponent)) { return(false); } // TODO : ideally we would collect all the points that we reflect // from and make a mirror that shows all of them ReflectionPoint rp = RayTracer.reflectedRayCanSeeComponent(swComponent); createMirrorExtrusion(rp); return(true); }