Пример #1
0
    public static void Parallelogram()
    {
        bool repeat = true;

        while (repeat == true)
        {
            Console.Clear();

            double a;
            double b;
            double h;

            Console.WriteLine("Okay, so give me side edges, and the height");
            a = Convert.ToDouble(Console.ReadLine());
            b = Convert.ToDouble(Console.ReadLine());
            h = Convert.ToDouble(Console.ReadLine());

            Console.Clear();

            Console.ForegroundColor = ConsoleColor.DarkGreen;
            Console.WriteLine("Parallelogram: " + "Side edge 1 - " + a + " / Side edge 2 - " + " / Height " + h + "\n");
            //Calculate parallelogram area
            double area = a * h;
            Console.WriteLine("Parallelogram area = " + area);

            //Calculate parallelogram perimeter
            double perimeter = a * 2 + b * 2;
            Console.WriteLine("Parallelogram perimeter = " + perimeter);

            Console.ForegroundColor = ConsoleColor.White;

            Solids.Repeat(ref repeat, "parallelogram");
        }
    }
Пример #2
0
    public static void Diamond()
    {
        bool repeat = true;

        while (repeat == true)
        {
            Console.Clear();

            double a;
            double h;

            Console.WriteLine("Okay, give me side edge and height");
            a = Convert.ToDouble(Console.ReadLine());
            h = Convert.ToDouble(Console.ReadLine());

            Console.Clear();

            Console.ForegroundColor = ConsoleColor.DarkGreen;
            Console.WriteLine("Diamond: " + " Side edge 1 - " + a + " / Height - " + h + "\n");

            //Calculate diamond area
            double area = a * h;
            Console.WriteLine("Diamond area = " + area);

            //Calculate diamond perimeter
            double perimeter = a * 4;
            Console.WriteLine("Diamond perimeter = " + perimeter);

            Console.ForegroundColor = ConsoleColor.White;

            Solids.Repeat(ref repeat, "diamond");
        }
    }
Пример #3
0
        public override int GetHashCode()
        {
            int hashCode = 1803674884;

            hashCode = hashCode * -1521134295 + Id.GetHashCode();
            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(Name);

            hashCode = hashCode * -1521134295 + IsIntermediate.GetHashCode();
            hashCode = hashCode * -1521134295 + IsDanger.GetHashCode();
            hashCode = hashCode * -1521134295 + IsProduction.GetHashCode();
            hashCode = hashCode * -1521134295 + IsActive.GetHashCode();
            hashCode = hashCode * -1521134295 + IntermediateNrD.GetHashCode();
            hashCode = hashCode * -1521134295 + ClpSignalWordId.GetHashCode();
            hashCode = hashCode * -1521134295 + ClpMsdsId.GetHashCode();
            hashCode = hashCode * -1521134295 + FunctionId.GetHashCode();
            hashCode = hashCode * -1521134295 + Price.GetHashCode();
            hashCode = hashCode * -1521134295 + CurrencyId.GetHashCode();
            hashCode = hashCode * -1521134295 + UnitId.GetHashCode();
            hashCode = hashCode * -1521134295 + Density.GetHashCode();
            hashCode = hashCode * -1521134295 + Solids.GetHashCode();
            hashCode = hashCode * -1521134295 + Ash450.GetHashCode();
            hashCode = hashCode * -1521134295 + VOC.GetHashCode();
            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(Remarks);

            hashCode = hashCode * -1521134295 + LoginId.GetHashCode();
            hashCode = hashCode * -1521134295 + DateCreated.GetHashCode();
            hashCode = hashCode * -1521134295 + DateUpdated.GetHashCode();
            return(hashCode);
        }
Пример #4
0
    public static void Triangle()
    {
        bool repeat = true;

        while (repeat == true)
        {
            Console.Clear();

            double a;
            double b;
            double c;
            double h;

            string answer;
            Console.WriteLine("Okay, so give me side edge and the height");
            a = Convert.ToDouble(Console.ReadLine());
            h = Convert.ToDouble(Console.ReadLine());

            Console.Clear();
            Console.WriteLine("Is this equilateral triangle? Yes/No");

            answer = Console.ReadLine();

            if (answer == "Yes" || answer == "yes")
            {
                Console.Clear();

                Console.ForegroundColor = ConsoleColor.DarkGreen;
                Console.WriteLine("Triangle: " + "basic - " + a + " / Height - " + h + "\n");

                //Calculate perimeter of the traingle
                double perimeter = a * 3;
                Console.WriteLine("Perimeter of the triangle = " + perimeter);
            }
            else
            {
                Console.Clear();

                Console.WriteLine("Okay, so I'm gonna need two more side edges");
                b = Convert.ToDouble(Console.ReadLine());
                c = Convert.ToDouble(Console.ReadLine());

                Console.Clear();

                Console.ForegroundColor = ConsoleColor.DarkGreen;
                Console.WriteLine("Triangle: " + " Side edge 1 - " + a + " / Side edge 2 - " + b + " / Side edge 3 - " + c + " / Height - " + h + "\n");

                //Calculate perimeter of the triangle
                double perimeter = a + b + c;
                Console.WriteLine("Perimeter of the triangle = " + perimeter);
            }

            //Calculate triangle area
            double area = a * h / 2;
            Console.WriteLine("Triangle area = " + area);

            Console.ForegroundColor = ConsoleColor.White;
            Solids.Repeat(ref repeat, "triangle");
        }
    }
Пример #5
0
    public static void Deltoid()
    {
        bool repeat = true;

        while (repeat == true)
        {
            Console.Clear();

            double a;
            double b;
            double p;
            double d;

            Console.WriteLine("Okay, so I'm gonna need both side edges, and both diagonals");

            a = Convert.ToDouble(Console.ReadLine());
            b = Convert.ToDouble(Console.ReadLine());
            p = Convert.ToDouble(Console.ReadLine());
            d = Convert.ToDouble(Console.ReadLine());

            Console.Clear();
            Console.ForegroundColor = ConsoleColor.DarkGreen;
            Console.WriteLine("Deltoid: " + "Side edge 1 - " + a + " / Side edge 2 - " + b + " / Diagonal 1 " + p + " / Diagonal 2 \n");
            //Calculate delotid area
            double area = (p * d) / 2;
            Console.WriteLine("delotid area = " + area);

            //Calculate the perimeter of the delotid
            double perimeter = a * 2 + b * 2;
            Console.WriteLine("Delotid perimeter = " + perimeter);

            Console.ForegroundColor = ConsoleColor.White;
            Solids.Repeat(ref repeat, "deltoid");
        }
    }
