コード例 #1
1
        // Try to see if the SolidWorks Body2 shape is a pure sphere.
        // If so,return true. If not a sphere, return false.
        // If it is a sphere, in 'radius' and 'center' one can get
        // the sphere data.
        public static bool SWbodyToSphere(Body2 swBody,
                                          ref double radius, 
                                          ref Point3D center)
        {
            bool issphere = false;
            if (swBody.GetFaceCount() == 1)
            {
                object[] mfaces = (object[])swBody.GetFaces();
                Face2 sphface = (Face2)mfaces[0];
                Surface msurf = (Surface)sphface.GetSurface();

                if (msurf.IsSphere())
                {
                    issphere= true;
                    double[] sphpar = (double[])msurf.SphereParams;
                    radius = sphpar[3];
                    center.X = sphpar[0]; center.Y = sphpar[1]; center.Z = sphpar[2];
                }
            }
            return issphere;
        }
コード例 #2
0
ファイル: MainForm.cs プロジェクト: alexionita95/VirtualPet
 private void RenderBody(Graphics gfx, Body2 body)
 {
     if (body.Shape is Circle)
     {
         Circle c         = body.Shape as Circle;
         Vec2   beginning = body.Position.Sub(c.Radius);
         gfx.DrawEllipse(Pens.Red, new Rectangle((int)beginning.X, (int)beginning.Y, (int)c.Radius * 2, (int)c.Radius * 2));
     }
     if (body.Shape is Poly2)
     {
         Poly2 p = body.Shape as Poly2;
         for (int i = 0; i < p.Vertices.Count; ++i)
         {
             Math.Matrix.Mat2 rot = Math.Matrix.Mat2.Rotation(body.Rotation);
             int  j   = i + 1 < p.Vertices.Count ? i + 1 : 0;
             Vec2 v1  = body.Position.Add(rot.Mul(p.Vertices[i]));
             Vec2 v2  = body.Position.Add(rot.Mul(p.Vertices[j]));
             Vec2 mid = v1.Add(v2).Div(2);
             Vec2 dir = mid.Add(rot.Mul(p.Normals[i]).Mul(10));
             gfx.DrawLine(Pens.Red, new Point((int)v1.X, (int)v1.Y), new Point((int)v2.X, (int)v2.Y));
             gfx.DrawLine(Pens.Green, new Point((int)mid.X, (int)mid.Y), new Point((int)dir.X, (int)dir.Y));
             gfx.FillEllipse(Brushes.Blue, new Rectangle((int)v1.X - 1, (int)v1.Y - 2, 4, 4));
             gfx.FillEllipse(Brushes.Blue, new Rectangle((int)v2.X - 1, (int)v2.Y - 2, 4, 4));
         }
     }
 }
コード例 #3
0
        static int CompareArea(Body2 a, Body2 b)
        {
            /* returns 0 for no change in total surface
             * returns 1 for negative change
             * returns 2 for positive change */

            object[] body1Faces, body2Faces;
            double   body1Area, body2Area;


            body1Faces = a.GetFaces();
            body2Faces = b.GetFaces();

            body1Area = 0;
            foreach (Face2 face in body1Faces)
            {
                body1Area += face.GetArea();
            }

            body2Area = 0;
            foreach (Face2 face in body2Faces)
            {
                body2Area += face.GetArea();
            }

            body1Area = Math.Round(body1Area, 8);
            body2Area = Math.Round(body2Area, 8);

            Logger.Info("Area A:" + body1Area + "\tArea B:" + body2Area);
            Program.report.AddDelayedLine("Area A:\t\t" + body1Area + "\t\tArea B:\t\t" + body2Area);

            return(IncDecDoubleReport(body1Area, body2Area, "CompareArea()"));
        }
コード例 #4
0
ファイル: MainForm.cs プロジェクト: alexionita95/VirtualPet
        public MainForm()
        {
            InitializeComponent();
            DoubleBuffered     = true;
            renderPanel.Paint += RenderPanel_Paint;
            Circle     c1 = new Circle(10);
            Circle     c2 = new Circle(100);
            Rectangle2 r  = new Rectangle2(renderPanel.Width / 2, 20);
            Rectangle2 r2 = new Rectangle2(renderPanel.Width / 4, 20);

            //Body2 b1 = new Body2(new Transform2(new Vec2(120,150)),0.6f, c1);
            Body2 b1 = new Body2(new Transform2(new Vec2(renderPanel.Width / 2, 10), 0), 0.6f, r2);

            b1.CoR = 0.95f;
            Body2 b2 = new Body2(new Transform2(new Vec2(renderPanel.Width / 2, renderPanel.Height - 100), 0), 0.0f, r);

            //Body2 b2 = new Body2(new Transform2(new Vec2(150,400), 0), 0.0f, c2);
            b2.CoR             = 0.4f;
            b1.Rotation        = 95;
            b2.Rotation        = 30;
            b2.EnableGravity   = false;
            b1.EnableGravity   = false;
            b1.DynamicFriction = 0.2f;
            b1.StaticFriction  = 0.4f;
            b2.DynamicFriction = 0.2f;
            b2.StaticFriction  = 0.4f;
            //b1.Collider = c1;
            //b2.Collider = c2;
            physics.AddBody(b1, true);
            // physics.ApplyForce(b1, new WindTest());
            physics.AddBody(b2, false);
            timer1.Start();
        }
コード例 #5
0
            public void AjouterDossier(BodyFolder dossier, Component2 comp)
            {
                Body2 corps = dossier.ePremierCorps();

                if (corps.IsNull())
                {
                    return;
                }

                String BaseMateriau;
                String Materiau = corps.eGetMateriauCorpsOuComp(comp, out BaseMateriau);
                string Profil;

                if (corps.eTypeDeCorps() == eTypeCorps.Tole)
                {
                    Double Ep = corps.eEpaisseurCorpsOuDossier(dossier);
                    if (Ep == -1)
                    {
                        WindowLog.EcrireF("Pb d'epaisseur sur le corps {0}", corps.Name);
                        return;
                    }

                    Profil = "Ep " + Ep.ToString();
                }
                else if (dossier.ePropExiste(CONSTANTES.PROFIL_NOM))
                {
                    Profil = dossier.eProp(CONSTANTES.PROFIL_NOM);
                }
                else
                {
                    Profil = NomVolume;
                }

                Ajouter(BaseMateriau, Materiau, Profil, dossier, comp);
            }
コード例 #6
0
 private void highlightComponents()
 {
     double[] notVisible = new double[9] {
         1, 0, 0, 1, 1, 1, 0.3, 0, 0
     };
     double[] visible = new double[9] {
         0, 1, 0, 1, 1, 1, 0.3, 0, 0
     };
     foreach (ComponentIdentifier ci in ourComponents)
     {
         object   bodyInfo;
         object[] bodies = (object[])ci.component.GetBodies3((int)swBodyType_e.swAllBodies, out bodyInfo);
         if (bodies != null && bodies.Length > 0)
         {
             for (int i = 0; i < bodies.Length; i++)
             {
                 Body2 body = (Body2)bodies[i];
                 if (ci.visibleToRawRays)
                 {
                     body.MaterialPropertyValues2 = visible;
                 }
                 else
                 {
                     body.MaterialPropertyValues2 = notVisible;
                 }
             }
         }
     }
 }
