Exemple #1
0
		internal static void GenerateData(STPModelData md, IfcBuilding building,bool openings)
		{
			IfcMaterial concrete = new IfcMaterial(md, "Concrete", "", "");
			int thickness = 200;
			IfcMaterialLayer materialLayer = new IfcMaterialLayer(md, concrete, thickness, false, "Core", "", "", 0);
			string name = thickness + "mm Concrete";
			IfcMaterialLayerSet materialLayerSet = new IfcMaterialLayerSet( materialLayer, name, "");
			materialLayerSet.Associates.GlobalId = "2l_enLhI93reVwnim9gXUq";
			md.NextObjectRecord = 300;
			IfcSlabType slabType = new IfcSlabType(name, materialLayerSet, IfcSlabTypeEnum.FLOOR) { GlobalId = "0RSW$KKbzCZ9QaSm3GoEan" };
			slabType.ObjectTypeOf.GlobalId = "3wwDcmW5T3HfafURQewdD0";
			PolyCurve polycurve = new PolyCurve();
			polycurve.Append(new Line(0, 0, 0, 1000, 0, 0));
			polycurve.Append(new Arc(new Point3d(1000, 0, 0), new Point3d(1400, 2000, 0), new Point3d(1000, 4000, 0)));
			polycurve.Append(new Line(1000, 4000, 0, 0, 4000, 0));
			polycurve.Append(new Arc(new Point3d(0, 4000, 0), new Point3d(-400, 2000, 0), new Point3d(0, 0, 0)));
			IfcSlabStandardCase slabStandardCase = new IfcSlabStandardCase(building, slabType, polycurve, -200, true, null) { GlobalId = "1wAj$J2Az2V8wnBiVYd3bU" };
			slabStandardCase.Material.Associates.GlobalId = "3ESAzibgr9BvK9M75iV84w";
			if (openings)
			{
				IfcCircleProfileDef cpd = new IfcCircleProfileDef(md, "100DIA", 50);
				IfcExtrudedAreaSolid eas = new IfcExtrudedAreaSolid(cpd,new IfcAxis2Placement3D(md,new Plane(new Point3d(100,300,-200),Vector3d.XAxis,Vector3d.YAxis)),new IfcDirection(md,0,0,1),thickness);
				IfcOpeningStandardCase opening = new IfcOpeningStandardCase(slabStandardCase, null, eas) { GlobalId = "15RSTHd8nFVQWMRE7og7sd", Name = "Opening" };
				opening.VoidsElement.GlobalId = "0gqEDsyEzFXvY$fc_rUxyO";
				IfcRectangleProfileDef rpd = new IfcRectangleProfileDef(md, "RecessRectangle", 500, 1000);
				eas = new IfcExtrudedAreaSolid(rpd, new IfcAxis2Placement3D(md, new Plane(new Point3d(500, 1000, -50), Vector3d.XAxis, Vector3d.YAxis)), new IfcDirection(md, 0, 0, 1), 50);
				IfcOpeningElement recess = new IfcOpeningElement(slabStandardCase, eas, IfcOpeningElementTypeEnum.RECESS) { GlobalId = "0w93HZ19H2D99zbAVNb4o2", Name = "Recess" };
				recess.VoidsElement.GlobalId = "3iUkij4q1DmxlXuHzQVJaM";
			}
		}
Exemple #2
0
        /***************************************************/

        public static bool IsEqual(this BHG.PolyCurve bhCurve, RHG.PolyCurve rhCurve, double tolerance = BHG.Tolerance.Distance)
        {
            if (bhCurve == null & rhCurve == null)
            {
                return(true);
            }

            bool equal = true;
            List <BHG.ICurve> bhCurves = bhCurve.Curves;

            rhCurve.RemoveNesting();
            RHG.Curve[] rhCurves = rhCurve.Explode();

            if (bhCurves.Count != rhCurves.Length)
            {
                return(false);
            }

            for (int i = 0; i < bhCurves.Count; i++)
            {
                equal &= bhCurves[i].IIsEqual(rhCurves[i], tolerance);
            }

            return(equal);
        }
 internal PolyCurve(PolyCurve other)
 {
   IntPtr pOther = IntPtr.Zero;
   if (null != other)
     pOther = other.ConstPointer();
   IntPtr ptr = UnsafeNativeMethods.ON_PolyCurve_New(pOther);
   ConstructNonConstObject(ptr);
 }
Exemple #4
0
		internal static void GenerateData(STPModelData md, IfcBuilding building,bool assembly)
		{
			IfcDocumentReference documentReference = new IfcDocumentReference(md, "", "MyReinforcementCode", "MyCodeISO3766", "", null);
			IfcRelAssociatesDocument associatesDocument = new IfcRelAssociatesDocument(md.Project, documentReference);
			associatesDocument.GlobalId = "1R7R97$uLAAv4wci$KGwn8";
			IfcMaterial material = new IfcMaterial(md, "ReinforcingSteel", "", "");
			List<Point3d> points = new List<Point3d>() { new Point3d(-69.0, 0.0, -122.0), new Point3d(-69.0, 0.0, -79.0), new Point3d(-54.9411254969541, 0.0, -45.0588745030455), new Point3d(-21.0, 0.0, -31.0), new Point3d(21.0, 0.0, -31.0), new Point3d(54.9411254969541, 0.0, -45.0588745030455), new Point3d(69.0, 0.0, -78.9999999999999), new Point3d(69.0, 0.00000000000000089, -321.0), new Point3d(54.9939785957165, 1.21791490472034, -354.941125496954), new Point3d(21.1804517666074, 4.15822158551252, -369.0), new Point3d(-20.6616529376114, 7.79666547283599, -369.0), new Point3d(-54.4751797667207, 10.7369721536282, -354.941125496954), new Point3d(-68.4812011710042, 11.9548870583485, -321.0), new Point3d(-69.0, 12.0, -79.0), new Point3d(-54.9411254969541, 12.0, -45.0588745030455), new Point3d(-21.0, 12.0, -31.0), new Point3d(21.0, 12.0, -31.0), new Point3d(54.9411254969541, 12.0, -45.0588745030455), new Point3d(69.0, 12.0, -78.9999999999999),new Point3d(69.0, 12.0, -122.0), };
			PolyCurve pc = new PolyCurve();
			pc.Append(new Line(points[0],points[1]));
			pc.Append(new Arc(points[1],points[2],points[3] ));
			pc.Append(new Line(points[3],points[4]));
			pc.Append(new Arc(points[4],points[5],points[6] ));
			pc.Append(new Line(points[6],points[7]));
			pc.Append(new Arc(points[7],points[8],points[9] ));
			pc.Append(new Line(points[9],points[10]));
			pc.Append(new Arc(points[10],points[11],points[12] ));
			pc.Append(new Line(points[12],points[13]));
			pc.Append(new Arc(points[13],points[14],points[15] ));
			pc.Append(new Line(points[15],points[16]));
			pc.Append(new Arc(points[16],points[17],points[18] ));
			pc.Append(new Line(points[18],points[19]));
			IfcBoundedCurve directrix = IfcBoundedCurve.ConvertCurve(md,pc);

			double barDiameter = 12, area = Math.PI * Math.Pow( barDiameter,2) / 4;
			IfcSweptDiskSolid sweptDiskSolid = new IfcSweptDiskSolid(directrix, barDiameter/2.0, 0);
			IfcRepresentationMap representationMap = new IfcRepresentationMap(sweptDiskSolid);
			string shapeCode = ""; //Todo
			IfcReinforcingBarType reinforcingBarType = new IfcReinforcingBarType(md, "12 Diameter Ligature", IfcReinforcingBarTypeEnum.LIGATURE, barDiameter, area, 1150, IfcReinforcingBarSurfaceEnum.TEXTURED, shapeCode, null) { GlobalId = "0jMRtfHYXE7u4s_CQ2uVE9", MaterialSelect = material, RepresentationMaps = new List<IfcRepresentationMap>() { representationMap} };
			reinforcingBarType.ObjectTypeOf.GlobalId = "1iAfl2ERbFmwi7uniy1H7j";
			reinforcingBarType.Material.Associates.GlobalId = "3gfVO40P5EfQyKZ_bF0R$6";
			if (assembly)
			{
				IfcMaterial concrete = new IfcMaterial(md,"Concrete","","Concrete");
				string name = "400x200RC";
				IfcRectangleProfileDef rectangleProfileDef = new IfcRectangleProfileDef(md, name, 400, 200);
				IfcMaterialProfile materialProfile = new IfcMaterialProfile(md,name,"",concrete,rectangleProfileDef,0,"");

				IfcBeamType beamType = new IfcBeamType(name, materialProfile, IfcBeamTypeEnum.BEAM) { GlobalId = "3bdpqVuWTCbxJ2S3ODYv6q"};
				beamType.ObjectTypeOf.GlobalId = "2oaQVVf79BrwRouvtRuQVg";
				beamType.Material.Associates.GlobalId = "2ZEgyI2v184hwa$_diRqS9";
				IfcBeamStandardCase beamStandardCase = new IfcBeamStandardCase(building, beamType, new Line(0, 0, 0, 0, 5000, 0), Vector3d.ZAxis, IfcCardinalPointReference.TOPMID, null) { GlobalId = "1yjQ2DwLnCC8k3i3X6D_ut" };
				beamStandardCase.Material.Associates.GlobalId = "3DWeleqqjEG9KshbOZXUdY";
				IfcElementAssembly elementAssembly = new IfcElementAssembly(beamStandardCase, IfcAssemblyPlaceEnum.FACTORY, IfcElementAssemblyTypeEnum.REINFORCEMENT_UNIT) { GlobalId = "0Q1tCJWdj4kOkZUg7rkf2h" };
				List<string> ids = new List<string>() { "0ohBfsArr3ruXYxacT4yl5","3YrK7RbE122fNRsP5djFAe","0wxAc63nj5AezFhfks7wLL","0bsov2wZL6tRRZmKy4vuUU","3qrgfIBb92ZegJTle7jou3","16m6R3JeT83fJPCze2yU$a","2SGIIYjSbCuu3HVwoLt1yh","0PsLby6eL8_hVEt4QwK0lZ","1325VJou5AngWp1djcV0hL","20zj_$BcH74xRgR4bDrLNb","3M4SfEMtHEJukgZR4hw$eV","23BYnIaOLBZPVTrKVEDJiy","2XulRByDL8ugyo4Uqv9rJr","2xvQMSga96XOT3VeCS6ZsK","2gUE6_w3j77f8YJGz_2RMl","0J0dRL4tT93REAabfASDom","048RJ151b81PqODsTMD4EA","3hXx9Kb6b5bvjgr9pwvpz0","0FmUHg8ZX0ZfY$0f5nkM2l","2_zvpwRdvAuRiTlHXX$Qp8","1mhkXHKfX6PxdS2vZn17wX","0CeIQzUqP5qOOeAjMtH2OX","3shtoAQL5BAhvwA_1Ph$lC","22j4RNKqD2IBRDGig5eaCF","3Wvu6qGJH4ChhTV3pl9CGh","37Qrf07Iz3tRMbSxEA4ynH","2gelqZ1Wv8BvCy6TstVGkd","1Q21dHc_X7eRppCHrT69Vb","0e6Wc08NLD59ueqCAK1gxp","3xdMOSZMj3cBOV_QTbXZha","1r_U9JTkHDWwkv_nfWFHVe","29I7_S2fT3WRD4zPH4YjmD","0$ciATTaP17PJMHQD0$N3Y","1irBeCCUf82wdGg7qTPCbW" };
				int jcounter = 0;
				for (int icounter = 25; icounter < 5000; icounter += 150)
				{
					IfcElement element = reinforcingBarType.GenerateMappedItemElement(elementAssembly, new Plane(new Point3d(0, icounter, 0), Vector3d.XAxis, Vector3d.YAxis));
					element.GlobalId = ids[jcounter++];
				}
				elementAssembly.IsDecomposedBy[0].GlobalId = "1WdB196Kb72f_pKgj5rklU";
			}
			else
			{ 
				IfcElement element = reinforcingBarType.GenerateMappedItemElement(building, Plane.WorldXY);
				element.GlobalId = "0WUveBtSTDbunNjDLsuRn$";
			}
		}
        internal PolyCurve(PolyCurve other)
        {
            IntPtr pOther = IntPtr.Zero;

            if (null != other)
            {
                pOther = other.ConstPointer();
            }
            IntPtr ptr = UnsafeNativeMethods.ON_PolyCurve_New(pOther);

            ConstructNonConstObject(ptr);
        }