Пример #6
0
        /// <summary>
        /// Clears (removes) all assignments from the specified group.
        /// </summary>
        public void Clear()
        {
            foreach (var point in Points)
            {
                Remove(point);
            }

            foreach (var frame in Frames)
            {
                Remove(frame);
            }

            foreach (var area in Areas)
            {
                Remove(area);
            }

            foreach (var link in Links)
            {
                Remove(link);
            }

            Points.Clear();
            Frames.Clear();
            Areas.Clear();
            Links.Clear();
            Cables.Clear();
            Tendons.Clear();
            Solids.Clear();
        }
Пример #7
0
    public static void Square()
    {
        bool repeat = true;

        while (repeat == true)
        {
            Console.Clear();
            double a;

            Console.WriteLine("Okay, so give me side edge");

            a = Convert.ToDouble(Console.ReadLine());

            Console.Clear();
            Console.ForegroundColor = ConsoleColor.DarkGreen;
            Console.WriteLine("Square: " + "Side edge 1 - " + a + "\n");

            //Calculate square area
            double area = a * a;
            Console.WriteLine("Square area = " + area);

            //Calculate diagonal of the square
            double diagonal = Math.Sqrt(a);
            Console.WriteLine("Diagonal of the square = " + diagonal);

            //Calculate the perimeter of the square
            double perimeter = a * 4;
            Console.WriteLine("The perimeter of the square = " + perimeter);

            Console.ForegroundColor = ConsoleColor.White;
            Solids.Repeat(ref repeat, "square");
        }
    }
Пример #8
0
    public static void Circle()
    {
        bool repeat = true;

        while (repeat == true)
        {
            Console.Clear();

            double r;

            Console.WriteLine("Okay, so I'm gonna need radius");
            r = Convert.ToDouble(Console.ReadLine());

            Console.Clear();
            Console.ForegroundColor = ConsoleColor.DarkGreen;
            Console.WriteLine("Circle: " + "Radius - " + r + "\n");

            //Calculate circle area
            double area = Math.PI * Math.Pow(r, 2);
            Console.WriteLine("Circle area = " + area);

            //Calculate circle perimeter
            double perimeter = 2 * Math.PI * r;
            Console.WriteLine("Circle perimeter = " + perimeter);

            Console.ForegroundColor = ConsoleColor.White;
            Solids.Repeat(ref repeat, "circle");
        }
    }
Пример #9
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            basicEffect = new BasicEffect(GraphicsDevice);

            LedorSystem = new ParticleSystem("Sans titre", 10000, 1, BlendState.NonPremultiplied, false, Content, GraphicsDevice);
            LedorSystem.SetViewProjection(
                Matrix.CreateLookAt(
                    new Vector3(50 * (float)Math.Sin(angle), 2, 50 * (float)Math.Cos(angle)),
                    new Vector3(0, 0, 0),
                    Vector3.UnitY),
                projection);

            var sphere1 = Solids.Sphere(new SphereOptions {
                Radius = 1, Center = new Vector3(-0.5f, 0, 0), SolidColor = Color.White
            });
            var sphere2 = Solids.Sphere(new SphereOptions {
                Radius = 1, Center = new Vector3(0.5f, 0, 0), SolidColor = Color.Red
            });
            var sphere1XNA = sphere1.Substract(sphere2);

            ListMesh = Convertor.csgToMeshesWithCache(sphere1XNA);

            vertices = new VertexPositionColorNormal[ListMesh.Count][];
            indices  = new short[ListMesh.Count][];

            for (int M = 0; M < ListMesh.Count; ++M)
            {
                Mesh ActiveMesh = ListMesh[M];
                vertices[M] = new VertexPositionColorNormal[ActiveMesh.vertices.Count];

                for (int V = 0; V < ActiveMesh.vertices.Count; ++V)
                {
                    vertices[M][V] = new VertexPositionColorNormal()
                    {
                        Position = ActiveMesh.vertices[V],
                        Color    = Color.FromNonPremultiplied((int)ActiveMesh.colors[V][0],
                                                              (int)ActiveMesh.colors[V][1],
                                                              (int)ActiveMesh.colors[V][2],
                                                              (int)ActiveMesh.colors[V][3]),
                        Normal = new Vector3()
                    };
                }


                indices[M] = new short[ActiveMesh.triangles.Count * 3];

                for (int T = 0; T < ActiveMesh.triangles.Count; ++T)
                {
                    indices[M][T * 3]     = (short)ActiveMesh.triangles[T][0];
                    indices[M][T * 3 + 1] = (short)ActiveMesh.triangles[T][1];
                    indices[M][T * 3 + 2] = (short)ActiveMesh.triangles[T][2];
                }

                CalculateNormals(vertices[M], indices[M]);
            }
        }
Пример #10
0
        public void TryPlayerMove(CPlayer plr, Direction dir)
        {
            bool successful = true;

            Solids?.Invoke(plr, dir, ref successful);
            if (successful)
            {
                plr.Move(dir);
            }
        }
Пример #11
0
        private void GetSolids()
        {
            var options = new Options
            {
                ComputeReferences = true // Обязательно ставить true, так как по Reference строятся размеры
            };

            foreach (var geometryObject in Wall.get_Geometry(options).GetTransformed(Transform.Identity))
            {
                var solid = geometryObject as Solid;
                if (solid != null && solid.Volume > 0.0)
                {
                    Solids.Add(solid);
                }
            }
        }