コード例 #7
0
        /// Specialized initialization for generic mate, given the two bodies to be connected, the
        /// positions of the two frames to connect on the bodies (each expressed
        /// in body or abs. coordinates).
        public virtual void Initialize(ChBodyFrame mbody1,     //< first body to link
                                       ChBodyFrame mbody2,     /// second body to link
                                       bool pos_are_relative,  //< true: following pos. are relative to bodies.
                                       ChFrame <double> mpos1, //< mate frame (slave), for 1st body (rel. or abs., see flag above)
                                       ChFrame <double> mpos2  //< mate frame (master), for 2nd body (rel. or abs., see flag above)
                                       )
        {
            Debug.Assert(mbody1 != mbody2);

            this.Body1 = mbody1;
            this.Body2 = mbody2;
            // this.SetSystem(mbody1.GetSystem());

            this.mask.SetTwoBodiesVariables(Body1.Variables(), Body2.Variables());

            if (pos_are_relative)
            {
                this.frame1 = mpos1;
                this.frame2 = mpos2;
            }
            else
            {
                // from abs to body-rel
                (this.Body1).TransformParentToLocal(mpos1, this.frame1);
                this.Body2.TransformParentToLocal(mpos2, this.frame2);
            }
        }
コード例 #8
0
        /// Override _all_ time, jacobian etc. updating.
        /// In detail, it computes jacobians, violations, etc. and stores
        /// results in inner structures.
        public override void update(double mytime, bool update_assets = true)
        {
            // Inherit time changes of parent class (ChLink), basically doing nothing :)
            base.update(mytime, update_assets);

            // compute jacobians
            ChVector AbsDist = Body1.TransformPointLocalToParent(pos1) - Body2.TransformPointLocalToParent(pos2);

            curr_dist = AbsDist.Length();
            ChVector D2abs  = ChVector.Vnorm(AbsDist);
            ChVector D2relB = Body2.TransformDirectionParentToLocal(D2abs);
            ChVector D2relA = Body1.TransformDirectionParentToLocal(D2abs);

            ChVector CqAx = D2abs;
            ChVector CqBx = -D2abs;

            ChVector CqAr = -ChVector.Vcross(D2relA, pos1);
            ChVector CqBr = ChVector.Vcross(D2relB, pos2);

            Cx.Get_Cq_a().ElementN(0) = CqAx.x;
            Cx.Get_Cq_a().ElementN(1) = CqAx.y;
            Cx.Get_Cq_a().ElementN(2) = CqAx.z;
            Cx.Get_Cq_a().ElementN(3) = CqAr.x;
            Cx.Get_Cq_a().ElementN(4) = CqAr.y;
            Cx.Get_Cq_a().ElementN(5) = CqAr.z;

            Cx.Get_Cq_b().ElementN(0) = CqBx.x;
            Cx.Get_Cq_b().ElementN(1) = CqBx.y;
            Cx.Get_Cq_b().ElementN(2) = CqBx.z;
            Cx.Get_Cq_b().ElementN(3) = CqBr.x;
            Cx.Get_Cq_b().ElementN(4) = CqBr.y;
            Cx.Get_Cq_b().ElementN(5) = CqBr.z;

            //***TO DO***  C_dt? C_dtdt? (may be never used..)
        }
コード例 #9
0
        // Test if a SolidWorks Body2 shape can be converted to a pure sphere.
        public static bool SWbodyToSphere(Body2 swBody)
        {
            double  dfoo = 0;
            Point3D vfoo = new Point3D(0, 0, 0);

            return(SWbodyToSphere(swBody, ref dfoo, ref vfoo));
        }
コード例 #10
0
        public override void Start()
        {
            // shaft1Direction = new Vector3(0, 0, 1);
            // shaft2Direction = new Vector3(0, 0, 1);

            // line1 = new GameObject().AddComponent<LineRenderer>();
            // line2 = new GameObject().AddComponent<LineRenderer>();

            ChCoordsys csys = new ChCoordsys(Utils.ToChrono(transform.position), Utils.ToChrono(transform.rotation));

            Initialize(body1, body2, csys);

            //// TODO: Check that this is correct.
            var rot1 = UnityEngine.Quaternion.Euler(shaft1Direction);

            //var rot1 = Quaternion.LookRotation(shaft1Direction.normalized);
            Set_local_shaft1(new ChFrame <double>(Utils.ToChrono(shaft1Origin), Utils.ToChrono(rot1)));
            var rot2 = UnityEngine.Quaternion.Euler(shaft2Direction);

            //var rot2 = Quaternion.LookRotation(shaft2Direction.normalized);
            Set_local_shaft2(new ChFrame <double>(Utils.ToChrono(shaft2Origin), Utils.ToChrono(rot2)));

            var height        = 2 * transform.localScale.y;
            var pulley2height = Body2.GetType();

            Set_r1(4);
            Set_r2(2);

            //ChSystem msystem = FindObjectOfType<ChSystem>();
            // msystem.AddLink(this);
            ChSystem.system.AddLink(this);
        }
コード例 #11
0
        public void MakeTriangles()
        {
            swSketchManager = modDoc.SketchManager;
            var i = 0;

            foreach (var verts in stlSurfaceVertices)
            {
                swSketchManager.Insert3DSketch(true);
                var p1 = verts[0];
                var p2 = verts[1];
                var p3 = verts[2];
                stlSurfaces[i].l1 = swSketchManager.CreateLine((double)p1.x, (double)p1.y, (double)p1.z, (double)p2.x, (double)p2.y, (double)p2.z) as SketchLine;
                stlSurfaces[i].l2 = swSketchManager.CreateLine((double)p2.x, (double)p2.y, (double)p2.z, (double)p3.x, (double)p3.y, (double)p3.z) as SketchLine;
                stlSurfaces[i].l3 = swSketchManager.CreateLine((double)p3.x, (double)p3.y, (double)p3.z, (double)p1.x, (double)p1.y, (double)p1.z) as SketchLine;
                var plane = modDoc.InsertPlanarRefSurface();
                var name  = "Surface-Plane" + (i + 1).ToString();
                modDoc.Extension.SelectByID(name, "SURFACEBODY", 0, 0, 0, false, 0, null);
                Body2 body = modDoc.ISelectionManager.GetSelectedObject(1);
                body.SetMaterialProperty("Default", "solidworks materials.sldmat", "Pure Gold");
                stlSurfaces[i].b = body;
                i++;
            }
            modDoc.ViewZoomtofit2();
            //swSketchManager.InsertSketch(true);
            Finish();
        }
コード例 #12
0
ファイル: OutilsCommun.cs プロジェクト: Titifonky/SwExtension
        public static void PlierTole(this Body2 Tole, ModelDoc2 mdl, String nomConfigPliee)
        {
            var tmpTole = Tole;

            if (tmpTole.IsNull())
            {
                tmpTole = mdl.ePartDoc().eChercherCorps(CONSTANTES.NOM_CORPS_DEPLIEE, false);

                if (tmpTole.IsNull())
                {
                    return;
                }
            }

            Feature FonctionDepliee = tmpTole.eFonctionEtatDepliee();

            FonctionDepliee.eModifierEtat(swFeatureSuppressionAction_e.swSuppressFeature, nomConfigPliee);

            mdl.eEffacerSelection();

            FonctionDepliee.eParcourirSousFonction(
                f =>
            {
                if ((f.Name.ToLowerInvariant() == CONSTANTES.LIGNES_DE_PLIAGE.ToLowerInvariant()) ||
                    (f.Name.ToLowerInvariant() == CONSTANTES.CUBE_DE_VISUALISATION.ToLowerInvariant()))
                {
                    f.eSelect(true);
                }
                return(false);
            }
                );

            mdl.BlankSketch();
            mdl.eEffacerSelection();
        }