Exemple #6
0
 /// <summary>
 /// Convert a Nucleus polyCurve into a RhinoCommon one
 /// </summary>
 /// <param name="curve"></param>
 /// <returns></returns>
 public static RC.PolyCurve Convert(PolyCurve curve)
 {
     RC.PolyCurve result = new RC.PolyCurve();
     foreach (Curve subCrv in curve.SubCurves)
     {
         RC.Curve rCrv = Convert(subCrv);
         if (rCrv != null)
         {
             result.Append(rCrv);
         }
     }
     return(result);
 }
Exemple #7
0
        static internal IEnumerable <Rhino.Geometry.Curve> ToRhino(this IEnumerable <CurveLoop> loops)
        {
            foreach (var loop in loops)
            {
                var polycurve = new Rhino.Geometry.PolyCurve();

                foreach (var curve in loop)
                {
                    polycurve.Append(curve.ToRhino());
                }

                yield return(polycurve);
            }
        }
Exemple #8
0
        public List<Curve> Write(ref Point3d position, Vector3d unitX, Vector3d unitY)
        {
            position -= Start * unitX;

            var curves = new List<Curve>(Vectors.Count);

            for (int i = 0; i < Vectors.Count; i++)
            {
                var pointCount = (Vectors[i].Count + 1) / 2;

                var curve = new PolyCurve();

                var localP = Vectors[i][0];

                var lastPoint = position + localP.X * unitX + localP.Y * unitY;

                for (int j = 1; j < pointCount; j++)
                {
                    localP = Vectors[i][j * 2];

                    var nextPoint = position + localP.X * unitX + localP.Y * unitY;

                    var localT = Vectors[i][j * 2 - 1];

                    if (localT.IsZero)
                    {
                        curve.Append(new Line(lastPoint, nextPoint));
                    }
                    else
                    {
                        var tangent = localT.X * unitX + localT.Y * unitY;

                        curve.Append(new Arc(lastPoint, tangent, nextPoint));
                    }

                    lastPoint = nextPoint;
                }

                curves.Add( curve);
            }

            position += End * unitX;
            
            return curves;
        }
Exemple #9
0
 /// <summary>
 /// Convert a RhinoCommon PolyCurve to a Nucleus one
 /// </summary>
 /// <param name="polyCurve"></param>
 /// <returns></returns>
 public static PolyCurve Convert(RC.PolyCurve polyCurve)
 {
     if (polyCurve != null)
     {
         PolyCurve  result  = new PolyCurve();
         RC.Curve[] subCrvs = polyCurve.Explode();
         foreach (RC.Curve subCrv in subCrvs)
         {
             Curve crv = Convert(subCrv);
             if (crv != null)
             {
                 result.Add(crv);
             }
         }
         return(result);
     }
     return(null);
 }
Exemple #10
0
        /***************************************************/

        public static BHG.ICurve FromRhino(this RHG.PolyCurve polyCurve)
        {
            if (polyCurve == null)
            {
                return(null);
            }

            polyCurve.RemoveNesting();
            if (polyCurve.IsPolyline())
            {
                RHG.Polyline polyline;
                polyCurve.TryGetPolyline(out polyline);
                return(polyline.FromRhino());
            }
            else
            {
                return new BHG.PolyCurve {
                           Curves = polyCurve.Explode().Select(x => x.FromRhino()).ToList()
                }
            };
        }