Пример #12
0
    public static void Rectangle()
    {
        bool repeat = true;

        while (repeat == true)
        {
            Console.Clear();

            double a;
            double b;

            Console.WriteLine("Okay, so give me his side edges");
            a = Convert.ToDouble(Console.ReadLine());
            b = Convert.ToDouble(Console.ReadLine());


            Console.Clear();

            Console.ForegroundColor = ConsoleColor.DarkGreen;
            Console.WriteLine("Rectangle: " + "Side edge 1 - " + a + " / Side edge 2 - " + b + "\n");
            //Calculate area of the rectangle
            double area = a * b;
            Console.WriteLine("Rectangle area = " + area);

            //Calculate diagonal of the rectangle
            double diagonal = Math.Sqrt(a * a + b * b);
            Console.WriteLine("Diagonal of the rectangle = " + diagonal);

            //Calculate perimeter of the rectangle
            double perimeter = a * 2 + b * 2;
            Console.WriteLine("perimeter of the rectangle = " + perimeter);

            Console.ForegroundColor = ConsoleColor.White;

            Solids.Repeat(ref repeat, "rectangle");
        }
    }
Пример #13
0
        /// <summary>
        /// Clears (removes) all assignments from the specified group.
        /// </summary>
        /// <exception cref="CSiException"><see cref="CSiApiBase.API_DEFAULT_ERROR_CODE" /></exception>
        public void Clear()
        {
#if !BUILD_ETABS2015 && !BUILD_ETABS2016 && !BUILD_ETABS2017
            _app?.Model.Definitions.Groups.Clear(Name);
#else
            //Node
            foreach (var point in Points)
            {
                Remove(point);
            }
            //Frame
            foreach (var frame in Frames)
            {
                Remove(frame);
            }
            //Area
            foreach (var area in Areas)
            {
                Remove(area);
            }
            //Link
            foreach (var link in Links)
            {
                Remove(link);
            }
#endif
            Points.Clear();
            Frames.Clear();
            Areas.Clear();
            Links.Clear();
#if !BUILD_ETABS2015 && !BUILD_ETABS2016 && !BUILD_ETABS2017
            Cables.Clear();
            Tendons.Clear();
            Solids.Clear();
#endif
        }
Пример #14
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");
        }
    }
Пример #15
0
        /// <summary>
        /// Creates or populates Revit elements based on the information contained in this class.
        /// </summary>
        /// <param name="doc">The document.</param>
        protected override void Create(Document doc)
        {
            Transform lcs = (ObjectLocation != null) ? ObjectLocation.TotalTransform : Transform.Identity;

            if (ProductRepresentation != null)
            {
                if (ProductRepresentation.IsValid())
                {
                    using (IFCImportShapeEditScope shapeEditScope = IFCImportShapeEditScope.Create(doc, this))
                    {
                        shapeEditScope.GraphicsStyleId = m_GraphicsStyleId;
                        shapeEditScope.CategoryId      = CategoryId;

                        // The name can be added as well. but it is usually less useful than 'oid'
                        string myId = GlobalId; // + "(" + Name + ")";

                        ProductRepresentation.CreateProductRepresentation(shapeEditScope, lcs, lcs, myId);

                        int numSolids = Solids.Count;
                        int numVoids  = Voids.Count;
                        if ((numSolids > 0) && (numVoids > 0))
                        {
                            // We may have some GeometryInstances.  These need to be "exploded" to do the cutting.
                            for (int solidIdx = 0; solidIdx < numSolids; solidIdx++)
                            {
                                if (Solids[solidIdx].GeometryObject is GeometryInstance)
                                {
                                    //// This code currently doesn't work, so commented out.
                                    //GeometryInstance geomInst = Solids[solidIdx].GeometryObject as GeometryInstance;
                                    //GeometryElement geomElem = geomInst.GetInstanceGeometry();

                                    //foreach (GeometryObject geomObj in geomElem)
                                    //{
                                    //if (geomObj is Solid)
                                    //Solids.Add(IFCSolidInfo.Create(Solids[solidIdx].Id, geomObj as Solid));
                                    //else if (geomObj is Mesh)
                                    //Solids.Add(IFCSolidInfo.Create(Solids[solidIdx].Id, geomObj as Mesh));
                                    //else if (geomObj is GeometryInstance)
                                    //IFCImportFile.TheLog.LogError(Solids[solidIdx].Id, "Can't cut nested mapped items, ignoring " + numVoids + " void(s).", false);

                                    // Other items are irrelevant here.
                                    //}

                                    //Solids.RemoveAt(solidIdx);
                                    //solidIdx--;
                                    //numSolids--;
                                }
                            }

                            // This may be different than before, with the addition of solids from FamilyInstances.
                            numSolids = Solids.Count;

                            // Attempt to cut each solid with each void.
                            for (int solidIdx = 0; solidIdx < numSolids; solidIdx++)
                            {
                                if (!(Solids[solidIdx].GeometryObject is Solid))
                                {
                                    // Assume that we only deal with solids, meshes and instances.
                                    string typeName = (Solids[solidIdx].GeometryObject is Mesh) ? "mesh" : "instance";
                                    IFCImportFile.TheLog.LogError(Id, "Can't cut " + typeName + " geometry, ignoring " + numVoids + " void(s).", false);
                                    continue;
                                }

                                for (int voidIdx = 0; voidIdx < numVoids; voidIdx++)
                                {
                                    if (!(Voids[voidIdx].GeometryObject is Solid))
                                    {
                                        IFCImportFile.TheLog.LogError(Id, "Can't cut Solid geometry with a Mesh (# " + Voids[voidIdx].Id + "), ignoring.", false);
                                        continue;
                                    }

                                    Solids[solidIdx].GeometryObject =
                                        IFCGeometryUtil.ExecuteSafeBooleanOperation(Solids[solidIdx].Id, Voids[voidIdx].Id,
                                                                                    Solids[solidIdx].GeometryObject as Solid, Voids[voidIdx].GeometryObject as Solid,
                                                                                    BooleanOperationsType.Difference);
                                    if ((Solids[solidIdx].GeometryObject as Solid).Faces.IsEmpty)
                                    {
                                        Solids.RemoveAt(solidIdx);
                                        solidIdx--;
                                        numSolids--;
                                        break;
                                    }
                                }
                            }
                        }

                        bool addedCurves = shapeEditScope.AddPlanViewCurves(FootprintCurves, Id);

                        if ((numSolids > 0 || addedCurves))
                        {
                            if (GlobalId != null)
                            {
                                // If the GlobalId is null, this is a fake IfcProduct that we don't want to create into a DirectShape, or
                                // add to the caches in any way.  We only wanted to gather its geometry.
                                DirectShape shape = Importer.TheCache.UseElementByGUID <DirectShape>(doc, GlobalId);

                                if (shape == null)
                                {
                                    shape = IFCElementUtil.CreateElement(doc, CategoryId, Importer.ImportAppGUID(), GlobalId);
                                }

                                List <GeometryObject> directShapeGeometries = new List <GeometryObject>();
                                foreach (IFCSolidInfo geometryObject in Solids)
                                {
                                    // We need to check if the solid created is good enough for DirectShape.  If not, warn and use a fallback Mesh.
                                    GeometryObject currObject = geometryObject.GeometryObject;
                                    if (currObject is Solid)
                                    {
                                        Solid solid = currObject as Solid;
                                        if (!shape.IsValidGeometry(solid))
                                        {
                                            IFCImportFile.TheLog.LogWarning(Id, "Couldn't create valid solid, reverting to mesh.", false);
                                            directShapeGeometries.AddRange(IFCGeometryUtil.CreateMeshesFromSolid(solid));
                                            currObject = null;
                                        }
                                    }

                                    if (currObject != null)
                                    {
                                        directShapeGeometries.Add(currObject);
                                    }
                                }

                                // We will use the first IfcTypeObject id, if it exists.  In general, there should be 0 or 1.
                                ElementId typeId = ElementId.InvalidElementId;
                                foreach (IFCTypeObject typeObject in TypeObjects)
                                {
                                    if (typeObject.IsValidForCreation && typeObject.CreatedElementId != ElementId.InvalidElementId)
                                    {
                                        typeId = typeObject.CreatedElementId;
                                        break;
                                    }
                                }

                                shape.SetShape(directShapeGeometries);
                                shapeEditScope.SetPlanViewRep(shape);

                                if (typeId != ElementId.InvalidElementId)
                                {
                                    shape.SetTypeId(typeId);
                                }

                                PresentationLayerNames.UnionWith(shapeEditScope.PresentationLayerNames);
                                m_CreatedElementId = shape.Id;
                            }
                        }
                    }
                }
                else
                {
                    IFCImportFile.TheLog.LogWarning(Id, "There is no valid geometry for this " + EntityType.ToString() + "; entity will not be built.", false);
                }
            }

            base.Create(doc);
        }