コード例 #13
0
ファイル: OutilsCommun.cs プロジェクト: Titifonky/SwExtension
        public static void DeplierTole(this Body2 Tole, ModelDoc2 mdl, String nomConfigDepliee)
        {
            Feature FonctionDepliee = Tole.eFonctionEtatDepliee();

            FonctionDepliee.eModifierEtat(swFeatureSuppressionAction_e.swUnSuppressFeature, nomConfigDepliee);
            FonctionDepliee.eModifierEtat(swFeatureSuppressionAction_e.swUnSuppressDependent, nomConfigDepliee);

            mdl.eEffacerSelection();

            FonctionDepliee.eParcourirSousFonction(
                f =>
            {
                f.eModifierEtat(swFeatureSuppressionAction_e.swUnSuppressFeature, nomConfigDepliee);

                if ((f.Name.ToLowerInvariant() == CONSTANTES.LIGNES_DE_PLIAGE.ToLowerInvariant()) ||
                    (f.Name.ToLowerInvariant() == CONSTANTES.CUBE_DE_VISUALISATION.ToLowerInvariant()))
                {
                    f.eSelect(true);
                }
                return(false);
            }
                );

            mdl.UnblankSketch();
            mdl.eEffacerSelection();

            //// Si des corps autre que la tole dépliée sont encore visible dans la config, on les cache et on recontruit tout
            //foreach (Body2 pCorps in mdl.ePartDoc().eListeCorps(false))
            //{
            //    if ((pCorps.Name == CONSTANTES.NOM_CORPS_DEPLIEE))
            //        pCorps.eVisible(true);
            //    else
            //        pCorps.eVisible(false);
            //}
        }
コード例 #14
0
        /// Initialization based on passing two vectors (point + dir) on the
        /// two bodies, they will represent the X axes of the two frames (Y and Z will
        /// be built from the X vector via Gram Schmidt orthonormalization).
        /// Use the other ChLinkMateGeneric::Initialize() if you want to set the two frames directly.
        public virtual void Initialize(ChBodyFrame mbody1,    //< first body to link
                                       ChBodyFrame mbody2,    //< second body to link
                                       bool pos_are_relative, //< true: following pos. are relative to bodies.
                                       ChVector mpt1,         //< origin of slave frame 1, for 1st body (rel. or abs., see flag above)
                                       ChVector mpt2,         //< origin of master frame 2, for 2nd body (rel. or abs., see flag above)
                                       ChVector mnorm1,       //< X axis of slave plane, for 1st body (rel. or abs., see flag above)
                                       ChVector mnorm2        //< X axis of master plane, for 2nd body (rel. or abs., see flag above)
                                       )
        {
            Debug.Assert(mbody1 != mbody2);

            this.Body1 = mbody1;
            this.Body2 = mbody2;
            // this.SetSystem(mbody1.GetSystem());

            this.mask.SetTwoBodiesVariables(Body1.Variables(), Body2.Variables());

            ChVector            mx   = new ChVector(0, 0, 0);
            ChVector            my   = new ChVector(0, 0, 0);
            ChVector            mz   = new ChVector(0, 0, 0);
            ChVector            mN   = new ChVector(0, 0, 0);
            ChMatrix33 <double> mrot = new ChMatrix33 <double>();

            ChFrame <double> mfr1 = new ChFrame <double>();
            ChFrame <double> mfr2 = new ChFrame <double>();

            if (pos_are_relative)
            {
                mN = mnorm1;
                mN.DirToDxDyDz(ref mx, ref my, ref mz, new ChVector(0, 1, 0));
                mrot.Set_A_axis(mx, my, mz);
                mfr1.SetRot(mrot);
                mfr1.SetPos(mpt1);

                mN = mnorm2;
                mN.DirToDxDyDz(ref mx, ref my, ref mz, new ChVector(0, 1, 0));
                mrot.Set_A_axis(mx, my, mz);
                mfr2.SetRot(mrot);
                mfr2.SetPos(mpt2);
            }
            else
            {
                ChVector temp = ChVector.VECT_Z;
                // from abs to body-rel
                mN = this.Body1.TransformDirectionParentToLocal(mnorm1);
                mN.DirToDxDyDz(ref mx, ref my, ref mz, temp);
                mrot.Set_A_axis(mx, my, mz);
                mfr1.SetRot(mrot);
                mfr1.SetPos(this.Body1.TransformPointParentToLocal(mpt1));

                mN = this.Body2.TransformDirectionParentToLocal(mnorm2);
                mN.DirToDxDyDz(ref mx, ref my, ref mz, temp);
                mrot.Set_A_axis(mx, my, mz);
                mfr2.SetRot(mrot);
                mfr2.SetPos(this.Body2.TransformPointParentToLocal(mpt2));
            }

            this.frame1 = mfr1;
            this.frame2 = mfr2;
        }
コード例 #15
0
ファイル: Shaft.cs プロジェクト: DmitryGubkin/Old-Projects
        private void AddChamferFillet()                            // add chamfer or fillet on the edges
        {
            PartDoc SwPart    = (PartDoc)SwApp.IActiveDoc2;        // get intarfaces of PartDoc
            Array   AllBodies = (Array)SwPart.GetBodies2(0, true); //get array of bodys
            Body2   SwBody    = AllBodies.GetValue(0) as Body2;
            //get first body of array, because we have single solid body at the active document
            Array  AllEges      = (Array)SwBody.GetEdges();                 //get array of body edges
            int    current_edge = 0;                                        // current edge index of body
            Entity ent          = AllEges.GetValue(current_edge) as Entity; // needs to use some intarfaces such as Select4()
            bool   flag         = true;                                     // flag

            for (int i = 0; i < Stages.Count; i++)
            {
                ent = AllEges.GetValue(current_edge) as Entity;
                ent.Select4(false, null); //select firs edge

                if (flag == true)
                //do chamfer or fillet on the current edge of body
                {
                    AddEdgeFeature(i, true); // add feature on start of stage
                    current_edge++;          // index of the next edge
                }

                ent = AllEges.GetValue(current_edge) as Entity;
                ent.Select4(false, null);     //select next edge

                if (i == (Stages.Count - 1))  // end ege of whole shaft
                {
                    AddEdgeFeature(i, false); //add feature on end of stage
                    break;                    //break cycle
                }


                if (Stages[i].R2 != Stages[i + 1].R1)
                //Check end radius of current stage node and start radius of the next stage node, if they are not the same we can do chamfer or fillet
                {
                    AddEdgeFeature(i, false); //add feature on end of stage
                    flag = true;
                    current_edge++;

                    if (Stages[i].GetType() == typeof(ConicStage) && Stages[i].R2 == Stages[i + 1].R1)
                    {
                        flag = false;
                        current_edge++;
                    }
                }
                else // if they are the same, disable any operation(Chamfer or Fillet)
                {
                    if (Stages[i + 1].GetType() == typeof(ConicStage) || Stages[i].GetType() == typeof(ConicStage))
                    {
                        if (Stages[i + 1].R1 != Stages[i + 1].R2 || Stages[i].R1 != Stages[i].R2)
                        {
                            current_edge++;
                        }
                    }
                    flag = false;
                }
            }
        }
コード例 #16
0
ファイル: Script.cs プロジェクト: savionasc/Argamassa
 void Awake()
 {
     rb1 = Body1.GetComponent <Rigidbody>();
     rb2 = Body2.GetComponent <Rigidbody>();
     rb3 = Body3.GetComponent <Rigidbody>();
     rb5 = Body5.GetComponent <Rigidbody>();
     rb6 = Body6.GetComponent <Rigidbody>();
 }