Exemple #11
0
		private IfcBeam GenerateIPE200(STPModelData md,IfcBuilding building,bool tessellated)
		{
			 
			if (tessellated)
			{
				List<Point3d> coords = new List<Point3d>() { new Point3d(1000.0, 50.0, -91.5), new Point3d(1000.0, 14.8, -91.5), new Point3d(1000.0, 50.0, -100.0), new Point3d(1000.0, -50.0, -100.0), new Point3d(1000.0, -50.0, -91.5), new Point3d(1000.0, -14.8, -91.5), new Point3d(1000.0, -2.8, 79.5), new Point3d(1000.0, -2.8, -79.5), new Point3d(1000.0, -50.0, 91.5), new Point3d(1000.0, -14.8, 91.5), new Point3d(1000.0, -50.0, 100.0), new Point3d(1000.0, 50.0, 100.0), new Point3d(1000.0, 50.0, 91.5), new Point3d(1000.0, 14.8, 91.5), new Point3d(1000.0, 2.8, -79.5), new Point3d(1000.0, 2.8, 79.5), new Point3d(0.0, 2.8, 79.5), new Point3d(0.0, 2.8, -79.5), new Point3d(0.0, 50.0, 91.5), new Point3d(0.0, 14.8, 91.5), new Point3d(0.0, 50.0, 100.0), new Point3d(0.0, -50.0, 100.0), new Point3d(0.0, -50.0, 91.5), new Point3d(0.0, -14.8, 91.5), new Point3d(0.0, -2.8, -79.5), new Point3d(0.0, -2.8, 79.5), new Point3d(0.0, -50.0, -91.5), new Point3d(0.0, -14.8, -91.5), new Point3d(0.0, -50.0, -100.0), new Point3d(0.0, 50.0, -100.0), new Point3d(0.0, 50.0, -91.5), new Point3d(0.0, 14.8, -91.5), new Point3d(0.0, 14.8, -91.5), new Point3d(0.0, 2.8, -79.5), new Point3d(1000.0, 14.8, -91.5), new Point3d(1000.0, 2.8, -79.5), new Point3d(500.0, 2.8, -79.5), new Point3d(500.0, 14.8, -91.5), new Point3d(0.0, 2.8, -79.5), new Point3d(0.0, 2.8, 79.5), new Point3d(1000.0, 2.8, -79.5), new Point3d(1000.0, 2.8, 79.5), new Point3d(500.0, 2.8, -79.5), new Point3d(500.0, 2.8, 79.5), new Point3d(0.0, 2.8, 79.5), new Point3d(0.0, 14.8, 91.5), new Point3d(1000.0, 2.8, 79.5), new Point3d(1000.0, 14.8, 91.5), new Point3d(500.0, 2.8, 79.5), new Point3d(500.0, 14.8, 91.5), new Point3d(0.0, 14.8, 91.5), new Point3d(0.0, 50.0, 91.5), new Point3d(1000.0, 14.8, 91.5), new Point3d(1000.0, 50.0, 91.5), new Point3d(500.0, 14.8, 91.5), new Point3d(500.0, 50.0, 91.5), new Point3d(0.0, 50.0, 91.5), new Point3d(0.0, 50.0, 100.0), new Point3d(1000.0, 50.0, 91.5), new Point3d(1000.0, 50.0, 100.0), new Point3d(500.0, 50.0, 91.5), new Point3d(500.0, 50.0, 100.0), new Point3d(0.0, 50.0, 100.0), new Point3d(0.0, -50.0, 100.0), new Point3d(1000.0, 50.0, 100.0), new Point3d(1000.0, -50.0, 100.0), new Point3d(500.0, 50.0, 100.0), new Point3d(500.0, -50.0, 100.0), new Point3d(0.0, -50.0, 100.0), new Point3d(0.0, -50.0, 91.5), new Point3d(1000.0, -50.0, 100.0), new Point3d(1000.0, -50.0, 91.5), new Point3d(500.0, -50.0, 100.0), new Point3d(500.0, -50.0, 91.5), new Point3d(0.0, -50.0, 91.5), new Point3d(0.0, -14.8, 91.5), new Point3d(1000.0, -50.0, 91.5), new Point3d(1000.0, -14.8, 91.5), new Point3d(500.0, -50.0, 91.5), new Point3d(500.0, -14.8, 91.5), new Point3d(0.0, -14.8, 91.5), new Point3d(0.0, -2.8, 79.5), new Point3d(1000.0, -14.8, 91.5), new Point3d(1000.0, -2.8, 79.5), new Point3d(500.0, -14.8, 91.5), new Point3d(500.0, -2.8, 79.5), new Point3d(0.0, -2.8, 79.5), new Point3d(0.0, -2.8, -79.5), new Point3d(1000.0, -2.8, 79.5), new Point3d(1000.0, -2.8, -79.5), new Point3d(500.0, -2.8, 79.5), new Point3d(500.0, -2.8, -79.5), new Point3d(0.0, -2.8, -79.5), new Point3d(0.0, -14.8, -91.5), new Point3d(1000.0, -2.8, -79.5), new Point3d(1000.0, -14.8, -91.5), new Point3d(500.0, -2.8, -79.5), new Point3d(500.0, -14.8, -91.5), new Point3d(0.0, -14.8, -91.5), new Point3d(0.0, -50.0, -91.5), new Point3d(1000.0, -14.8, -91.5), new Point3d(1000.0, -50.0, -91.5), new Point3d(500.0, -14.8, -91.5), new Point3d(500.0, -50.0, -91.5), new Point3d(0.0, -50.0, -91.5), new Point3d(0.0, -50.0, -100.0), new Point3d(1000.0, -50.0, -91.5), new Point3d(1000.0, -50.0, -100.0), new Point3d(500.0, -50.0, -91.5), new Point3d(500.0, -50.0, -100.0), new Point3d(0.0, -50.0, -100.0), new Point3d(0.0, 50.0, -100.0), new Point3d(1000.0, -50.0, -100.0), new Point3d(1000.0, 50.0, -100.0), new Point3d(500.0, -50.0, -100.0), new Point3d(500.0, 50.0, -100.0), new Point3d(0.0, 50.0, -100.0), new Point3d(0.0, 50.0, -91.5), new Point3d(1000.0, 50.0, -100.0), new Point3d(1000.0, 50.0, -91.5), new Point3d(500.0, 50.0, -100.0), new Point3d(500.0, 50.0, -91.5), new Point3d(0.0, 50.0, -91.5), new Point3d(0.0, 14.8, -91.5), new Point3d(1000.0, 50.0, -91.5), new Point3d(1000.0, 14.8, -91.5), new Point3d(500.0, 50.0, -91.5), new Point3d(500.0, 14.8, -91.5) };
				IfcCartesianPointList3D cartesianPointList3D = new IfcCartesianPointList3D(md, coords);
				cartesianPointList3D.Comments.Add("the geometric representation of the beam is provided as a triangulated face set");
				cartesianPointList3D.Comments.Add("the meshing depends on the creating software system");

				List<CoordIndex> coordIndex = new List<CoordIndex>() { new CoordIndex(6, 5, 4), new CoordIndex(15, 8, 6), new CoordIndex(6, 4, 3), new CoordIndex(10, 11, 9), new CoordIndex(16, 10, 7), new CoordIndex(14, 11, 10), new CoordIndex(7, 8, 16), new CoordIndex(6, 2, 15), new CoordIndex(2, 3, 1), new CoordIndex(3, 2, 6), new CoordIndex(10, 16, 14), new CoordIndex(14, 13, 12), new CoordIndex(11, 14, 12), new CoordIndex(8, 15, 16), new CoordIndex(24, 23, 22), new CoordIndex(17, 26, 24), new CoordIndex(22, 21, 20), new CoordIndex(28, 29, 27), new CoordIndex(32, 28, 25), new CoordIndex(30, 29, 28), new CoordIndex(18, 25, 26), new CoordIndex(24, 20, 17), new CoordIndex(20, 21, 19), new CoordIndex(32, 31, 30), new CoordIndex(28, 32, 30), new CoordIndex(33, 34, 37), new CoordIndex(36, 35, 38), new CoordIndex(40, 44, 43), new CoordIndex(41, 43, 44), new CoordIndex(46, 50, 49), new CoordIndex(47, 49, 50), new CoordIndex(56, 55, 51), new CoordIndex(55, 56, 54), new CoordIndex(57, 58, 62), new CoordIndex(60, 59, 61), new CoordIndex(63, 64, 68), new CoordIndex(66, 65, 67), new CoordIndex(69, 70, 74), new CoordIndex(72, 71, 73), new CoordIndex(80, 79, 75), new CoordIndex(79, 80, 78), new CoordIndex(81, 82, 86), new CoordIndex(84, 83, 85), new CoordIndex(88, 92, 91), new CoordIndex(89, 91, 92), new CoordIndex(94, 98, 97), new CoordIndex(95, 97, 98), new CoordIndex(104, 103, 99), new CoordIndex(103, 104, 102), new CoordIndex(105, 106, 110), new CoordIndex(108, 107, 109), new CoordIndex(111, 112, 116), new CoordIndex(114, 113, 115), new CoordIndex(117, 118, 122), new CoordIndex(120, 119, 121), new CoordIndex(128, 127, 123), new CoordIndex(127, 128, 126), new CoordIndex(22, 20, 24), new CoordIndex(32, 25, 18), new CoordIndex(18, 26, 17), new CoordIndex(33, 37, 38), new CoordIndex(36, 38, 37), new CoordIndex(40, 43, 39), new CoordIndex(41, 44, 42), new CoordIndex(46, 49, 45), new CoordIndex(47, 50, 48), new CoordIndex(56, 51, 52), new CoordIndex(55, 54, 53), new CoordIndex(57, 62, 61), new CoordIndex(60, 61, 62), new CoordIndex(63, 68, 67), new CoordIndex(66, 67, 68), new CoordIndex(69, 74, 73), new CoordIndex(72, 73, 74), new CoordIndex(80, 75, 76), new CoordIndex(79, 78, 77), new CoordIndex(81, 86, 85), new CoordIndex(84, 85, 86), new CoordIndex(88, 91, 87), new CoordIndex(89, 92, 90), new CoordIndex(94, 97, 93), new CoordIndex(95, 98, 96), new CoordIndex(104, 99, 100), new CoordIndex(103, 102, 101), new CoordIndex(105, 110, 109), new CoordIndex(108, 109, 110), new CoordIndex(111, 116, 115), new CoordIndex(114, 115, 116), new CoordIndex(117, 122, 121), new CoordIndex(120, 121, 122), new CoordIndex(128, 123, 124), new CoordIndex(127, 126, 125) };
				IfcTriangulatedFaceSet triangulatedFaceSet = new IfcTriangulatedFaceSet(md, cartesianPointList3D, null, true, coordIndex, null);

				return new IfcBeam(building, triangulatedFaceSet) { GlobalId = "0EF5_zZRv0pQPddeofU3KT", Name = "ExampleBeamName",Description = "ExampleBeamDescription",Tag = "Tag" };
			}

			List<Point3d> points = new List<Point3d>() {new Point3d(2.8,-79.5,0),new Point3d(2.8,79.5,0),new Point3d(6.314719,87.985281,0),new Point3d(14.8,91.5,0),new Point3d(50.0,91.5,0),new Point3d(50.0,100.0,0),new Point3d(-50.0,100.0,0),new Point3d(-50.0,91.5,0),new Point3d(-14.8,91.5,0),new Point3d(-6.314719,87.985281,0),new Point3d(-2.8,79.5,0),new Point3d(-2.8,-79.5,0),new Point3d(-6.314719,-87.985281,0),new Point3d(-14.8,-91.5,0),new Point3d(-50.0,-91.5,0),new Point3d(-50.0,-100.0,0),new Point3d(50.0,-100.0,0),new Point3d(50.0,-91.5,0),new Point3d(14.8,-91.5,0),new Point3d(6.314719,-87.985281,0) };
			PolyCurve pc = new PolyCurve();
			pc.Append(new Line(points[0],points[1]));
			pc.Append(new Arc(points[1],points[2],points[3]));
			pc.Append(new Line(points[3],points[4]));
			pc.Append(new Line(points[4],points[5]));
			pc.Append(new Line(points[5],points[6]));
			pc.Append(new Line(points[6],points[7]));
			pc.Append(new Line(points[7],points[8]));
			pc.Append(new Arc(points[8],points[9],points[10]));
			pc.Append(new Line(points[10],points[11]));
			pc.Append(new Arc(points[11],points[12],points[13]));
			pc.Append(new Line(points[13], points[14]));
			pc.Append(new Line(points[14], points[15]));
			pc.Append(new Line(points[15], points[16]));
			pc.Append(new Line(points[16], points[17]));
			pc.Append(new Line(points[17], points[18]));
			pc.Append(new Arc(points[18],points[19],points[0]));
			IfcBoundedCurve boundedCurve = IfcBoundedCurve.ConvertCurve(md, pc);
			IfcArbitraryClosedProfileDef arbitraryClosedProfileDef = new IfcArbitraryClosedProfileDef("IPE200",boundedCurve);
			IfcAxis2Placement3D axis2Placement3D = new IfcAxis2Placement3D(new IfcCartesianPoint(md,0,0,0),new IfcDirection(md,0,1,0),new IfcDirection(md,1,0,0));
			IfcExtrudedAreaSolid extrudedAreaSolid = new IfcExtrudedAreaSolid(arbitraryClosedProfileDef, axis2Placement3D,new IfcDirection(md,0,0,1),1000);
			return new IfcBeam(building, extrudedAreaSolid) { GlobalId = "0EF5_zZRv0pQPddeofU3KT", Name = "ExampleBeamName",Description = "ExampleBeamDescription", Tag = "Tag" }; 
		}
