Example #1
0
    void DrawCadObject(ICADObject obj, string style)
    {
        var he = obj as IEntity;

        canvas.SetStyle((he != null && he.type == IEntityType.Point) ? style + "Points" : style);
        if (he != null)
        {
            canvas.DrawSegments((obj as IEntity).SegmentsInPlane(null));
        }
        else
        if (obj is SketchObject)
        {
            (obj as SketchObject).Draw(canvas);
        }
    }
Example #2
0
    void DrawCadObject(ICADObject obj, string style)
    {
        var sko = obj as SketchObject;

        if (sko != null && !sko.isVisible)
        {
            return;
        }
        var he = obj as IEntity;

        canvas.SetStyle((he != null && he.type == IEntityType.Point) ? style + "Points" : style);
        if (he != null)
        {
            canvas.DrawSegments((obj as IEntity).SegmentsInPlane(null));
        }
        else
        if (sko != null)
        {
            sko.Draw(canvas);
        }
    }
Example #3
0
    private void Update()
    {
        if (activeFeature != null)
        {
            if (currentSketch != null && currentSketch.IsTopologyChanged())
            {
                UpdateSystem();
            }
            var    res    = sys.Solve();
            string result = "";
            result += (GC.GetTotalMemory(false) / 1024 / 1024.0).ToString("0.##") + " mb\n";
            result += res.ToString() + "\n";
            if (sys.dofChanged)
            {
                if (res == EquationSystem.SolveResult.OKAY && !sys.HasDragged())
                {
                    int  dof;
                    bool ok = sys.TestRank(out dof);
                    if (!ok)
                    {
                        dofText = "<color=\"#FF3030\">DOF: " + dof + "</color>\n";
                    }
                    else if (dof == 0)
                    {
                        dofText = "<color=\"#30FF30\">DOF: " + dof + "</color>\n";
                    }
                    else
                    {
                        dofText = "<color=\"#FFFFFF\">DOF: " + dof + "</color>\n";
                    }
                }
                else
                {
                    dofText = "<color=\"#303030\">DOF: ?</color>\n";
                }
            }
            result += dofText;
            //result += sys.stats;
            resultText.text = result.ToString();
        }

        detail.Update();
        meshDirty = meshDirty | detail.features.OfType <MeshFeature>().Any(f => f.dirty);
        detail.MarkDirty();
        detail.UpdateDirtyUntil(activeFeature);
        if (meshDirty && !suppressCombine)
        {
            meshDirty = false;
            mesh.Clear();
            Solid result        = null;
            int   combinedCount = 0;
            foreach (var f in detail.features)
            {
                var mf = f as MeshFeature;
                if (mf != null)
                {
                    if (result == null)
                    {
                        result = mf.solid;
                    }
                    else
                    {
                        if (mf.combined == null)
                        {
                            //#if UNITY_WEBGL
                            //if(combinedCount > 0) {
                            //	break;
                            //}
                            //#endif
                            switch (mf.operation)
                            {
                            case CombineOp.Union: mf.combined = Solids.Union(result, mf.solid); break;

                            case CombineOp.Difference: mf.combined = Solids.Difference(result, mf.solid); break;

                            case CombineOp.Intersection: mf.combined = Solids.Intersection(result, mf.solid); break;
                            }
                            combinedCount++;
                        }
                        result = mf.combined;
                    }
                }
                if (f == activeFeature)
                {
                    break;
                }
            }
            Debug.Log("combined " + combinedCount + " meshes");
            solid = result;
            if (result != null)
            {
                mesh.FromSolid(result);
            }
        }

        double dist = -1.0;

        hovered = detail.HoverUntil(Input.mousePosition, Camera.main, UnityEngine.Matrix4x4.identity, ref dist, activeFeature);
        if (hovered == null && solid != null)
        {
            var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            var id  = solid.Raytrace(ray);
            selectedMesh.FromSolid(solid, id);
        }
        else
        {
            selectedMesh.Clear();
        }

        canvas.ClearStyle("hovered");
        if (hovered != null)
        {
            canvas.SetStyle("hovered");
            if (hovered is IEntity)
            {
                canvas.DrawSegments((hovered as IEntity).SegmentsInPlane(null));
            }
            else
            if (hovered is SketchObject)
            {
                (hovered as SketchObject).Draw(canvas);
            }
        }

        if (activeFeature is SketchFeatureBase)
        {
            var sk = activeFeature as SketchFeatureBase;
            if (sk.ShouldRedrawConstraints() || justSwitchedToSketch)
            {
                sk.DrawConstraints(canvas);
            }
        }
        else
        {
            canvas.ClearStyle("constraints");
        }
    }