コード例 #17
0
        // Test if a SolidWorks Body2 shape can be converted to a pure cylinder.
        public static bool SWbodyToCylinder(Body2 swBody)
        {
            double  rad = 0;
            Point3D pA  = new Point3D(0, 0, 0);
            Point3D pB  = new Point3D(0, 0, 0);

            return(SWbodyToCylinder(swBody, ref pA, ref pB, ref rad));
        }
コード例 #18
0
ファイル: PrismaticJoint.cs プロジェクト: pabllopf/Alis
 /// <summary>
 ///     Set the joint limits, usually in meters.
 /// </summary>
 public void SetLimits(float lower, float upper)
 {
     Box2DxDebug.Assert(lower <= upper);
     Body1.WakeUp();
     Body2.WakeUp();
     LowerLimit = lower;
     UpperLimit = upper;
 }
コード例 #19
0
ファイル: Form1.cs プロジェクト: wwkkww1983/SolidWorksAPI
        //判断是否为多实体零件或钣金件
        private bool isMutiBodyOrSheetMetal(ref bool isBlank, ref bool isSM, ref bool isSolidBody, ref string strError)
        {
            if (m_ModelDoc != null)
            {
                PartDoc swPartDoc = (PartDoc)m_ModelDoc;
                if (swPartDoc != null)
                {
                    object[] vBodies = (object[])swPartDoc.GetBodies2((int)swBodyType_e.swAllBodies, false);
                    if (vBodies == null)
                    {
                        strError = "空白图纸";
                        isBlank  = true;
                        return(false);
                    }
                    if (vBodies.Length > 1)
                    {
                        return(true);
                    }
                    else if (vBodies.Length == 1)
                    {
                        Body2 body = (Body2)vBodies[0];
                        isSM = body.IsSheetMetal();

                        //识别文件类型体
                        isSolidBody = false;
                        switch (body.GetType())
                        {
                        case (int)swBodyType_e.swSolidBody:
                            strError    = "实体文件";
                            isSolidBody = true;
                            break;

                        case (int)swBodyType_e.swSheetBody:
                            strError = "板体文件";
                            break;

                        case (int)swBodyType_e.swEmptyBody:
                            strError = "空白体文件";
                            break;

                        case (int)swBodyType_e.swGeneralBody:
                            strError = "一般,非流形体文件";
                            break;

                        case (int)swBodyType_e.swMinimumBody:
                            strError = "点体文件";
                            break;

                        case (int)swBodyType_e.swWireBody:
                            strError = "线体文件";
                            break;
                        }
                    }
                }
            }

            return(false);
        }
コード例 #20
0
        public static TmsV1PaymentinstrumentsPost201Response Run()
        {
            var profileId  = "93B32398-AD51-4CC2-A682-EA3E93614EB1";
            var requestObj = new Body2();

            var cardObj = new Tmsv1paymentinstrumentsCard
            {
                ExpirationMonth = "09",
                ExpirationYear  = "2022",
                Type            = Tmsv1paymentinstrumentsCard.TypeEnum.Visa
            };

            requestObj.Card = cardObj;

            var billToObj = new Tmsv1paymentinstrumentsBillTo
            {
                FirstName          = "John",
                LastName           = "Smith",
                Company            = "CyberSource",
                Address1           = "12 Main Street",
                Address2           = "20 My Street",
                Locality           = "San Francisco",
                AdministrativeArea = "CA",
                PostalCode         = "90200",
                Country            = "US",
                Email       = "*****@*****.**",
                PhoneNumber = "555123456"
            };

            requestObj.BillTo = billToObj;

            var instrumentIdentifierObj = new Tmsv1paymentinstrumentsInstrumentIdentifier();

            var cardObj2 = new Tmsv1instrumentidentifiersCard
            {
                Number = "4111111111111111"
            };

            instrumentIdentifierObj.Card = cardObj2;

            requestObj.InstrumentIdentifier = instrumentIdentifierObj;

            try
            {
                var configDictionary = new Configuration().GetConfiguration();
                var clientConfig     = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary);
                var apiInstance      = new PaymentInstrumentsApi(clientConfig);

                var result = apiInstance.TmsV1PaymentinstrumentsPost(profileId, requestObj);
                Console.WriteLine(result);
                return(result);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception on calling the API: " + e.Message);
                return(null);
            }
        }
コード例 #21
0
        // Test if a SolidWorks Body2 shape can be converted to a pure box.
        public static bool SWbodyToBox(Body2 swBody)
        {
            Point3D  vfooc = new Point3D(0, 0, 0);
            Vector3D vfoox = new Vector3D(0, 0, 0);
            Vector3D vfooy = new Vector3D(0, 0, 0);
            Vector3D vfooz = new Vector3D(0, 0, 0);

            return(SWbodyToBox(swBody, ref vfooc, ref vfoox, ref vfooy, ref vfooz));
        }
コード例 #22
0
        public void RestapiOauthTokenPostTest()
        {
            // TODO: add unit test for the method 'RestapiOauthTokenPost'
            Body2 body = null; // TODO: replace null with proper value

            var response = instance.RestapiOauthTokenPost(body);

            Assert.IsInstanceOf <InlineResponseDefault1> (response, "response is InlineResponseDefault1");
        }
コード例 #23
0
ファイル: Argamassa.cs プロジェクト: savionasc/Argamassa
 void setRigibody()
 {
     this.rb1 = Body1.GetComponent <Rigidbody>();
     this.rb2 = Body2.GetComponent <Rigidbody>();
     this.rb3 = Body3.GetComponent <Rigidbody>();
     this.rb4 = Body4.GetComponent <Rigidbody>();
     this.rb5 = Body5.GetComponent <Rigidbody>();
     this.rb6 = Body6.GetComponent <Rigidbody>();
 }
コード例 #24
0
        /// <summary>
        ///     Use this to update the target point.
        /// </summary>
        public void SetTarget(Vec2 target)
        {
            if (Body2.IsSleeping())
            {
                Body2.WakeUp();
            }

            Target = target;
        }
コード例 #25
0
        /// <summary>
        ///     Gets the reaction torque using the specified inv dt
        /// </summary>
        /// <param name="invDt">The inv dt</param>
        /// <returns>The float</returns>
        public override float GetReactionTorque(float invDt)
        {
            // TODO_ERIN not tested
            Vec2  r = Math.Mul(Body2.GetXForm().R, LocalAnchor2 - Body2.GetLocalCenter());
            Vec2  p = Impulse * jacobian.Linear2;
            float l = Impulse * jacobian.Angular2 - Vec2.Cross(r, p);

            return(invDt * l);
        }
コード例 #26
0
            public AnalyseBarre(Body2 corps, ModelDoc2 mdl)
            {
                Corps = corps;
                Mdl   = mdl;

                AnalyserFaces();

                AnalyserPercages();
            }