Exemple #12
0
        /***************************************************/

        public static RHG.PolyCurve ToRhino(this BHG.PolyCurve bPolyCurve)
        {
            if (bPolyCurve == null)
            {
                return(null);
            }

            IEnumerable <RHG.Curve> parts = bPolyCurve.Curves.Select(x => x.IToRhino());

            // Check if bPolycurve is made of disconnected segments
            if (RHG.Curve.JoinCurves(parts).Length > 1)
            {
                return(null);
            }

            RHG.PolyCurve rPolycurve = new RHG.PolyCurve();
            foreach (RHG.Curve curve in parts)
            {
                rPolycurve.Append(curve);
            }
            return(rPolycurve);
        }
Exemple #13
0
        internal static GeometryBase CreateGeometryHelper(IntPtr pGeometry, object parent, int subobjectIndex)
        {
            if (IntPtr.Zero == pGeometry)
            {
                return(null);
            }

            var type = UnsafeNativeMethods.ON_Geometry_GetGeometryType(pGeometry);

            if (type < 0)
            {
                return(null);
            }
            GeometryBase rc = null;

            switch (type)
            {
            case UnsafeNativeMethods.OnGeometryTypeConsts.ON_Curve: //1
                rc = new Curve(pGeometry, parent, subobjectIndex);
                break;

            case UnsafeNativeMethods.OnGeometryTypeConsts.ON_NurbsCurve: //2
                rc = new NurbsCurve(pGeometry, parent, subobjectIndex);
                break;

            case UnsafeNativeMethods.OnGeometryTypeConsts.ON_PolyCurve: // 3
                rc = new PolyCurve(pGeometry, parent, subobjectIndex);
                break;

            case UnsafeNativeMethods.OnGeometryTypeConsts.ON_PolylineCurve: //4
                rc = new PolylineCurve(pGeometry, parent, subobjectIndex);
                break;

            case UnsafeNativeMethods.OnGeometryTypeConsts.ON_ArcCurve: //5
                rc = new ArcCurve(pGeometry, parent, subobjectIndex);
                break;

            case UnsafeNativeMethods.OnGeometryTypeConsts.ON_LineCurve: //6
                rc = new LineCurve(pGeometry, parent, subobjectIndex);
                break;

            case UnsafeNativeMethods.OnGeometryTypeConsts.ON_Mesh: //7
                rc = new Mesh(pGeometry, parent);
                break;

            case UnsafeNativeMethods.OnGeometryTypeConsts.ON_Point: //8
                rc = new Point(pGeometry, parent);
                break;

            case UnsafeNativeMethods.OnGeometryTypeConsts.ON_TextDot: //9
                rc = new TextDot(pGeometry, parent);
                break;

            case UnsafeNativeMethods.OnGeometryTypeConsts.ON_Surface: //10
                rc = new Surface(pGeometry, parent);
                break;

            case UnsafeNativeMethods.OnGeometryTypeConsts.ON_Brep: //11
                rc = new Brep(pGeometry, parent);
                break;

            case UnsafeNativeMethods.OnGeometryTypeConsts.ON_NurbsSurface: //12
                rc = new NurbsSurface(pGeometry, parent);
                break;

            case UnsafeNativeMethods.OnGeometryTypeConsts.ON_RevSurface: //13
                rc = new RevSurface(pGeometry, parent);
                break;

            case UnsafeNativeMethods.OnGeometryTypeConsts.ON_PlaneSurface: //14
                rc = new PlaneSurface(pGeometry, parent);
                break;

            case UnsafeNativeMethods.OnGeometryTypeConsts.ON_ClippingPlaneSurface: //15
                rc = new ClippingPlaneSurface(pGeometry, parent);
                break;

            case UnsafeNativeMethods.OnGeometryTypeConsts.ON_Hatch: // 17
                rc = new Hatch(pGeometry, parent);
                break;

            case UnsafeNativeMethods.OnGeometryTypeConsts.ON_SumSurface: //19
                rc = new SumSurface(pGeometry, parent);
                break;

            case UnsafeNativeMethods.OnGeometryTypeConsts.ON_BrepFace: //20
            {
                int    faceindex = -1;
                IntPtr ptr_brep  = UnsafeNativeMethods.ON_BrepSubItem_Brep(pGeometry, ref faceindex);
                if (ptr_brep != IntPtr.Zero && faceindex >= 0)
                {
                    Brep b = new Brep(ptr_brep, parent);
                    rc = b.Faces[faceindex];
                }
            }
            break;

            case UnsafeNativeMethods.OnGeometryTypeConsts.ON_BrepEdge: // 21
            {
                int    edgeindex = -1;
                IntPtr ptr_brep  = UnsafeNativeMethods.ON_BrepSubItem_Brep(pGeometry, ref edgeindex);
                if (ptr_brep != IntPtr.Zero && edgeindex >= 0)
                {
                    Brep b = new Brep(ptr_brep, parent);
                    rc = b.Edges[edgeindex];
                }
            }
            break;

            case UnsafeNativeMethods.OnGeometryTypeConsts.ON_InstanceReference: // 23
                rc = new InstanceReferenceGeometry(pGeometry, parent);
                break;

            case UnsafeNativeMethods.OnGeometryTypeConsts.ON_Extrusion: //24
                rc = new Extrusion(pGeometry, parent);
                break;

            case UnsafeNativeMethods.OnGeometryTypeConsts.ON_PointCloud: // 26
                rc = new PointCloud(pGeometry, parent);
                break;

            case UnsafeNativeMethods.OnGeometryTypeConsts.ON_DetailView: // 27
                rc = new DetailView(pGeometry, parent);
                break;

            case UnsafeNativeMethods.OnGeometryTypeConsts.ON_Light: //32
                rc = new Light(pGeometry, parent);
                break;

            case UnsafeNativeMethods.OnGeometryTypeConsts.ON_PointGrid: //33
                rc = new Point3dGrid(pGeometry, parent);
                break;

            case UnsafeNativeMethods.OnGeometryTypeConsts.ON_MorphControl: //34
                rc = new MorphControl(pGeometry, parent);
                break;

            case UnsafeNativeMethods.OnGeometryTypeConsts.ON_BrepLoop: //35
            {
                int    loopindex = -1;
                IntPtr ptr_brep  = UnsafeNativeMethods.ON_BrepSubItem_Brep(pGeometry, ref loopindex);
                if (ptr_brep != IntPtr.Zero && loopindex >= 0)
                {
                    Brep b = new Brep(ptr_brep, parent);
                    rc = b.Loops[loopindex];
                }
            }
            break;

            case UnsafeNativeMethods.OnGeometryTypeConsts.ON_BrepTrim: // 36
            {
                int    trimindex = -1;
                IntPtr ptr_brep  = UnsafeNativeMethods.ON_BrepSubItem_Brep(pGeometry, ref trimindex);
                if (ptr_brep != IntPtr.Zero && trimindex >= 0)
                {
                    Brep b = new Brep(ptr_brep, parent);
                    rc = b.Trims[trimindex];
                }
            }
            break;

            case UnsafeNativeMethods.OnGeometryTypeConsts.ON_Leader: // 38
                rc = new Leader(pGeometry, parent);
                break;

            case UnsafeNativeMethods.OnGeometryTypeConsts.ON_SubD: // 39
                rc = new SubD(pGeometry, parent);
                break;

            case UnsafeNativeMethods.OnGeometryTypeConsts.ON_DimLinear: //40
                rc = new LinearDimension(pGeometry, parent);
                break;

            case UnsafeNativeMethods.OnGeometryTypeConsts.ON_DimAngular: //41
                rc = new AngularDimension(pGeometry, parent);
                break;

            case UnsafeNativeMethods.OnGeometryTypeConsts.ON_DimRadial: //42
                rc = new RadialDimension(pGeometry, parent);
                break;

            case UnsafeNativeMethods.OnGeometryTypeConsts.ON_DimOrdinate: //43
                rc = new OrdinateDimension(pGeometry, parent);
                break;

            case UnsafeNativeMethods.OnGeometryTypeConsts.ON_Centermark: //44
                rc = new Centermark(pGeometry, parent);
                break;

            case UnsafeNativeMethods.OnGeometryTypeConsts.ON_Text: //45
                rc = new TextEntity(pGeometry, parent);
                break;

            default:
                rc = new UnknownGeometry(pGeometry, parent, subobjectIndex);
                break;
            }

            return(rc);
        }
        private void createStripe(int firstVertexIndex, int secondVertexIndex, int thirdVertexIndex, GH_Path path, int item)
        {
            // first vertex in the stripe direction
            Point3d a = bottomCps[firstVertexIndex];
            Point3d A = topCps[firstVertexIndex];

            Point3d b = bottomCps[secondVertexIndex];
            Point3d B = topCps[secondVertexIndex];

            Point3d c = bottomCps[thirdVertexIndex];
            Point3d C = topCps[thirdVertexIndex];

            // Centre of Edge AB
            Point3d ab = 0.5 * (a + b);
            Point3d AB = 0.5 * (A + B);

            // Centre of Edge AC
            Point3d ac = 0.5 * (a + c);
            Point3d AC = 0.5 * (A + C);

            // Centre of Mesh Face
            Point3d m = (ab + ac + 0.5 * (b + c)) / 3;
            Point3d M = (AB + AC + 0.5 * (B + C)) / 3;

            // perform planar Offset
            double planarOffset = planarVerticesValues[firstVertexIndex];
            double curveScaler = curveVerticesValues[firstVertexIndex];
            double openingScaler = openingWidthVerticesValues[firstVertexIndex];
            double curvePointiness = pointinessValues[firstVertexIndex];

            if (ManualAdjustedVertexIndexies.Contains(firstVertexIndex))
            {
                GH_Path pth = new GH_Path(firstVertexIndex);

                planarOffset = ManualValueTree[new GH_Path(firstVertexIndex)][2].Value;
                curveScaler = ManualValueTree[new GH_Path(firstVertexIndex)][0].Value;
                openingScaler = ManualValueTree[new GH_Path(firstVertexIndex)][3].Value;
                curvePointiness = ManualValueTree[new GH_Path(firstVertexIndex)][1].Value;

            }

            // Offset : Centre of Edge AB
            Vector3d v_ab = a - b;
            Vector3d v_AB = A - B;
            v_ab.Unitize();
            v_AB.Unitize();

            // Offset : Centre of Edge AC
            Vector3d v_ac = a - c;
            Vector3d v_AC = A - C;
            v_ac.Unitize();
            v_AC.Unitize();

            // not used
            #region Correct Offset
            /*

            // Angles
            Vector3d ac_ab = ac - ab; ac_ab.Unitize();
            Vector3d AC_AB = AC - AB; AC_AB.Unitize();

            double dotProduct_b = ac_ab * v_ab;
            double dotProduct_B = AC_AB * v_AB;
            double dotProduct_c = -ac_ab * v_ac;
            double dotProduct_C = -AC_AB * v_AC;

            Utils.ToDegree(dotProduct_b);
            Utils.ToDegree(dotProduct_B);
            Utils.ToDegree(dotProduct_c);
            Utils.ToDegree(dotProduct_C);

            v_ab *= planarOffset / Math.Tan(Math.Acos(dotProduct_b));
            v_AB *= planarOffset / Math.Tan(Math.Acos(dotProduct_B));
            v_ac *= planarOffset / Math.Tan(Math.Acos(dotProduct_c));
            v_AC *= planarOffset / Math.Tan(Math.Acos(dotProduct_C));

            */
            #endregion correct offset

            // create offset point
            Point3d oab = ab + (v_ab * planarOffset);
            Point3d oAB = AB + (v_AB * planarOffset);

            // create offset point
            Point3d oac = ac + (v_ac * planarOffset);
            Point3d oAC = AC + (v_AC * planarOffset);

            //---- Super normalization of Offset Points ----------------------------------------------------------------------------

            // shortest connected Edge (changes offset point; normalize offset point)
            if (iSuperNormalization == true)
            {
                List<int> neighbourVertices = iSpringMesh.Vertices[firstVertexIndex].NeighborVertexIndices;
                double minimalLengthTop = 999999999999;
                double minimalLengthBottom = 9999999999999;

                foreach (int i in neighbourVertices)
                {
                    Vector3d vectorBottom = bottomCps[firstVertexIndex] - bottomCps[i];
                    Vector3d vectorTop = topCps[firstVertexIndex] - topCps[i];

                    if (vectorBottom.Length * 0.5 < minimalLengthBottom)
                        minimalLengthBottom = vectorBottom.Length * 0.5;

                    if (vectorTop.Length * 0.5 < minimalLengthTop)
                        minimalLengthTop = vectorTop.Length * 0.5;
                }
                //Test:
                minimalLengthBottom = (minimalLengthTop + minimalLengthBottom) * 0.5;
                minimalLengthTop = minimalLengthBottom;
                //End Test

                oab = a - (v_ab * (minimalLengthBottom - planarOffset));
                oAB = A - (v_AB * (minimalLengthTop - planarOffset));

                oac = a - (v_ac * (minimalLengthBottom - planarOffset));
                oAC = A - (v_AC * (minimalLengthTop - planarOffset));
            }

            //---- End Super normalization of Offset Points ----------------------------------------------------------------------------

            Point3d AAB = curveScaler * A + (1.0 - curveScaler) * oAB;
            Point3d aab = curveScaler * a + (1.0 - curveScaler) * oab;

            Point3d AAC = curveScaler * A + (1.0 - curveScaler) * oAC;
            Point3d aac = curveScaler * a + (1.0 - curveScaler) * oac;

            Point3d openingAAB = (-1 * v_AB * openingScaler) + A;
            Point3d openingaab = (-1 * v_ab * openingScaler) + a;

            Point3d openingAAC = (-1 * v_AC * openingScaler) + A;
            Point3d openingaac = (-1 * v_ac * openingScaler) + a;

            // Condition, choose between Opening Width and tangentscale

            if (new Vector3d(AAB - A).Length > openingScaler)
                AAB = openingAAB;

            if (new Vector3d(aab - a).Length > openingScaler)
                aab = openingaab;

            if (new Vector3d(AAC - A).Length > openingScaler)
                AAC = openingAAC;

            if (new Vector3d(aac - a).Length > openingScaler)
                aac = openingaac;

            // Pointiness of the Surface

            Point3d max_aA = 0.5 * (a + A);
            Point3d min_aA1 = 0.5 * (aab + AAB);
            Point3d min_aA2 = 0.5 * (aac + AAC);
            Point3d aA1 = (curvePointiness * max_aA) + ((1 - curvePointiness) * min_aA1);
            Point3d aA2 = (curvePointiness * max_aA) + ((1 - curvePointiness) * min_aA2);

            // Create Curves
            Curve profileCurve1 = Curve.CreateControlPointCurve(new List<Point3d>() { oab, aab, aA1, AAB, oAB }, curveDegree);
            Curve profileCurve2 = Curve.CreateControlPointCurve(new List<Point3d>() { oac, aac, aA2, AAC, oAC }, curveDegree);
            Curve profileCrv11 = Curve.CreateControlPointCurve(new List<Point3d>() { ab, oab }, 1);
            Curve profileCrv12 = Curve.CreateControlPointCurve(new List<Point3d>() { oAB, AB }, 1);
            Curve profileCrv21 = Curve.CreateControlPointCurve(new List<Point3d>() { ac, oac }, 1);
            Curve profileCrv22 = Curve.CreateControlPointCurve(new List<Point3d>() { oAC, AC }, 1);

            Curve profileCurveNew1 = Curve.JoinCurves(new List<Curve>() { profileCrv11, profileCurve1, profileCrv12 }, documentTolerance, true)[0];
            Curve profileCurveNew2 = Curve.JoinCurves(new List<Curve>() { profileCrv21, profileCurve2, profileCrv22 }, documentTolerance, true)[0];

            oTriLoopCurves.Add(profileCurveNew1, path.AppendElement(item));
            oTriLoopCurves.Add(profileCurveNew2, path.AppendElement(item));

            if (iPolySrf)
            {
                //not used method : if triloop need to be polySurface.
                #region Genes Method
                /*
                PolyCurve polyCurve1 = new PolyCurve();
                polyCurve1.Append(new LineCurve(m, ab));
                polyCurve1.Append(new LineCurve(ab, oab));
                polyCurve1.Append(profileCurve1);
                polyCurve1.Append(new LineCurve(oAB, AB));
                polyCurve1.Append(new LineCurve(AB, M));

                PolyCurve polyCurve2 = new PolyCurve();
                polyCurve2.Append(new LineCurve(m, ac));
                polyCurve2.Append(new LineCurve(ac, oac));
                polyCurve2.Append(profileCurve2);
                polyCurve2.Append(new LineCurve(oAC, AC));
                polyCurve2.Append(new LineCurve(AC, M));

                oTriLoop.Add(
                    Brep.CreateFromLoft(
                       new List<Curve>() { polyCurve1, polyCurve2 },
                       Point3d.Unset, Point3d.Unset,
                       LoftType.Normal,
                       false
                       )[0], path.AppendElement(item)
                   );

                */
                #endregion Genes Method

                //used method
                #region Seperate Planar from Curved Method
                PolyCurve polyCurve1 = new PolyCurve();
                polyCurve1.Append(profileCurve1);

                PolyCurve polyCurve2 = new PolyCurve();
                polyCurve2.Append(profileCurve2);

                // Planar Part Curves
                Curve planarCurveBottom = Curve.CreateControlPointCurve(new List<Point3d>() { m, ac, oac, oab, ab, m }, 1);
                Curve planarCurveTop = Curve.CreateControlPointCurve(new List<Point3d>() { M, AB, oAB, oAC, AC, M }, 1);

                // Add Planar Crv
                oTriLoopPlanCrv.Add(planarCurveBottom, path.AppendElement(item));
                oTriLoopPlanCrv.Add(planarCurveTop, path.AppendElement(item));

                // Add Bended Brep
                oTriLoop.Add(
                    Brep.CreateFromLoft(
                       new List<Curve>() { polyCurve1, polyCurve2 },
                       Point3d.Unset, Point3d.Unset,
                       LoftType.Normal,
                       false
                       )[0], path.AppendElement(item)
                   );
                #endregion Seperate Planar from Curved Method

            }
            else
            #region single surface
            {
                profileCurve1 = Curve.JoinCurves(
                    new List<Curve>() { new LineCurve(b, oab), profileCurve1, new LineCurve(oAB, B) },
                    documentTolerance,
                    true)[0];

                profileCurve2 = Curve.JoinCurves(
                    new List<Curve>() { new LineCurve(c, oac), profileCurve2, new LineCurve(oAC, C) },
                    documentTolerance,
                    true)[0];

                // Planar Part Curves
                Curve planarCurveBottom = Curve.CreateControlPointCurve(new List<Point3d>() { m, ac, oac, oab, ab, m }, 1);
                Curve planarCurveTop = Curve.CreateControlPointCurve(new List<Point3d>() { M, AB, oAB, oAC, AC, M }, 1);
                // Add Planar Crvs
                oTriLoopPlanCrv.Add(planarCurveBottom, path.AppendElement(item));
                oTriLoopPlanCrv.Add(planarCurveTop, path.AppendElement(item));

                Brep brep = Brep.CreateFromLoft(
                       new List<Curve>() { profileCurve1, profileCurve2 },
                       Point3d.Unset, Point3d.Unset,
                       LoftType.Normal,
                       false
                       )[0];

                // =============================================
                // Trim the brep using planes
                // =============================================

                double offsetAmount = 0.2;
                Vector3d normal;
                Brep[] breps;

                normal = Vector3d.CrossProduct(B - A, C - A);

                Point3d A_ = A + offsetAmount * normal;

                breps = brep.Trim(new Plane(A_, AB, M), documentTolerance);
                if (breps.Length > 0) brep = breps[0];
                else { oTriLoop.Add(brep, path.AppendElement(item)); return; }

                breps = brep.Trim(new Plane(A_, M, AC), documentTolerance);
                if (breps.Length > 0) brep = breps[0];
                else { oTriLoop.Add(brep, path.AppendElement(item)); return; }

                normal = Vector3d.CrossProduct(b - a, c - a);

                Point3d a_ = a - offsetAmount * normal;

                breps = brep.Trim(new Plane(a_, m, ab), documentTolerance);
                if (breps.Length > 0) brep = breps[0];
                else { oTriLoop.Add(brep, path.AppendElement(item)); return; }

                breps = brep.Trim(new Plane(a_, ac, m), documentTolerance);
                if (breps.Length > 0) brep = breps[0];
                else { oTriLoop.Add(brep, path.AppendElement(item)); return; }

                oTriLoop.Add(brep, path.AppendElement(item));
            }
            #endregion single surface

            #region close panel

            // close panel
            //Point3d closeVertice = Point3dList.ClosestPointInList(iClosedPanelPts, iSpringMesh.Vertices[firstVertexIndex].Position);
            //if (ICD.Utils.Distance(closeVertice, iSpringMesh.Vertices[firstVertexIndex].Position) < iClosePanelDist)
            if (iVertexPanel2[firstVertexIndex])
            {
                oClosedPanel.Add(
                    Brep.CreateFromLoft(
                       new List<Curve>() { new LineCurve(A, oAB), new LineCurve(A, oAC) },
                       Point3d.Unset, Point3d.Unset,
                       LoftType.Normal,
                       false
                       )[0], path.AppendElement(item)
                    );
                oClosedPanel.Add(
                    Brep.CreateFromLoft(
                       new List<Curve>() { new LineCurve(oab, a), new LineCurve(oac, a) },
                       Point3d.Unset, Point3d.Unset,
                       LoftType.Normal,
                       false
                       )[0], path.AppendElement(item)
                    );
            }

            #endregion close panel

            // do EffectorHoles
            List<Point3d> EffectorHoleTop = EffectorHoles(A, B, C, M, oAB, oAC, item);
            List<Point3d> EffectorHoleBottom = EffectorHoles(a, b, c, m, oab, oac, item);

            foreach (Point3d pt in EffectorHoleTop)
                oTriLoopEffectorHoles.Add(pt, path.AppendElement(item).AppendElement(1));

            foreach (Point3d pt in EffectorHoleBottom)
                oTriLoopEffectorHoles.Add(pt, path.AppendElement(item).AppendElement(0));
        }
    internal static GeometryBase CreateGeometryHelper(IntPtr pGeometry, object parent, int subobject_index)
    {
      if (IntPtr.Zero == pGeometry)
        return null;

      int type = UnsafeNativeMethods.ON_Geometry_GetGeometryType(pGeometry);
      if (type < 0)
        return null;
      GeometryBase rc = null;

      switch (type)
      {
        case idxON_Curve: //1
          rc = new Curve(pGeometry, parent, subobject_index);
          break;
        case idxON_NurbsCurve: //2
          rc = new NurbsCurve(pGeometry, parent, subobject_index);
          break;
        case idxON_PolyCurve: // 3
          rc = new PolyCurve(pGeometry, parent, subobject_index);
          break;
        case idxON_PolylineCurve: //4
          rc = new PolylineCurve(pGeometry, parent, subobject_index);
          break;
        case idxON_ArcCurve: //5
          rc = new ArcCurve(pGeometry, parent, subobject_index);
          break;
        case idxON_LineCurve: //6
          rc = new LineCurve(pGeometry, parent, subobject_index);
          break;
        case idxON_Mesh: //7
          rc = new Mesh(pGeometry, parent);
          break;
        case idxON_Point: //8
          rc = new Point(pGeometry, parent);
          break;
        case idxON_TextDot: //9
          rc = new TextDot(pGeometry, parent);
          break;
        case idxON_Surface: //10
          rc = new Surface(pGeometry, parent);
          break;
        case idxON_Brep: //11
          rc = new Brep(pGeometry, parent);
          break;
        case idxON_NurbsSurface: //12
          rc = new NurbsSurface(pGeometry, parent);
          break;
        case idxON_RevSurface: //13
          rc = new RevSurface(pGeometry, parent);
          break;
        case idxON_PlaneSurface: //14
          rc = new PlaneSurface(pGeometry, parent);
          break;
        case idxON_ClippingPlaneSurface: //15
          rc = new ClippingPlaneSurface(pGeometry, parent);
          break;
        case idxON_Annotation2: // 16
          rc = new AnnotationBase(pGeometry, parent);
          break;
        case idxON_Hatch: // 17
          rc = new Hatch(pGeometry, parent);
          break;
        case idxON_TextEntity2: //18
          rc = new TextEntity(pGeometry, parent);
          break;
        case idxON_SumSurface: //19
          rc = new SumSurface(pGeometry, parent);
          break;
        case idxON_BrepFace: //20
          {
            int faceindex = -1;
            IntPtr pBrep = UnsafeNativeMethods.ON_BrepSubItem_Brep(pGeometry, ref faceindex);
            if (pBrep != IntPtr.Zero && faceindex >= 0)
            {
              Brep b = new Brep(pBrep, parent);
              rc = b.Faces[faceindex];
            }
          }
          break;
        case idxON_BrepEdge: // 21
          {
            int edgeindex = -1;
            IntPtr pBrep = UnsafeNativeMethods.ON_BrepSubItem_Brep(pGeometry, ref edgeindex);
            if (pBrep != IntPtr.Zero && edgeindex >= 0)
            {
              Brep b = new Brep(pBrep, parent);
              rc = b.Edges[edgeindex];
            }
          }
          break;
        case idxON_InstanceDefinition: // 22
          rc = new InstanceDefinitionGeometry(pGeometry, parent);
          break;
        case idxON_InstanceReference: // 23
          rc = new InstanceReferenceGeometry(pGeometry, parent);
          break;
#if USING_V5_SDK
        case idxON_Extrusion: //24
          rc = new Extrusion(pGeometry, parent);
          break;
#endif
        case idxON_LinearDimension2: //25
          rc = new LinearDimension(pGeometry, parent);
          break;
        case idxON_PointCloud: // 26
          rc = new PointCloud(pGeometry, parent);
          break;
        case idxON_DetailView: // 27
          rc = new DetailView(pGeometry, parent);
          break;
        case idxON_AngularDimension2: // 28
          rc = new AngularDimension(pGeometry, parent);
          break;
        case idxON_RadialDimension2: // 29
          rc = new RadialDimension(pGeometry, parent);
          break;
        case idxON_Leader: // 30
          rc = new Leader(pGeometry, parent);
          break;
        case idxON_OrdinateDimension2: // 31
          rc = new OrdinateDimension(pGeometry, parent);
          break;
        case idxON_Light: //32
          rc = new Light(pGeometry, parent);
          break;
        case idxON_PointGrid: //33
          rc = new Point3dGrid(pGeometry, parent);
          break;
        case idxON_MorphControl: //34
          rc = new MorphControl(pGeometry, parent);
          break;
        case idxON_BrepLoop: //35
          {
            int loopindex = -1;
            IntPtr pBrep = UnsafeNativeMethods.ON_BrepSubItem_Brep(pGeometry, ref loopindex);
            if (pBrep != IntPtr.Zero && loopindex >= 0)
            {
              Brep b = new Brep(pBrep, parent);
              rc = b.Loops[loopindex];
            }
          }
          break;
        case idxON_BrepTrim: // 36
          {
            int trimindex = -1;
            IntPtr pBrep = UnsafeNativeMethods.ON_BrepSubItem_Brep(pGeometry, ref trimindex);
            if (pBrep != IntPtr.Zero && trimindex >= 0)
            {
              Brep b = new Brep(pBrep, parent);
              rc = b.Trims[trimindex];
            }
          }
          break;
        default:
          rc = new UnknownGeometry(pGeometry, parent, subobject_index);
          break;
      }

      return rc;
    }
