Beispiel #1
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
            }
        }
Beispiel #2
0
        static double CommonVolume(ModelDoc2 comparePart, Body2 a, Body2 b)
        {
            FeatureManager partFeatureMgr = comparePart.FeatureManager;
            Feature        partFeature;

            object[] localBodies;
            double   totalBodyVolume = 0;

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

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

            // Logger.Info("Inserting a Combine Feature: Intersection...");
            partFeature = partFeatureMgr.InsertCombineFeature((int)swBodyOperationType_e.SWBODYINTERSECT, null, bodies_array);
            if (partFeature == null)
            {
                Logger.Warn("No Intersection found between the provided bodies");
                return(0);  // Zero Volume
            }
            // 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(Math.Round(totalBodyVolume, 8));  // returns the yielded volume
            }
            else
            {
                Logger.Error("VolumeComparator.cs", "SubstractVolume()", "Could not suppress feature");
                return(-1);  // Suppression did not work
            }
        }
Beispiel #3
0
        static int CompareVolume(Body2 a, Body2 b)
        {
            /* returns 0 for no change in volume
             * returns 1 for negative change
             * returns 2 for positive change */
            double[] body1MassProp, body2MassProp;
            double   body1Volume, body2Volume;

            body1MassProp = a.GetMassProperties(0);  // Using a density of '0' since we don't need mass
            body2MassProp = b.GetMassProperties(0);

            body1Volume = Math.Round(body1MassProp[3], 8);
            body2Volume = Math.Round(body2MassProp[3], 8);

            Logger.Info("Volume A:" + body1Volume + "\tVolume B:" + body2Volume);
            Program.report.AddDelayedLine("Volume A:\t\t" + body1Volume + "\tVolume B:\t" + body2Volume);

            return(IncDecDoubleReport(body1Volume, body2Volume, "CompareVolume()"));
        }