コード例 #27
0
        static double SubstractVolume(ModelDoc2 comparePart, Body2 a, Body2 b)
        {
            FeatureManager partFeatureMgr = comparePart.FeatureManager;
            Feature        partFeature;

            object[] localBodies;
            double   totalBodyVolume = 0;

            Body2[]  bodies_array = new Body2[] { b };
            double[] bodyproperties;
            bool     suppression;
            double   a_volume = Math.Round((a.GetMassProperties(0))[3], 8);
            double   b_volume = Math.Round((b.GetMassProperties(0))[3], 8);

            a_volume = Math.Round(a_volume, 8);
            b_volume = Math.Round(b_volume, 8);

            //  Logger.Info("Inserting a Combine Feature: Substraction...");
            partFeature = partFeatureMgr.InsertCombineFeature((int)swBodyOperationType_e.SWBODYCUT, a, bodies_array);
            if (partFeature == null)
            {
                if (b_volume >= a_volume)
                {
                    Logger.Warn("Body B seems to encompass all of Body A yielding a null volume.");
                    return(0);
                }
                else
                {
                    Logger.Warn("Volume A: " + a_volume +
                                "\nVolume B: " + b_volume);
                    Logger.Error("VolumeComparator", "SubstractVolume", "Could not create Feature");
                }
            }
            // Logger.Info("New Combine Feature added.");

            localBodies = ((PartDoc)comparePart).GetBodies2((int)swBodyType_e.swSolidBody, true);

            foreach (Body2 body in localBodies)
            {
                bodyproperties   = body.GetMassProperties(0);
                totalBodyVolume += bodyproperties[3];
            }

            suppression = partFeature.SetSuppression2((int)swFeatureSuppressionAction_e.swSuppressFeature, (int)swInConfigurationOpts_e.swThisConfiguration, null);

            if (suppression == true)
            {
                comparePart.Save();
                return(totalBodyVolume);  // returns the yielded volume
            }
            else
            {
                Logger.Error("VolumeComparator.cs", "SubstractVolume()", "Could not suppress feature");
                return(-1); // Suppression did not work
            }
        }
コード例 #28
0
            public Info AjouterCorps(Body2 body, int nb)
            {
                Info inf = null;

                for (int i = 0; i < nb; i++)
                {
                    inf = AjouterCorps(body);
                }

                return(inf);
            }
コード例 #29
0
        public static void Run(IReadOnlyDictionary <string, string> configDictionary)
        {
            var requestObj = new Body2();

            var paymentInformationCardObj = new PaymentinstrumentsCard();

            paymentInformationCardObj.ExpirationMonth = "09";
            paymentInformationCardObj.ExpirationYear  = "2022";
            paymentInformationCardObj.Type            = PaymentinstrumentsCard.TypeEnum.Visa;
            requestObj.Card = paymentInformationCardObj;

            var v2paymentsOrderInformationBillToObj = new PaymentinstrumentsBillTo();

            v2paymentsOrderInformationBillToObj.FirstName          = "John";
            v2paymentsOrderInformationBillToObj.LastName           = "Smith";
            v2paymentsOrderInformationBillToObj.Company            = "CyberSource";
            v2paymentsOrderInformationBillToObj.Address1           = "12 Main Street";
            v2paymentsOrderInformationBillToObj.Address2           = "20 My Street";
            v2paymentsOrderInformationBillToObj.Locality           = "Foster City";
            v2paymentsOrderInformationBillToObj.AdministrativeArea = "CA";
            v2paymentsOrderInformationBillToObj.PostalCode         = "90200";
            v2paymentsOrderInformationBillToObj.Country            = "US";
            v2paymentsOrderInformationBillToObj.Email       = "*****@*****.**";
            v2paymentsOrderInformationBillToObj.PhoneNumber = "555123456";
            requestObj.BillTo = v2paymentsOrderInformationBillToObj;

            var instrumentIdentifierObj = new PaymentinstrumentsInstrumentIdentifier();

            var v2paymentsPaymentInformationCardObj = new InstrumentidentifiersCard();

            v2paymentsPaymentInformationCardObj.Number = "4111111111111111";
            instrumentIdentifierObj.Card = v2paymentsPaymentInformationCardObj;

            requestObj.InstrumentIdentifier = instrumentIdentifierObj;

            var merchantConfig = new MerchantConfig(configDictionary)
            {
                RequestType     = "POST",
                RequestTarget   = "/tms/v1/paymentinstruments",
                RequestJsonData = JsonConvert.SerializeObject(requestObj)
            };

            try
            {
                var configurationSwagger = new ApiClient().CallAuthenticationHeader(merchantConfig);
                var apiInstance          = new PaymentInstrumentApi(configurationSwagger);
                var result = apiInstance.PaymentinstrumentsPost("93B32398-AD51-4CC2-A682-EA3E93614EB1", requestObj);
                Console.WriteLine(result);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception on calling the API: " + e.Message);
            }
        }
コード例 #30
0
        private void Lancer(Body2 corps)
        {
            MdlBase.eEffacerSelection();

            var faceBase = corps.eFaceFixeTolerie();

            var liste = new List <Face2>();

            faceBase.eChercherFacesTangentes(ref liste);

            liste = liste.FindAll(f => ((Surface)f.GetSurface()).IsPlane());

            foreach (var face in liste)
            {
                face.eSelectEntite(MdlBase, -1, true);
            }

            //if (faceBase.IsNull())
            //{
            //    WindowLog.Ecrire("Pas de face de base");
            //    return;
            //}

            //MdlBase.eEffacerSelection();

            //var listeLoop = (Object[])faceBase.GetLoops();
            //WindowLog.Ecrire("Recherche des loop // Nb de loop : " + listeLoop.Length);

            //var listePercage = new List<Loop2>();

            //foreach (Loop2 loop in listeLoop)
            //    if (!loop.IsOuter())
            //        listePercage.Add(loop);

            //MdlBase.eEffacerSelection();

            //WindowLog.Ecrire("Selection des percages // Nb de percage : " + listePercage.Count);
            //foreach (var loop in listePercage)
            //{
            //    var edge = (Edge)loop.GetEdges()[0];

            //    Face2 faceCylindre = null;
            //    foreach (Face2 face in edge.GetTwoAdjacentFaces2())
            //    {
            //        if (!face.IsSame(faceBase))
            //        {
            //            faceCylindre = face;
            //            faceCylindre.eSelectEntite(MdlBase, -1, true);
            //            break;
            //        }
            //    }
            //}
        }
コード例 #31
0
        //
        // STATE FUNCTIONS
        //

        /// Adds force to residual R, as R*= F*c
        /// NOTE: here the off offset in R is NOT used because add F at the TWO offsets of the two connected bodies,
        /// so it is assumed that offsets for Body1 and Body2 variables have been already set properly!
        public override void IntLoadResidual_F(int off, ref ChVectorDynamic <double> R, double c)
        {
            if (Body1 == null || Body2 == null)
            {
                return;
            }

            ChVector mbody_force  = new ChVector(0, 0, 0);
            ChVector mbody_torque = new ChVector(0, 0, 0);

            if (ChVector.Vnotnull(C_force))
            {
                ChVector m_abs_force = Body2.GetA().Matr_x_Vect(marker2.FrameMoving.GetA().Matr_x_Vect(C_force));

                if (Body2.Variables().IsActive())
                {
                    Body2.To_abs_forcetorque(m_abs_force,
                                             marker1.GetAbsCoord().pos,          // absolute application point is always marker1
                                             false,                              // from abs. space
                                             ref mbody_force, ref mbody_torque); // resulting force-torque, both in abs coords
                    R.matrix.PasteSumVector(mbody_force * -c, Body2.Variables().GetOffset(), 0);
                    R.matrix.PasteSumVector(Body2.TransformDirectionParentToLocal(mbody_torque) * -c,
                                            Body2.Variables().GetOffset() + 3, 0);
                }

                if (Body1.Variables().IsActive())
                {
                    Body1.To_abs_forcetorque(m_abs_force,
                                             marker1.GetAbsCoord().pos,          // absolute application point is always marker1
                                             false,                              // from abs. space
                                             ref mbody_force, ref mbody_torque); // resulting force-torque, both in abs coords
                    R.matrix.PasteSumVector(mbody_force * c, Body1.Variables().GetOffset(), 0);
                    R.matrix.PasteSumVector(Body1.TransformDirectionParentToLocal(mbody_torque) * c,
                                            Body1.Variables().GetOffset() + 3, 0);
                }
            }
            if (ChVector.Vnotnull(C_torque))
            {
                ChVector m_abs_torque = Body2.GetA().Matr_x_Vect(marker2.FrameMoving.GetA().Matr_x_Vect(C_torque));
                // load torques in 'fb' vector accumulator of body variables (torques in local coords)
                if (Body1.Variables().IsActive())
                {
                    R.matrix.PasteSumVector(Body1.TransformDirectionParentToLocal(m_abs_torque) * c,
                                            Body1.Variables().GetOffset() + 3, 0);
                }
                if (Body2.Variables().IsActive())
                {
                    R.matrix.PasteSumVector(Body2.TransformDirectionParentToLocal(m_abs_torque) * -c,
                                            Body2.Variables().GetOffset() + 3, 0);
                }
            }
        }