Exemple #16
0
        public CurveConverter(Point3dConverter ptConv, ArcConverter arcConv, LineConverter lineConv)
        {
            //to convert ArcCurves
            AddConverter(new PipeConverter <rh.ArcCurve, pp.Arc>(
                             (rhArc) => { return(arcConv.ToPipe <rh.Arc, pp.Arc>(rhArc.Arc)); },
                             (ppArc) => { return(new rh.ArcCurve(arcConv.FromPipe <rh.Arc, pp.Arc>(ppArc))); }
                             ));
            //to convert LineCurves
            AddConverter(new PipeConverter <rh.LineCurve, pp.Line>(
                             (rhLine) => { return(lineConv.ToPipe <rh.Line, pp.Line>(rhLine.Line)); },
                             (ppLine) => { return(new rh.LineCurve(lineConv.FromPipe <rh.Line, pp.Line>(ppLine))); }
                             ));
            //to convert polyline curves
            AddConverter(new PipeConverter <rh.PolylineCurve, pp.Polyline>(
                             (rhpl) =>
            {
                List <ppg.Vec> ptList = new List <ppg.Vec>();
                int ptCount           = rhpl.PointCount;
                for (int i = 0; i < ptCount; i++)
                {
                    ptList.Add(ptConv.ToPipe <rh.Point3d, ppg.Vec>(rhpl.Point(i)));
                }
                return(new pp.Polyline(ptList));
            },
                             (ppl) =>
            {
                List <rh.Point3d> ptList = new List <rh.Point3d>();
                foreach (var pt in ppl.Points)
                {
                    ptList.Add(ptConv.FromPipe <rh.Point3d, ppg.Vec>(pt));
                }
                return(new rh.PolylineCurve(ptList));
            }
                             ));
            //to convert nurbs curves
            AddConverter(new PipeConverter <rh.NurbsCurve, pp.NurbsCurve>(
                             (rhc) => {
                pp.NurbsCurve curve;

                /*
                 * if the curve is closed, the internal NurbsCurve datastructure stores too many points in the
                 * array, in order to loop around to the next knot, we want to take a smaller list in that case
                 */
                //rebuilding the curve just in case.. if there is something weird about the curve
                var rhc2 = rhc.Rebuild(rhc.Points.Count, rhc.Degree, true);
                rhc      = rhc2 ?? rhc;

                int controlPtsNum = rhc.IsClosed ? rhc.Points.Count - (rhc.IsPeriodic ? rhc.Degree : 1)
                            : rhc.Points.Count;
                List <ppg.Vec> ptList = rhc.Points.Take(controlPtsNum).Select(
                    (pt) => ptConv.ToPipe <rh.Point3d, ppg.Vec>(pt.Location)).ToList();

                //normalizing the knots to be between 0 and 1
                List <double> knotList = rhc.Knots.Select((k) => (k - rhc.Domain.Min) / (rhc.Domain.Length)).ToList();
                curve = new pp.NurbsCurve(ptList, rhc.Degree,
                                          rhc.Points.Take(controlPtsNum).Select((pt) => pt.Weight).ToList(), knotList, rhc.IsClosed);
                curve.IsPeriodic = rhc.IsPeriodic;

                return(curve);
            },
                             (ppc) => {
                List <rh.Point3d> ptList = ppc.ControlPoints.Select(
                    (pt) => ptConv.FromPipe <rh.Point3d, ppg.Vec>(pt)).ToList();

                /*
                 * If the curve is closed, then rhino expects the first point to appear at the end of the
                 * control point list again, so we add it.
                 */
                if (ppc.IsClosed)
                {
                    ptList.Add(ptList.First());
                }
                rh.NurbsCurve curve = rh.NurbsCurve.Create(ppc.IsPeriodic, ppc.Degree, ptList);
                if (ppc.IsClosed && ppc.ControlPoints.Count > 3 && !curve.IsClosed)
                {
                    curve.MakeClosed(1e-7);
                }

                if (!ppc.IsRational)
                {
                    for (int i = 0; i < curve.Points.Count; i++)
                    {
                        var pt    = curve.Points.ElementAt(i);
                        var newPt = new rh.Point4d(pt.Location.X, pt.Location.Y, pt.Location.Z, ppc.Weights[i % ppc.Weights.Count]);
                        curve.Points.SetPoint(i, newPt);
                    }
                }
                //setting knots after scaling them to the domain
                if (ppc.Knots.Count == curve.Knots.Count)
                {
                    for (int i = 0; i < ppc.Knots.Count; i++)
                    {
                        curve.Knots[i] = ppc.Knots[i] * (curve.Domain.Length) + curve.Domain.Min;
                    }
                }

                string msg;
                if (!curve.IsValidWithLog(out msg))
                {
                    System.Diagnostics.Debug.WriteLine(msg);
                    if (curve.IsPeriodic)
                    {
                        curve.Knots.CreatePeriodicKnots(1.0 / (curve.Points.Count));
                    }
                    else
                    {
                        curve.Knots.CreateUniformKnots(1.0 / (curve.Points.Count));
                    }
                    if (!curve.IsValid)
                    {
                        throw new InvalidOperationException("Cannot create a valid curve with " +
                                                            "received data because: \n" + msg);
                    }
                }

                return(curve);
            }
                             ));

            //to convert polycurves
            AddConverter(new PipeConverter <rh.PolyCurve, pp.PolyCurve>(
                             (rhc) => {
                List <pp.Curve> curves = new List <pp.Curve>();
                for (int i = 0; i < rhc.SegmentCount; i++)
                {
                    curves.Add(ToPipe <rh.Curve, pp.Curve>(rhc.SegmentCurve(i)));
                }
                return(new pp.PolyCurve(curves));
            },
                             (ppc) => {
                var curve = new rh.PolyCurve();
                foreach (var segment in ppc.Segments)
                {
                    curve.Append(FromPipe <rh.Curve, pp.Curve>(segment));
                }
                return(curve);
            }
                             ));
        }
        private Curve CreateSpiral(Plane plane, double r0, double r1, Int32 turns)
        {
            Line l0 = new Line(plane.Origin + r0 * plane.XAxis, plane.Origin + r1 * plane.XAxis);
            Line l1 = new Line(plane.Origin - r0 * plane.XAxis, plane.Origin - r1 * plane.XAxis);

            Point3d[] p0;
            Point3d[] p1;

            l0.ToNurbsCurve().DivideByCount(turns, true, out p0);
            l1.ToNurbsCurve().DivideByCount(turns, true, out p1);

            PolyCurve spiral = new PolyCurve();

            for (int i = 0; i < p0.Length - 1; i++)
            {
                Arc arc0 = new Arc(p0[i], plane.YAxis, p1[i + 1]);
                Arc arc1 = new Arc(p1[i + 1], -plane.YAxis, p0[i + 1]);

                spiral.Append(arc0);
                spiral.Append(arc1);
            }

            return spiral;
        }