Пример #16
0
 /// <summary>
 /// Removes objects from the group.
 /// </summary>
 public void Remove(Solid item)
 {
     Solids.Remove(item);
     item.RemoveFromGroup(this);
 }
Пример #17
0
    private void Update()
    {
        if (activeFeature != null)
        {
            if (currentSketch != null && (currentSketch.GetSketch().IsConstraintsChanged() || currentSketch.GetSketch().IsEntitiesChanged()) || sys.IsDirty)
            {
                suppressSolve = false;
            }
            if (currentSketch != null && currentSketch.IsTopologyChanged())
            {
                UpdateSystem();
            }
            var res = (!suppressSolve || sys.HasDragged()) ? sys.Solve() : EquationSystem.SolveResult.DIDNT_CONVEGE;
            if (res == EquationSystem.SolveResult.DIDNT_CONVEGE)
            {
                suppressSolve = true;
            }
            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 += "Undo: " + undoRedo.Count() + "\n";
            result += "UndoSize: " + undoRedo.Size() + "\n";
            //result += sys.stats;
            resultText.text = result.ToString();
        }

        detail.UpdateUntil(activeFeature);
        //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;

                            case CombineOp.Assembly: mf.combined = Solids.Assembly(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);
            }
        }


        if (!CameraController.instance.IsMoving && !suppressHovering)
        {
            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");
        canvas.ClearStyle("hoveredPoints");
        if (hovered != null)
        {
            DrawCadObject(hovered, "hovered");
        }

        canvas.ClearStyle("selected");
        canvas.ClearStyle("selectedPoints");
        foreach (var idp in selection)
        {
            var obj = detail.GetObjectById(idp);
            if (obj == null)
            {
                continue;
            }
            DrawCadObject(obj, "selected");
        }

        if (selection.Count == 1)
        {
            var obj = detail.GetObjectById(selection[0]);
            inspector.Inspect(obj);
        }
        else
        {
            inspector.Inspect(activeFeature);
        }

        if (activeFeature is SketchFeatureBase)
        {
            var sk = activeFeature as SketchFeatureBase;
            sk.DrawConstraints(canvas);

            //var skk = activeFeature as SketchFeature;
            //if(skk != null) skk.DrawTriangulation(canvas);
        }
        else
        {
            canvas.ClearStyle("constraints");
        }
    }
Пример #18
0
        public Cube(string name)
        {
            var cube = Solids.Cube(1, true).Translate(0, 0.5);

            MeshData = MeshBuilder.FromSolid(cube, name);
        }