コード例 #32
0
        /// <summary>
        /// Partially modify a Loadbalancer You can use update attributes of a resource
        /// </summary>
        /// <param name="datacenterId"></param>
        /// <param name="loadbalancerId"></param>
        /// <param name="loadbalancer">Modified Loadbalancer</param>
        /// <param name="body"></param>
        /// <param name="parameter">Controls whether response is pretty-printed (with indentation and new lines)</param>
        /// <param name="depth">Controls the details depth of response objects. \nEg. GET /datacenters/[ID]\n	- depth=0: only direct properties are included. Children (servers etc.) are not included\n	- depth=1: direct properties and children references are included\n	- depth=2: direct properties and children properties are included\n	- depth=3: direct properties and children properties and children&#39;s children are included\n	- depth=... and so on</param>
        /// <returns>Task of Loadbalancer</returns>
        public async System.Threading.Tasks.Task<Loadbalancer> PartialUpdateAsync(string datacenterId, string loadbalancerId, LoadbalancerProperties loadbalancer, Body2 body = null, bool? parameter = null, int? depth = null)
        {
            ApiResponse<Loadbalancer> response = await PartialUpdateAsyncWithHttpInfo(datacenterId, loadbalancerId, loadbalancer, body, parameter, depth);
            return response.Data;

        }
コード例 #33
0
 // Test if a SolidWorks Body2 shape can be converted to a pure box.
 public static bool SWbodyToConvexHull(Body2 swBody, int maxvertexes)
 {
     Point3D[] vertexes = null;
     return SWbodyToConvexHull(swBody, ref vertexes, maxvertexes);
 }
コード例 #34
0
        // Try to see if the SolidWorks Body2 shape is a pure cylinder.
        // If so,return true. If not a cylinder, return false.
        // If it is a cylinder, in 'P1' and 'P2' and 'radius' one can get
        // the two ends and the radius.
        public static bool SWbodyToCylinder(Body2 swBody,
                                          ref Point3D P1, ref Point3D P2,
                                          ref double radius)
        {
            bool iscyl = false;

            if (swBody.GetFaceCount() == 3)
                if (swBody.GetEdgeCount() == 2)
                {
                    object[] mfaces = (object[])swBody.GetFaces();
                    object[] medges = (object[])swBody.GetEdges();
                    object[] mverts = (object[])swBody.GetVertices();

                    int iplane = 0;
                    Surface surf_cyl = null;
                    Surface surf_planeA = null;
                    Surface surf_planeB = null;
                    for (int i = 0; i < 3; i++)
                    {
                        Face2 mface = (Face2)mfaces[i];
                        Surface msurf = (Surface)mface.GetSurface();
                        if (msurf.IsCylinder())
                        {
                            surf_cyl = msurf;
                        }
                        if (msurf.IsPlane())
                        {
                            if (iplane == 0) surf_planeA = msurf;
                            if (iplane == 1) surf_planeB = msurf;
                            iplane++;
                        }
                        if ((surf_cyl != null) && (surf_planeA != null) && (surf_planeB != null))
                        {
                            iscyl = true;

                            double[] cylpar = (double[])surf_cyl.CylinderParams;
                            Vector3D cyl_C = new Vector3D(cylpar[0], cylpar[1], cylpar[2]);
                            Vector3D cyl_D = new Vector3D(cylpar[3], cylpar[4], cylpar[5]);
                            double   cyl_rad = cylpar[6];
                            double cyl_tol = (1e-6);

                            double[] pApar = (double[])surf_planeA.PlaneParams;
                            Vector3D pA_N = new Vector3D(pApar[0], pApar[1], pApar[2]);
                            Vector3D pA_C = new Vector3D(pApar[3], pApar[4], pApar[5]);

                            double[] pBpar = (double[])surf_planeB.PlaneParams;
                            Vector3D pB_N = new Vector3D(pBpar[0], pBpar[1], pBpar[2]);
                            Vector3D pB_C = new Vector3D(pBpar[3], pBpar[4], pBpar[5]);

                            // Rejective test 1: cyl axis & norms ofplanes are not aligned?
                            if ((Vector3D.CrossProduct(cyl_D, pA_N)).Length > cyl_tol)
                                iscyl = false;
                            if ((Vector3D.CrossProduct(cyl_D, pB_N)).Length > cyl_tol)
                                iscyl = false;

                            // return geom.info
                            if (iscyl)
                            {
                                radius = cyl_rad;
                                P1 = (Point3D)(cyl_C + cyl_D * (Vector3D.DotProduct((pA_C - cyl_C), cyl_D)));
                                P2 = (Point3D)(cyl_C + cyl_D * (Vector3D.DotProduct((pB_C - cyl_C), cyl_D)));
                            }
                        }
                        else
                            iscyl = false;
                    }
                }

            return iscyl;
        }
コード例 #35
0
 // Test if a SolidWorks Body2 shape can be converted to a pure cylinder.
 public static bool SWbodyToCylinder(Body2 swBody)
 {
     double rad =0;
     Point3D pA = new Point3D(0, 0, 0);
     Point3D pB = new Point3D(0, 0, 0);
     return SWbodyToCylinder(swBody, ref pA, ref pB, ref rad);
 }
コード例 #36
0
 // Test if a SolidWorks Body2 shape can be converted to a pure sphere.
 public static bool SWbodyToSphere(Body2 swBody)
 {
     double dfoo = 0;
     Point3D vfoo = new Point3D(0, 0, 0);
     return SWbodyToSphere(swBody, ref dfoo, ref vfoo);
 }
コード例 #37
0
 // Test if a SolidWorks Body2 shape can be converted to a pure box.
 public static bool SWbodyToBox(Body2 swBody)
 {
     Point3D vfooc = new Point3D(0, 0, 0);
     Vector3D vfoox = new Vector3D(0, 0, 0);
     Vector3D vfooy = new Vector3D(0, 0, 0);
     Vector3D vfooz = new Vector3D(0, 0, 0);
     return SWbodyToBox(swBody, ref vfooc, ref vfoox, ref vfooy, ref vfooz);
 }