Exemple #18
0
        /***************************************************/

        public static void RenderRhinoWires(RHG.PolyCurve polycurve, Rhino.Display.DisplayPipeline pipeline, Color bhColour, int thickness)
        {
            pipeline.DrawCurve(polycurve, bhColour, thickness);
        }
 public IfcCompositeCurve(DatabaseIfc db, PolyCurve pc)
     : this(db, pc, false)
 {
 }
 internal IfcCompositeCurve(DatabaseIfc db, PolyCurve plc, bool twoD)
     : base(db)
 {
     mSegments = new List<int>(plc.SegmentCount);
     IfcCartesianPoint curr = null;
     for (int icounter = 0; icounter < plc.SegmentCount; icounter++)
         mSegments.Add(new IfcCompositeCurveSegment(db, plc.SegmentCurve(icounter), true, IfcTransitionCode.CONTINUOUS, twoD, curr, out curr).mIndex);
 }
        private void createStripe(int firstVertexIndex, int secondVertexIndex, int thirdVertexIndex)
        {
            Point3d a = bottomCps[firstVertexIndex];
            Point3d A = topCps[firstVertexIndex];

            Point3d aA = 0.5 * (a + A);

            Point3d b = bottomCps[secondVertexIndex];
            Point3d B = topCps[secondVertexIndex];

            Point3d c = bottomCps[thirdVertexIndex];
            Point3d C = topCps[thirdVertexIndex];

            Point3d ab = 0.5 * (a + b);
            Point3d AB = 0.5 * (A + B);

            Point3d ac = 0.5 * (a + c);
            Point3d AC = 0.5 * (A + C);

            Point3d m = 0.33333 * (ab + ac + 0.5 * (b + c));
            Point3d M = 0.33333 * (AB + AC + 0.5 * (B + C));

            Point3d AAB = iTangentScale * A + (1.0 - iTangentScale) * AB;
            Point3d aab = iTangentScale * a + (1.0 - iTangentScale) * ab;

            Point3d AAC = iTangentScale * A + (1.0 - iTangentScale) * AC;
            Point3d aac = iTangentScale * a + (1.0 - iTangentScale) * ac;

            Curve profileCurve1 = Curve.CreateControlPointCurve(new List<Point3d>() { ab, aab, aA, AAB, AB });
            Curve profileCurve2 = Curve.CreateControlPointCurve(new List<Point3d>() { ac, aac, aA, AAC, AC });

            if (iPolySrf)
            {
                PolyCurve polyCurve1 = new PolyCurve();
                polyCurve1.Append(new LineCurve(m, ab));
                polyCurve1.Append(profileCurve1);
                polyCurve1.Append(new LineCurve(AB, M));

                PolyCurve polyCurve2 = new PolyCurve();
                polyCurve2.Append(new LineCurve(m, ac));
                polyCurve2.Append(profileCurve2);
                polyCurve2.Append(new LineCurve(AC, M));

                oTriLoop.Add(
                    Brep.CreateFromLoft(
                       new List<Curve>() { polyCurve1, polyCurve2 },
                       Point3d.Unset, Point3d.Unset,
                       LoftType.Normal,
                       false
                       )[0]
                   );
            }
            else
            {
                profileCurve1 = Curve.JoinCurves(
                    new List<Curve>() { new LineCurve(b, ab), profileCurve1, new LineCurve(AB, B) },
                    documentTolerance,
                    true)[0];

                profileCurve2 = Curve.JoinCurves(
                    new List<Curve>() { new LineCurve(c, ac), profileCurve2, new LineCurve(AC, C) },
                    documentTolerance,
                    true)[0];

                Brep brep = Brep.CreateFromLoft(
                       new List<Curve>() { profileCurve1, profileCurve2 },
                       Point3d.Unset, Point3d.Unset,
                       LoftType.Normal,
                       false
                       )[0];

                // =============================================
                // Trim the brep using planes
                // =============================================

                double offsetAmount = 0.2;
                Vector3d normal;
                Brep[] breps;

                normal = Vector3d.CrossProduct(B - A, C - A);

                Point3d A_ = A + offsetAmount * normal;

                breps = brep.Trim(new Plane(A_, AB, M), documentTolerance);
                if (breps.Length > 0) brep = breps[0];
                else { oTriLoop.Add(brep); return; }

                breps = brep.Trim(new Plane(A_, M, AC), documentTolerance);
                if (breps.Length > 0) brep = breps[0];
                else { oTriLoop.Add(brep); return; }

                normal = Vector3d.CrossProduct(b - a, c - a);

                Point3d a_ = a - offsetAmount * normal;

                breps = brep.Trim(new Plane(a_, m, ab), documentTolerance);
                if (breps.Length > 0) brep = breps[0];
                else { oTriLoop.Add(brep); return; }

                breps = brep.Trim(new Plane(a_, ac, m), documentTolerance);
                if (breps.Length > 0) brep = breps[0];
                else { oTriLoop.Add(brep); return; }

                oTriLoop.Add(brep);
            }
        }
 internal static IfcIndexedPolyCurve Convert(DatabaseIfc db, PolyCurve polycurve, bool twoD)
 {
     double tol = db.Tolerance;
     Curve[] segments = polycurve.Explode();
     PolyCurve pc = new PolyCurve();
     foreach (Curve s in segments)
     {
         if (s.IsLinear(tol))
             pc.Append(new Line(s.PointAtStart, s.PointAtEnd));
         else
         {
             Arc a = Arc.Unset;
             if (s.TryGetArc(out a, tol))
                 pc.Append(a);
             else
                 return null;
         }
     }
     List<IfcSegmentIndexSelect> segs = new List<IfcSegmentIndexSelect>();
     IfcCartesianPointList cpl = null;
     bool closed = pc.PointAtStart.DistanceTo(pc.PointAtEnd) < tol;
     if (twoD)
     {
         Point2d pt = new Point2d(pc.PointAtStart.X, pc.PointAtStart.Y);
         int pcounter = 1;
         List<Point2d> pts = new List<Point2d>();
         pts.Add(pt);
         IfcLineIndex li = null;
         for (int icounter = 0; icounter < pc.SegmentCount; icounter++)
         {
             Curve c = pc.SegmentCurve(icounter);
             if (c.IsLinear(tol) && c.PointAtStart.DistanceTo(c.PointAtEnd) < tol)
                 continue;
             if (c.IsLinear(tol))
             {
                 if (closed && icounter + 1 == segments.Length)
                 {
                     if (li != null)
                         li.mIndices.Add(1);
                     else
                         li = new IfcLineIndex(pcounter, 1);
                 }
                 else
                 {
                     pts.Add(new Point2d(c.PointAtEnd.X, c.PointAtEnd.Y));
                     if (li != null)
                         li.mIndices.Add(++pcounter);
                     else
                         li = new IfcLineIndex(pcounter++, pcounter);
                 }
             }
             else
             {
                 if (li != null)
                 {
                     segs.Add(li);
                     li = null;
                 }
                 Point3d tp = c.PointAt(c.Domain.Mid);
                 pts.Add(new Point2d(tp.X, tp.Y));
                 if (closed && icounter + 1 == segments.Length)
                     segs.Add(new IfcArcIndex(pcounter++, pcounter++, 1));
                 else
                 {
                     pts.Add(new Point2d(c.PointAtEnd.X, c.PointAtEnd.Y));
                     segs.Add(new IfcArcIndex(pcounter++, pcounter++, pcounter));
                 }
             }
         }
         if (li != null)
             segs.Add(li);
         cpl = new IfcCartesianPointList2D(db, pts.ToArray());
     }
     else
     {
         Point3d pt = pc.PointAtStart;
         int pcounter = 1;
         List<Point3d> pts = new List<Point3d>();
         pts.Add(pt);
         List<IfcSegmentIndexSelect> sis = new List<IfcSegmentIndexSelect>(segments.Length);
         IfcLineIndex li = null;
         for (int icounter = 0; icounter < pc.SegmentCount; icounter++)
         {
             Curve c = pc.SegmentCurve(icounter);
             if (c.IsLinear(tol) && c.PointAtStart.DistanceTo(c.PointAtEnd) < tol)
                 continue;
             if (c.IsLinear(tol))
             {
                 if (closed && icounter + 1 == segments.Length)
                 {
                     if (li != null)
                         li.mIndices.Add(0);
                     else
                         li = new IfcLineIndex(pcounter, 0);
                 }
                 else
                 {
                     pts.Add(c.PointAtEnd);
                     if (li != null)
                         li.mIndices.Add(++pcounter);
                     else
                         li = new IfcLineIndex(pcounter++, pcounter);
                 }
             }
             else
             {
                 if (li != null)
                 {
                     segs.Add(li);
                     li = null;
                 }
                 pts.Add(c.PointAt(c.Domain.Mid));
                 if (closed && icounter + 1 == segments.Length)
                     segs.Add(new IfcArcIndex(pcounter++, pcounter, 0));
                 else
                 {
                     pts.Add(c.PointAtEnd);
                     segs.Add(new IfcArcIndex(pcounter++, pcounter++, pcounter));
                 }
             }
         }
         if (li != null)
             segs.Add(li);
         cpl = new IfcCartesianPointList3D(db, pts.ToArray());
     }
     return new IfcIndexedPolyCurve(cpl, segs) { };
 }