Пример #19
0
        /// <summary>
        /// Creates or populates Revit elements based on the information contained in this class.
        /// </summary>
        /// <param name="doc">The document.</param>
        protected override void Create(Document doc)
        {
            bool       preventInstances = false;
            IFCElement element          = this as IFCElement;

            if (element != null)
            {
                IFCOpeningElement openingElement = element as IFCOpeningElement;
                if (openingElement != null)
                {
                    preventInstances = true;
                }
                foreach (IFCFeatureElement opening in element.Openings)
                {
                    try
                    {
                        preventInstances = true;
                        // Create the actual Revit element based on the IFCFeatureElement here.
                        ElementId openingId = CreateElement(doc, opening);

                        // This gets around the issue that the Boolean operation between the void(s) in the IFCFeatureElement and
                        // the solid(s) in the IFCElement may use the Graphics Style of the voids in the resulting Solid(s), meaning
                        // that some faces may disappear when we turn off the visibility of IfcOpeningElements.
                        IList <IFCSolidInfo> voids = IFCElement.CloneElementGeometry(doc, opening, this, true);
                        if (voids != null)
                        {
                            foreach (IFCSolidInfo voidGeom in voids)
                            {
                                Voids.Add(voidGeom);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Importer.TheLog.LogError(opening.Id, ex.Message, false);
                    }
                }
            }
            if (HasValidTopLevelGeometry())
            {
                using (IFCImportShapeEditScope shapeEditScope = IFCImportShapeEditScope.Create(doc, this))
                {
                    shapeEditScope.GraphicsStyleId  = GraphicsStyleId;
                    shapeEditScope.CategoryId       = CategoryId;
                    shapeEditScope.PreventInstances = preventInstances;
                    // The name can be added as well. but it is usually less useful than 'oid'
                    string myId = GlobalId; // + "(" + Name + ")";

                    Transform lcs = IFCImportFile.TheFile.IFCProject.WorldCoordinateSystem;
                    if (lcs == null)
                    {
                        lcs = (ObjectLocation != null) ? ObjectLocation.TotalTransform : Transform.Identity;
                    }
                    else if (ObjectLocation != null)
                    {
                        lcs = lcs.Multiply(ObjectLocation.TotalTransform);
                    }

                    ProductRepresentation.CreateProductRepresentation(shapeEditScope, lcs, lcs, myId);

                    int numSolids = Solids.Count;
                    int numVoids  = Voids.Count;
                    if ((numSolids > 0) && (numVoids > 0))
                    {
                        // This may be different than before, with the addition of solids from FamilyInstances.
                        numSolids = Solids.Count;

                        // Attempt to cut each solid with each void.
                        for (int solidIdx = 0; solidIdx < numSolids; solidIdx++)
                        {
                            // We only cut body representation items.
                            if (Solids[solidIdx].RepresentationType != IFCRepresentationIdentifier.Body)
                            {
                                continue;
                            }

                            if (!(Solids[solidIdx].GeometryObject is Solid))
                            {
                                string typeName = (Solids[solidIdx].GeometryObject is Mesh) ? "mesh" : "instance";
                                Importer.TheLog.LogError(Id, "Can't cut " + typeName + " geometry, ignoring " + numVoids + " void(s).", false);
                                continue;
                            }

                            for (int voidIdx = 0; voidIdx < numVoids; voidIdx++)
                            {
                                if (!(Voids[voidIdx].GeometryObject is Solid))
                                {
                                    Importer.TheLog.LogError(Id, "Can't cut Solid geometry with a Mesh (# " + Voids[voidIdx].Id + "), ignoring.", false);
                                    continue;
                                }

                                Solids[solidIdx].GeometryObject =
                                    IFCGeometryUtil.ExecuteSafeBooleanOperation(Solids[solidIdx].Id, Voids[voidIdx].Id,
                                                                                Solids[solidIdx].GeometryObject as Solid, Voids[voidIdx].GeometryObject as Solid,
                                                                                BooleanOperationsType.Difference, null);
                                if ((Solids[solidIdx].GeometryObject as Solid).Faces.IsEmpty)
                                {
                                    Solids.RemoveAt(solidIdx);
                                    solidIdx--;
                                    numSolids--;
                                    break;
                                }
                            }
                        }
                    }

                    bool addedCurves = shapeEditScope.AddPlanViewCurves(FootprintCurves, Id);

                    if ((numSolids > 0 || addedCurves))
                    {
                        if (GlobalId != null)
                        {
                            // If the GlobalId is null, this is a fake IfcProduct that we don't want to create into a DirectShape, or
                            // add to the caches in any way.  We only wanted to gather its geometry.
                            DirectShape shape = Importer.TheCache.UseElementByGUID <DirectShape>(doc, GlobalId);

                            if (shape == null)
                            {
                                shape = IFCElementUtil.CreateElement(doc, CategoryId, GlobalId, null, Id);
                            }

                            List <GeometryObject> directShapeGeometries = new List <GeometryObject>();
                            foreach (IFCSolidInfo geometryObject in Solids)
                            {
                                // We need to check if the solid created is good enough for DirectShape.  If not, warn and use a fallback Mesh.
                                GeometryObject currObject = geometryObject.GeometryObject;
                                if (currObject is Solid)
                                {
                                    Solid solid = currObject as Solid;
                                    if (!shape.IsValidGeometry(solid))
                                    {
                                        Importer.TheLog.LogWarning(Id, "Couldn't create valid solid, reverting to mesh.", false);
                                        directShapeGeometries.AddRange(IFCGeometryUtil.CreateMeshesFromSolid(solid));
                                        currObject = null;
                                    }
                                }

                                if (currObject != null)
                                {
                                    directShapeGeometries.Add(currObject);
                                }
                            }

                            // We will use the first IfcTypeObject id, if it exists.  In general, there should be 0 or 1.
                            ElementId typeId = ElementId.InvalidElementId;
                            foreach (IFCTypeObject typeObject in TypeObjects)
                            {
                                if (typeObject.IsValidForCreation && typeObject.CreatedElementId != ElementId.InvalidElementId)
                                {
                                    typeId = typeObject.CreatedElementId;
                                    break;
                                }
                            }

                            shape.SetShape(directShapeGeometries);
                            shapeEditScope.SetPlanViewRep(shape);

                            if (typeId != ElementId.InvalidElementId)
                            {
                                shape.SetTypeId(typeId);
                            }

                            PresentationLayerNames.UnionWith(shapeEditScope.PresentationLayerNames);

                            CreatedElementId = shape.Id;
                            CreatedGeometry  = directShapeGeometries;
                        }
                    }
                }
            }
            else
            {
                if (this is IFCElement || this is IFCGrid)
                {
                    IList <IFCEntity> visitedEntities = new List <IFCEntity>();
                    visitedEntities.Add(this);
                    if (!HasValidSubElementGeometry(visitedEntities))
                    {
                        // We will not warn if this is an IfcSpatialStructureElement; those aren't expected to have their own geometry.
                        Importer.TheLog.LogWarning(Id, "There is no valid geometry for this " + EntityType.ToString() + "; entity will not be built.", false);
                    }
                }
            }

            base.Create(doc);
        }
Пример #20
0
        /// <summary>
        /// Creates or populates Revit elements based on the information contained in this class.
        /// </summary>
        /// <param name="doc">The document.</param>
        protected override void Create(Document doc)
        {
            bool       preventInstances = false;
            IFCElement element          = this as IFCElement;

            if (element != null)
            {
                preventInstances = this is IFCOpeningElement;
                foreach (IFCFeatureElement opening in element.Openings)
                {
                    try
                    {
                        preventInstances = true;
                        // Create the actual Revit element based on the IFCFeatureElement here.
                        ElementId openingId = CreateElement(doc, opening);

                        // This gets around the issue that the Boolean operation between the void(s) in the IFCFeatureElement and
                        // the solid(s) in the IFCElement may use the Graphics Style of the voids in the resulting Solid(s), meaning
                        // that some faces may disappear when we turn off the visibility of IfcOpeningElements.
                        IList <IFCSolidInfo> voids = IFCElement.CloneElementGeometry(doc, opening, this, true);
                        if (voids != null)
                        {
                            foreach (IFCSolidInfo voidGeom in voids)
                            {
                                IFCVoidInfo voidInfo = new IFCVoidInfo(voidGeom);
                                if (!Importer.TheProcessor.ApplyTransforms)
                                {
                                    // If we aren't applying transforms, then the Voids and Solids will be
                                    // in different coordinate spaces, so we need the transform of the
                                    // void, so we can transform it into the Solid coordinate space
                                    voidInfo.TotalTransform = opening?.ObjectLocation?.TotalTransform;
                                }

                                Voids.Add(voidInfo);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Importer.TheLog.LogError(opening.Id, ex.Message, false);
                    }
                }
            }
            if (HasValidTopLevelGeometry())
            {
                using (IFCImportShapeEditScope shapeEditScope = IFCImportShapeEditScope.Create(doc, this))
                {
                    shapeEditScope.GraphicsStyleId  = GraphicsStyleId;
                    shapeEditScope.CategoryId       = CategoryId;
                    shapeEditScope.PreventInstances = preventInstances;

                    // The name can be added as well. but it is usually less useful than 'oid'
                    string myId = GlobalId; // + "(" + Name + ")";

                    Transform lcs = IFCImportFile.TheFile.IFCProject.WorldCoordinateSystem;
                    if (lcs == null)
                    {
                        lcs = (ObjectLocation != null) ? ObjectLocation.TotalTransform : Transform.Identity;
                    }
                    else if (ObjectLocation != null)
                    {
                        lcs = lcs.Multiply(ObjectLocation.TotalTransform);
                    }

                    // If we are not applying transforms to the geometry, then pass in the identity matrix.
                    // Lower down this method we then pass lcs to the consumer element, so that it can apply
                    // the transform as required.
                    Transform transformToUse = Importer.TheProcessor.ApplyTransforms ? lcs : Transform.Identity;
                    ProductRepresentation.CreateProductRepresentation(shapeEditScope, transformToUse, transformToUse, myId);

                    int numSolids = Solids.Count;
                    // Attempt to cut each solid with each void.
                    for (int solidIdx = 0; solidIdx < numSolids; solidIdx++)
                    {
                        if (!CutSolidByVoids(Solids[solidIdx]))
                        {
                            Solids.RemoveAt(solidIdx);
                            solidIdx--;
                            numSolids--;
                        }
                    }

                    bool addedCurves = shapeEditScope.AddPlanViewCurves(FootprintCurves, Id);

                    if ((numSolids > 0 || addedCurves))
                    {
                        if (GlobalId != null)
                        {
                            // If the GlobalId is null, this is a fake IfcProduct that we don't want to create into a DirectShape, or
                            // add to the caches in any way.  We only wanted to gather its geometry.
                            DirectShape shape = Importer.TheCache.UseElementByGUID <DirectShape>(doc, GlobalId);

                            if (shape == null)
                            {
                                shape = IFCElementUtil.CreateElement(doc, CategoryId, GlobalId, null, Id, EntityType);
                            }

                            List <GeometryObject> directShapeGeometries = new List <GeometryObject>();
                            foreach (IFCSolidInfo geometryObject in Solids)
                            {
                                // We need to check if the solid created is good enough for DirectShape.  If not, warn and use a fallback Mesh.
                                GeometryObject currObject = geometryObject.GeometryObject;
                                if (currObject is Solid)
                                {
                                    Solid solid = currObject as Solid;
                                    if (!shape.IsValidGeometry(solid))
                                    {
                                        Importer.TheLog.LogWarning(Id, "Couldn't create valid solid, reverting to mesh.", false);
                                        directShapeGeometries.AddRange(IFCGeometryUtil.CreateMeshesFromSolid(solid));
                                        currObject = null;
                                    }
                                }

                                if (currObject != null)
                                {
                                    directShapeGeometries.Add(currObject);
                                }
                            }

                            // We will use the first IfcTypeObject id, if it exists.  In general, there should be 0 or 1.
                            IFCTypeObject typeObjectToUse = null;
                            foreach (IFCTypeObject typeObject in TypeObjects)
                            {
                                if (typeObject.IsValidForCreation && typeObject.CreatedElementId != ElementId.InvalidElementId)
                                {
                                    typeObjectToUse = typeObject;
                                    break;
                                }
                            }

                            if (!Importer.TheProcessor.PostProcessProduct(Id, typeObjectToUse?.Id, lcs,
                                                                          directShapeGeometries))
                            {
                                if (shape != null)
                                {
                                    shape.SetShape(directShapeGeometries);
                                    shapeEditScope.SetPlanViewRep(shape);

                                    if (typeObjectToUse != null && typeObjectToUse.CreatedElementId != ElementId.InvalidElementId)
                                    {
                                        shape.SetTypeId(typeObjectToUse.CreatedElementId);
                                    }
                                }
                            }

                            PresentationLayerNames.UnionWith(shapeEditScope.PresentationLayerNames);

                            CreatedElementId = shape.Id;
                            CreatedGeometry  = directShapeGeometries;
                        }
                    }
                }
            }
            else
            {
                if (this is IFCElement || this is IFCGrid)
                {
                    IList <IFCEntity> visitedEntities = new List <IFCEntity>();
                    visitedEntities.Add(this);
                    if (!HasValidSubElementGeometry(visitedEntities))
                    {
                        // We will not warn if this is an IfcSpatialStructureElement; those aren't expected to have their own geometry.
                        Importer.TheLog.LogWarning(Id, "There is no valid geometry for this " + EntityType.ToString() + "; entity will not be built.", false);
                    }
                }
            }

            base.Create(doc);
        }
Пример #21
0
        public PhysModel(Int32 modelIndex, Int32 solidCount, Byte[] collisionData, Byte[] keyData)
        {
            ModelIndex = modelIndex;
            KeyData    = System.Text.Encoding.ASCII.GetString(keyData);

            using (var ms = new MemoryStream(collisionData))
            {
                using (var br = new uReader(ms))
                {
                    for (Int32 i = 0; i < solidCount; i++)
                    {
                        var solid = new PhysModelSolid();
                        Solids.Add(solid);

                        var size   = br.ReadInt32();
                        var maxPos = br.BaseStream.Position + size;
                        solid.vphysicsID = br.ReadInt16();                         // ??
                        solid.version    = br.ReadInt16();
                        br.ReadInt16();
                        solid.modelType = br.ReadInt16();

                        if (solid.modelType != 0x0)
                        {
                            br.BaseStream.Seek(maxPos - br.BaseStream.Position, SeekOrigin.Current);
                            continue;
                        }

                        // ???
                        br.BaseStream.Seek(68, SeekOrigin.Current);

                        while (true)
                        {
                            var cc = new PhysModelConvex();
                            solid.Convexes.Add(cc);

                            var pos          = br.BaseStream.Position;
                            var vertexOffset = (Int32)(pos + br.ReadUInt32());

                            cc.BrushIndex = br.ReadInt32();
                            cc.idk2       = br.ReadByte();
                            cc.idk3       = br.ReadByte();
                            cc.idk4       = br.ReadUInt16();

                            var triCount = br.ReadInt16();
                            cc.idk5 = br.ReadUInt16();

                            for (Int32 j = 0; j < triCount; j++)
                            {
                                br.BaseStream.Seek(4, SeekOrigin.Current);

                                var index1 = br.ReadInt16();
                                br.ReadInt16();
                                var index2 = br.ReadInt16();
                                br.ReadInt16();
                                var index3 = br.ReadInt16();
                                br.ReadInt16();

                                try
                                {
                                    Vector3 v1 = collisionData.ReadAtPosition <Vector3>(vertexOffset + index1 * 16);
                                    Vector3 v2 = collisionData.ReadAtPosition <Vector3>(vertexOffset + index2 * 16);
                                    Vector3 v3 = collisionData.ReadAtPosition <Vector3>(vertexOffset + index3 * 16);

                                    cc.Triangles.Add(cc.Verts.Count);
                                    cc.Triangles.Add(cc.Verts.Count + 1);
                                    cc.Triangles.Add(cc.Verts.Count + 2);
                                    cc.Verts.Add(v1);
                                    cc.Verts.Add(v2);
                                    cc.Verts.Add(v3);
                                }
                                catch (System.Exception e)
                                {
                                    Debug.Log("Error on solid type: " + solid.modelType);
                                    Debug.LogError(e);
                                }
                            }

                            if (br.BaseStream.Position >= vertexOffset)
                            {
                                break;
                            }
                        }

                        Int64 remainder = maxPos - br.BaseStream.Position;
                        if (remainder > 0)
                        {
                            br.BaseStream.Seek(remainder, SeekOrigin.Current);
                        }
                    }
                }
            }

            KeyValues = KeyValues.Parse(KeyData);
        }
Пример #22
0
 /// <summary>
 /// Removes objects from the group.
 /// </summary>
 /// <exception cref="CSiException"><see cref="CSiApiBase.API_DEFAULT_ERROR_CODE" /></exception>
 public void Remove(Solid item)
 {
     setGroupAssign(item, remove: true);
     Solids.Remove(item);
     item.RemoveFromGroup(this);
 }
Пример #23
0
 /// <summary>
 /// Removes objects from the group.
 /// </summary>
 /// <exception cref="CSiException"><see cref="CSiApiBase.API_DEFAULT_ERROR_CODE" /></exception>
 public void Remove(Solid item)
 {
     setGroupAssign(item, remove: true);
     Solids.Remove(item);
 }
Пример #24
0
    public static void Trapeze()
    {
        bool repeat = true;

        while (repeat == true)
        {
            Console.Clear();

            double a;
            double b;
            double c;
            double d;
            double h;
            string answer;

            Console.WriteLine("Okay, give me both basic, height");
            a = Convert.ToDouble(Console.ReadLine());
            b = Convert.ToDouble(Console.ReadLine());
            h = Convert.ToDouble(Console.ReadLine());

            Console.WriteLine("Is this isosceles trapezoid? Yes/No");
            answer = Console.ReadLine();

            while (true)
            {
                if (answer == "Yes" || answer == "yes")
                {
                    Console.WriteLine("Okay, so give me side edge");
                    c = Convert.ToDouble(Console.ReadLine());

                    Console.ForegroundColor = ConsoleColor.DarkGreen;
                    Console.Clear();
                    Console.WriteLine("Trapeze: " + "basic 1 - " + a + " / basic 2 - " + b + " / Height " + h + "\n");

                    //Calculate perimeter of the trapeze
                    double perimeter = a + b + c * 2;
                    Console.WriteLine("Trapeze perimeter = " + perimeter);

                    break;
                }
                else if (answer == "No" || answer == "no")
                {
                    Console.WriteLine("Okay, so I'm gonna need two more side edges");
                    c = Convert.ToDouble(Console.ReadLine());
                    d = Convert.ToDouble(Console.ReadLine());

                    Console.ForegroundColor = ConsoleColor.DarkGreen;
                    Console.Clear();
                    Console.WriteLine("Trapeze: " + "basic 1 - " + a + " / basic 2 - " + b + " / Height " + h + "\n");

                    //Calculate perimeter of the trapeze
                    double perimeter = a + b + c + d;
                    Console.WriteLine("Trapeze perimeter = " + perimeter);
                    break;
                }
                else
                {
                    while (answer != "Yes" || answer != "yes" || answer != "No" || answer != "no")
                    {
                        Console.Clear();
                        Console.WriteLine("Is this isosceles trapezoid? Yes/No");
                        Console.WriteLine("I'm sorry, can You repeat?");
                        answer = Console.ReadLine();
                    }
                    break;
                }
            }
            //Calculate area of the trapeze
            double area = ((a + b) / 2) * h;
            Console.WriteLine("Trapeze area = " + area);

            Console.ForegroundColor = ConsoleColor.White;
            Solids.Repeat(ref repeat, "trapeze");
        }
    }
Пример #25
0
    public PhysModel(int modelIndex, int solidCount, byte[] collisionData, byte[] keyData)
    {
        ModelIndex = modelIndex;
        KeyData    = System.Text.Encoding.ASCII.GetString(keyData);

        using (var ms = new MemoryStream(collisionData))
        {
            using (var br = new BinaryReader(ms))
            {
                for (int i = 0; i < solidCount; i++)
                {
                    var solid = new PhysModelSolid();
                    Solids.Add(solid);

                    var size   = br.ReadInt32();
                    var maxPos = br.BaseStream.Position + size;
                    solid.PhysicsId = br.ReadInt16(); // ??
                    solid.Version   = br.ReadInt16();
                    var idk = br.ReadInt16();
                    solid.Type = br.ReadInt16();

                    if (solid.Type != 0x0)
                    {
                        continue;
                    }

                    // ???
                    br.BaseStream.Seek(68, SeekOrigin.Current);

                    while (true)
                    {
                        var cc = new PhysModelConvex();
                        solid.Convexes.Add(cc);

                        var pos          = br.BaseStream.Position;
                        var vertexOffset = (int)(pos + br.ReadUInt32());

                        cc.idk1 = br.ReadInt32();
                        cc.idk2 = br.ReadByte();
                        cc.idk3 = br.ReadByte();
                        cc.idk4 = br.ReadUInt16();

                        var triCount = br.ReadInt16();
                        cc.idk5 = br.ReadUInt16();

                        for (int j = 0; j < triCount; j++)
                        {
                            br.BaseStream.Seek(4, SeekOrigin.Current);

                            var index1 = br.ReadInt16();
                            var idk4   = br.ReadInt16();
                            var index2 = br.ReadInt16();
                            var idk5   = br.ReadInt16();
                            var index3 = br.ReadInt16();
                            var idk6   = br.ReadInt16();

                            var v1 = collisionData.ReadAtPosition <UnityEngine.Vector3>(vertexOffset + index1 * 16);
                            var v2 = collisionData.ReadAtPosition <UnityEngine.Vector3>(vertexOffset + index2 * 16);
                            var v3 = collisionData.ReadAtPosition <UnityEngine.Vector3>(vertexOffset + index3 * 16);

                            cc.Triangles.Add(cc.Verts.Count);
                            cc.Triangles.Add(cc.Verts.Count + 1);
                            cc.Triangles.Add(cc.Verts.Count + 2);
                            cc.Verts.Add(v1);
                            cc.Verts.Add(v2);
                            cc.Verts.Add(v3);
                        }

                        if (br.BaseStream.Position >= vertexOffset)
                        {
                            break;
                        }
                    }

                    var remainder = maxPos - br.BaseStream.Position;
                    if (remainder > 0)
                    {
                        br.BaseStream.Seek(remainder, SeekOrigin.Current);
                    }
                }
            }
        }

        KeyValues = KeyValues.Parse(KeyData);
    }
Пример #26
0
        static void Main(string[] args)
        {
            //Some parametres for window
            Console.WindowHeight = 50;
            Console.WindowWidth  = 120;
            Console.Title        = "Awesome Calculator";
            //###
            string answer = "";

            Console.WriteLine("What do You want to calculate?\n");
            Lists("Main menu");

            answer = Console.ReadLine();

            while (answer != "Exit" || answer != "exit")                       // Main loop for main menu
            {
                if (answer == "Solids" || answer == "solids" || answer == "1") // Checking if answer is for solids...
                {
                    while (answer != "Back")
                    {
                        Console.Clear();
                        Solids.SolidsFunc();
                        Solids.Exit(ref answer);
                    }
                }
                else if (answer == "Flat geometry" || answer == "Flat Geometry" || answer == "flat Geometry" || answer == "2") // ... or flat geometry
                {
                    while (answer != "Back")                                                                                   // Loop for flat geometry with switch. Breaking if You'll type "back".
                    {
                        Console.Clear();

                        Console.WriteLine("What do You want to calculate? (Flat geometry)\n");
                        Lists("Flat geometry");
                        answer = Console.ReadLine();

                        //Switch that checks which shape you want to calculate
                        switch (answer)
                        {
                        case "Square":
                        case "1":
                        {
                            FlatGeometry.Square();
                            break;
                        }

                        case "Triangle":
                        case "2":
                        {
                            FlatGeometry.Triangle();
                            break;
                        }

                        case "Rectangle":
                        case "3":
                        {
                            FlatGeometry.Rectangle();
                            break;
                        }

                        case "Parallelogram":
                        case "4":
                        {
                            FlatGeometry.Parallelogram();
                            break;
                        }

                        case "Diamond":
                        case "5":
                        {
                            FlatGeometry.Diamond();
                            break;
                        }

                        case "Trapeze":
                        case "6":
                        {
                            FlatGeometry.Trapeze();
                            break;
                        }

                        case "Circle":
                        case "7":
                        {
                            FlatGeometry.Circle();
                            break;
                        }

                        case "Deltoid":
                        case "8":
                        {
                            FlatGeometry.Deltoid();
                            break;
                        }

                        default:
                            break;
                        }
                    }
                }
                else if (answer == "Back" || answer == "back")  //If statement that makes you can go back
                {
                    Console.Clear();

                    Console.WriteLine("You are now here: Main menu\n");
                    Lists("Main menu");
                    answer = Console.ReadLine();
                }
                else
                {
                    Console.Clear();

                    Console.WriteLine("I'm sorry, can You repeat? You are here: Main menu\n");
                    Lists("Main menu");
                    answer = Console.ReadLine();
                }
            }
        }