コード例 #38
0
        // Try to see if the SolidWorks Body2 shape is a pure box.
        // If so,return true. If not a box, return false.
        // If it is a box, in 'corner' and 'Dx,Dy,Dx' one can get
        // the box main corner and the three departing edges.
        public static bool SWbodyToBox(Body2 swBody,
                                          ref Point3D corner,
                                          ref Vector3D Ex, ref Vector3D Ey, ref Vector3D Ez)
        {
            bool isbox = false;

            if (swBody.GetFaceCount() == 6)
                if (swBody.GetEdgeCount() == 12)
                    if (swBody.GetVertexCount() == 8)
                    {
                        object[] mfaces = (object[])swBody.GetFaces();
                        object[] medges = (object[])swBody.GetEdges();
                        object[] mverts = (object[])swBody.GetVertices();

                        isbox = true;

                        // rejective test 1: are all faces as planes?
                        bool allplanes = true;
                        for (int i = 0; i < 6; i++)
                        {
                            Face2 sphface = (Face2)mfaces[i];
                            Surface msurf = (Surface)sphface.GetSurface();
                            if (!msurf.IsPlane())
                            {
                                allplanes = false;
                            }
                        }
                        if (allplanes)
                        {
                            isbox = true;
                            Vector3D[] pnts = new Vector3D[8];
                            for (int ip = 0; ip < 8; ip++)
                                pnts[ip] = new Vector3D(((double[])((Vertex)mverts[ip]).GetPoint())[0],
                                                        ((double[])((Vertex)mverts[ip]).GetPoint())[1],
                                                        ((double[])((Vertex)mverts[ip]).GetPoint())[2]);
                            Vector3D pC = pnts[0];
                            int X_id = 0;
                            int Y_id = 0;
                            int Z_id = 0;
                            Vector3D pX = pnts[0];
                            Vector3D pY = pnts[0];
                            Vector3D pZ = pnts[0];
                            Vector3D Dx = (pX - pC);
                            Vector3D Dy = (pY - pC);
                            Vector3D Dz = (pZ - pC);

                            // rejective test 1: are there 3 points that define an orthogonal trihedron with pC corner?
                            bool found_corner = false;
                            for (int xi = 1; xi < 8; xi++)
                            {
                                for (int yi = xi + 1; yi < 8; yi++)
                                {
                                    for (int zi = yi + 1; zi < 8; zi++)
                                    {
                                        pX = pnts[xi];
                                        pY = pnts[yi];
                                        pZ = pnts[zi];
                                        Dx = (pX - pC);
                                        Dy = (pY - pC);
                                        Dz = (pZ - pC);
                                        if ((Math.Abs(Vector3D.DotProduct(Dx, Dy)) < Dx.Length * (1e-5)) &&
                                            (Math.Abs(Vector3D.DotProduct(Dy, Dz)) < Dx.Length * (1e-5)) &&
                                            (Math.Abs(Vector3D.DotProduct(Dz, Dx)) < Dx.Length * (1e-5)))
                                            {
                                                X_id = xi; Y_id = yi; Z_id = zi;
                                                found_corner = true;
                                                break;
                                            }
                                    }
                                    if (found_corner) break;
                                }
                                if (found_corner) break;
                            }
                            if (!found_corner)
                            {
                                isbox = false;
                            }

                            double box_tol = Dx.Length * (1e-5);

                            //System.Windows.Forms.MessageBox.Show(" Dx " + Dx + "\n" + " Dy " + Dy + "\n"  + " Dz " + Dz);

                            // rejective test 2: is there a point opposite to pC?
                            Vector3D pE = pC + Dx + Dy;
                            bool found_E = false;
                            int E_id = 0;
                            for (int ip = 1; ip < 8; ip++)
                            {
                                Vector3D ds = pE - pnts[ip];
                                if (ds.Length < box_tol)
                                {
                                    found_E = true;
                                    E_id = ip;
                                }
                            }
                            if (!found_E)
                            {
                                isbox = false;
                            }

                            // rejective test 3: are other four points aligned?
                            Vector3D norm = Vector3D.CrossProduct(Dx, Dy);
                            norm.Normalize();
                            Vector3D[] ptsA = new Vector3D[4];
                            bool[] aligned = new bool[4];
                            double[] dists = new double[4];
                            aligned[0] = aligned[1] = aligned[2] = aligned[3] = false;
                            ptsA[0] = pC;
                            ptsA[1] = pX;
                            ptsA[2] = pY;
                            ptsA[3] = pnts[E_id];
                            for (int iA = 0; iA < 4; iA++)
                                for (int ip = 1; ip < 8; ip++)
                                {
                                    if ((ip != E_id) && (ip != X_id) && (ip != Y_id))
                                    {
                                        Vector3D D = pnts[ip] - ptsA[iA];
                                        if ((Vector3D.CrossProduct(D, norm)).Length < box_tol)
                                        {
                                            aligned[iA] = true;
                                            dists[iA] = Vector3D.DotProduct(D, norm);
                                        }
                                    }
                                }
                            if ((aligned[0] != true) ||
                                (aligned[1] != true) ||
                                (aligned[2] != true) ||
                                (aligned[3] != true))
                            {
                                isbox = false;
                            }
                            if ((Math.Abs(dists[0] - dists[1]) > box_tol) ||
                                (Math.Abs(dists[0] - dists[2]) > box_tol) ||
                                (Math.Abs(dists[0] - dists[3]) > box_tol))
                            {
                                isbox = false;
                            }
                            // return geom.info
                            if (isbox)
                            {
                                corner = new Point3D(pC.X,pC.Y,pC.Z);
                                Ex = Dx;
                                Ey = Dy;
                                Ez = norm*dists[0];
                            }
                        }
                    }

            return isbox;
        }
コード例 #39
0
 /// <summary>
 /// Partially modify a Loadbalancer You can use update attributes of a resource
 /// </summary>
 /// <param name="datacenterId"></param> 
 /// <param name="loadbalancerId"></param> 
 /// <param name="loadbalancer">Modified Loadbalancer</param> 
 /// <param name="body"></param> 
 /// <param name="parameter">Controls whether response is pretty-printed (with indentation and new lines)</param> 
 /// <param name="depth">Controls the details depth of response objects. \nEg. GET /datacenters/[ID]\n	- depth=0: only direct properties are included. Children (servers etc.) are not included\n	- depth=1: direct properties and children references are included\n	- depth=2: direct properties and children properties are included\n	- depth=3: direct properties and children properties and children&#39;s children are included\n	- depth=... and so on</param> 
 /// <returns>Loadbalancer</returns>
 public Loadbalancer PartialUpdate(string datacenterId, string loadbalancerId, LoadbalancerProperties loadbalancer, Body2 body = null, bool? parameter = null, int? depth = null)
 {
     ApiResponse<Loadbalancer> response = PartialUpdateWithHttpInfo(datacenterId, loadbalancerId, loadbalancer, body, parameter, depth);
     return response.Data;
 }
コード例 #40
0
        // Try to see if the SolidWorks Body2 shape is a pure convex hull.
        // If so,return true. If not a convex hull, return false.
        // If it is a convex hull, in 'vertexes' get all the points.
        public static bool SWbodyToConvexHull(Body2 swBody,
                                          ref Point3D[] vertexes, int maxvertexes)
        {
            bool ishull = false;

            if (swBody.GetVertexCount() <= maxvertexes)
            {
                object[] mfaces = (object[])swBody.GetFaces();
                object[] medges = (object[])swBody.GetEdges();
                object[] mverts = (object[])swBody.GetVertices();

                ishull = true;

                // rejective test 1: are all faces as planes?
                bool allplanes = true;
                for (int i = 0; i < swBody.GetFaceCount(); i++)
                {
                    Face2 aface = (Face2)mfaces[i];
                    Surface msurf = (Surface)aface.GetSurface();
                    if (!msurf.IsPlane())
                    {
                        allplanes = false;
                    }
                }
                if (!allplanes)
                    return false;

                // rejective test 2: are all edges as straight lines?
                bool allstraightedges = true;
                for (int i = 0; i < swBody.GetEdgeCount(); i++)
                {
                    Edge aedge = (Edge)medges[i];
                    Curve mcurve = (Curve)aedge.GetCurve();
                    if (!mcurve.IsLine())
                    {
                        allstraightedges = false;
                    }
                }
                if (!allstraightedges)
                    return false;

                // rejective test 3: are there holes as in tori?
                // Use Euler formula  v + f - e = 2 -2*genus
                if (swBody.GetVertexCount() + swBody.GetFaceCount() - swBody.GetEdgeCount() != 2)
                    return false;

                if (ishull)
                {
                    vertexes = new Point3D[swBody.GetVertexCount()];
                    for (int ip = 0; ip < swBody.GetVertexCount(); ip++)
                    {
                        vertexes[ip] = new  Point3D(((double[])((Vertex)mverts[ip]).GetPoint())[0],
                                                    ((double[])((Vertex)mverts[ip]).GetPoint())[1],
                                                    ((double[])((Vertex)mverts[ip]).GetPoint())[2]);
                    }
                }
            }

            return ishull;
        }
コード例 #41
0
        /// <summary>
        /// Partially modify a Loadbalancer You can use update attributes of a resource
        /// </summary>
        /// <param name="datacenterId"></param>
        /// <param name="loadbalancerId"></param>
        /// <param name="loadbalancer">Modified Loadbalancer</param>
        /// <param name="body"></param>
        /// <param name="parameter">Controls whether response is pretty-printed (with indentation and new lines)</param>
        /// <param name="depth">Controls the details depth of response objects. \nEg. GET /datacenters/[ID]\n	- depth=0: only direct properties are included. Children (servers etc.) are not included\n	- depth=1: direct properties and children references are included\n	- depth=2: direct properties and children properties are included\n	- depth=3: direct properties and children properties and children&#39;s children are included\n	- depth=... and so on</param>
        /// <returns>Task of ApiResponse (Loadbalancer)</returns>
        public async System.Threading.Tasks.Task<ApiResponse<Loadbalancer>> PartialUpdateAsyncWithHttpInfo(string datacenterId, string loadbalancerId, LoadbalancerProperties loadbalancer, Body2 body = null, bool? parameter = null, int? depth = null)
        {
            // verify the required parameter 'datacenterId' is set
            if (datacenterId == null) throw new ApiException(400, "Missing required parameter 'datacenterId' when calling PartialUpdate");
            // verify the required parameter 'loadbalancerId' is set
            if (loadbalancerId == null) throw new ApiException(400, "Missing required parameter 'loadbalancerId' when calling PartialUpdate");
            // verify the required parameter 'loadbalancer' is set
            if (loadbalancer == null) throw new ApiException(400, "Missing required parameter 'loadbalancer' when calling PartialUpdate");


            var path_ = "/datacenters/{datacenterId}/loadbalancers/{loadbalancerId}";

            var pathParams = new Dictionary<String, String>();
            var queryParams = new Dictionary<String, String>();
            var headerParams = new Dictionary<String, String>();
            var formParams = new Dictionary<String, String>();
            var fileParams = new Dictionary<String, FileParameter>();
            Object postBody = null;

            // to determine the Content-Type header
            String[] httpContentTypes = new String[] {
                "application/vnd.profitbricks.partial-properties+json", "application/json"
            };
            String httpContentType = Configuration.ApiClient.SelectHeaderContentType(httpContentTypes);

            // to determine the Accept header
            String[] httpHeaderAccepts = new String[] {
                "application/vnd.profitbricks.resource+json"
            };
            String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts);
            if (httpHeaderAccept != null)
                headerParams.Add("Accept", httpHeaderAccept);

            // set "format" to json by default
            // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
            pathParams.Add("format", "json");
            if (datacenterId != null) pathParams.Add("datacenterId", Configuration.ApiClient.ParameterToString(datacenterId)); // path parameter
            if (loadbalancerId != null) pathParams.Add("loadbalancerId", Configuration.ApiClient.ParameterToString(loadbalancerId)); // path parameter

            if (parameter != null) queryParams.Add("parameter", Configuration.ApiClient.ParameterToString(parameter)); // query parameter
            if (depth != null) queryParams.Add("depth", Configuration.ApiClient.ParameterToString(depth)); // query parameter



            postBody = Configuration.ApiClient.Serialize(loadbalancer); // http body (model) parameter



            // authentication (basicAuth) required

            // http basic authentication required
            if (!String.IsNullOrEmpty(Configuration.Username) || !String.IsNullOrEmpty(Configuration.Password))
            {
                headerParams["Authorization"] = "Basic " + ApiClient.Base64Encode(Configuration.Username + ":" + Configuration.Password);
            }


            // make the HTTP request
            IRestResponse response = (IRestResponse)await Configuration.ApiClient.CallApiAsync(path_,
                Method.PATCH, queryParams, postBody, headerParams, formParams, fileParams,
                pathParams, httpContentType);

            int statusCode = (int)response.StatusCode;

            if (statusCode >= 400)
                throw new ApiException(statusCode, "Error calling PartialUpdate: " + response.Content, response.Content);
            else if (statusCode == 0)
                throw new ApiException(statusCode, "Error calling PartialUpdate: " + response.ErrorMessage, response.ErrorMessage);

            return new ApiResponse<Loadbalancer>(statusCode,
                response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
                (Loadbalancer)Configuration.ApiClient.Deserialize(response, typeof(Loadbalancer)));

        }
コード例 #42
0
ファイル: Program.cs プロジェクト: flair2005/dlnuvaar
        /// <summary>
        /// 创建SWBody对象
        /// </summary>
        /// <param name="body"></param>
        /// <returns></returns>
        private static SWBody CreateSWBody(Body2 body) {
            if (body == null)
                return null;

            SWBody swBody = new SWBody();

            swBody.Name = body.Name;

            //提取Face
            Face2 face = body.GetFirstFace();
            while (face != null) {
                swBody.Faces.Add(CreateSWFace(face));
                face = face.GetNextFace();
            }

            //提取Edge
            object[] edges = body.GetEdges();
            if (edges != null) {
                foreach (object objEdge in edges) {
                    if (objEdge != null) {
                        swBody.Edges.Add(CreateSWEdge((Edge)objEdge));
                    }
                }
            }

            //提取Vertex
            object[] vertices = body.GetVertices();
            if (vertices != null) {
                foreach (object objVertex in vertices) {
                    if (objVertex != null) {
                        swBody.Vertices.Add(CreateSWVertex((Vertex)objVertex));
                    }
                }
            }

            return swBody;
        }
コード例 #43
0
ファイル: SwAddin.cs プロジェクト: digger1985/MyCode
        private bool AddDeleteBodyMenu(Body2 swSelBody)
        {
            bool ret = false;

            if (swSelBody != null)
            {
                if (swSelBody.Name.Length > 9)
                {
                    if (swSelBody.Name.Substring(0, 9).ToLower() == "#swrfedge")
                    {
                        bool bRet = _iSwApp.AddMenuPopupItem2((int)swDocumentTypes_e.swDocPART, _addinId,
                                                              (int)swSelectType_e.swSelEVERYTHING,
                                                              MyTitle + " - ������� ������", "DeleteEdge", "", "", "");
                        ret = true;
                    }
                }
            }
            return ret;
        }