private void CreateChair() { CreateBoxNTranslate(10, 10, 50, -30, 40, 0); //front right leg chair CreateBoxNTranslate(10, 10, 50, 20, 40, 0); //front left leg chair CreateBoxNTranslate(10, 10, 120, -30, 90, 0); //back right leg chair CreateBoxNTranslate(10, 10, 120, 20, 90, 0); //back left leg chair CreateBoxNTranslate(70, 5, 20, -35, 90, 120); // chair top string ChairTopSlabName = "ChairTopSlab"; Block b = new Block(); double width = 70; double depth = 5; double dimA = 1000; double dimB = 800; Point2D[] outerPoints = new Point2D[7]; outerPoints[0] = new Point2D(0, dimB); outerPoints[1] = new Point2D(dimA, dimB); outerPoints[2] = new Point2D(dimA, 0); outerPoints[3] = new Point2D(width, 0); outerPoints[4] = new Point2D(width, depth); outerPoints[5] = new Point2D(0, depth); outerPoints[6] = (Point2D) outerPoints[0].Clone(); LinearPath outer = new LinearPath(Plane.XY, outerPoints); Point2D[] innerPoints = new Point2D[5]; innerPoints[0] = new Point2D(-30, 0); innerPoints[1] = new Point2D(-30, 60); innerPoints[2] = new Point2D(30, 60); innerPoints[3] = new Point2D(30, 0); innerPoints[4] = (Point2D)innerPoints[0].Clone(); LinearPath inner = new LinearPath(Plane.XY, innerPoints); devDept.Eyeshot.Entities.Region reg = new devDept.Eyeshot.Entities.Region(outer, inner); Mesh m2 = reg.ExtrudeAsMesh(10, 0.1, Mesh.natureType.Plain); m2.ColorMethod = colorMethodType.byEntity; m2.Color = Color.White; m2.MaterialName = ChairTopSlabName; b.Entities.Add(m2); viewportLayout1.Blocks.Add("ChairTopSlab", b); BlockReference reference = new BlockReference(0, 40, 60, "ChairTopSlab", 1, 1, 1, 0); viewportLayout1.Entities.Add(reference, 0); }
private void CreateArrowsDirections() { // removes previous arrows if present if (tempArrows != null) { model1.TempEntities.Remove(tempArrows[0]); model1.TempEntities.Remove(tempArrows[1]); model1.TempEntities.Remove(tempArrows[2]); model1.TempEntities.Remove(tempArrows[3]); } //creates 4 temporary arrows on the current moving plane to display when the mouse is over an entity tempArrows = new Mesh[4]; devDept.Eyeshot.Entities.Region arrowShape = new devDept.Eyeshot.Entities.Region(new LinearPath(xyzPlane, new Point2D[] { new Point2D(0, -2), new Point2D(4, -2), new Point2D(4, -4), new Point2D(10, 0), new Point2D(4, 4), new Point2D(4, 2), new Point2D(0, 2), new Point2D(0, -2), }), xyzPlane); //right arrow tempArrows[0] = arrowShape.ExtrudeAsMesh(2, 0.1, Mesh.natureType.Plain); tempArrows[0].Regen(0.1); tempArrows[0].Color = Color.FromArgb(100, Color.Red); //top arrow tempArrows[1] = (Mesh)tempArrows[0].Clone(); tempArrows[1].Rotate(Math.PI / 2, xyzPlane.AxisZ); tempArrows[1].Regen(0.1); //left arrow tempArrows[2] = (Mesh)tempArrows[0].Clone(); tempArrows[2].Rotate(Math.PI, xyzPlane.AxisZ); tempArrows[2].Regen(0.1); //bottom arrow tempArrows[3] = (Mesh)tempArrows[0].Clone(); tempArrows[3].Rotate(-Math.PI / 2, xyzPlane.AxisZ); tempArrows[3].Regen(0.1); Vector3D diagonalV = new Vector3D(tempArrows[0].BoxMin, tempArrows[0].BoxMax); double offset = Math.Max(Vector3D.Dot(diagonalV, xyzPlane.AxisX), Vector3D.Dot(diagonalV, xyzPlane.AxisY)); Vector3D translateX = xyzPlane.AxisX * offset / 2; Vector3D translateY = xyzPlane.AxisY * offset / 2; tempArrows[0].Translate(translateX); tempArrows[1].Translate(translateY); tempArrows[2].Translate(-1 * translateX); tempArrows[3].Translate(-1 * translateY); centerOfArrows = Point3D.Origin; }
public void CreateExtrudeMesh(Model model1) { Shapes shapes = new Shapes(); // Curve로 Region 생성 Region region = new Region(shapes.RoundRectangle()); Mesh mesh = region.ExtrudeAsMesh(new Vector3D(0, 0, 50), 0.001, Mesh.natureType.Plain); mesh.Color = Color.Aquamarine; mesh.ColorMethod = colorMethodType.byEntity; model1.Entities.Add(mesh); model1.Invalidate(); }
public static void CreateHybridEntity(Model vp) { double width = 0.5; Point3D[] profilePoints = new Point3D[] { new Point3D(-5, 0, 0), new Point3D(5, 0, 0), new Point3D(5, 0.5, 0), new Point3D(width, width, 0), new Point3D(width, 10 - width, 0), new Point3D(5, 10 - width, 0), new Point3D(5, 10, 0), new Point3D(-5, 10, 0), new Point3D(-5, 10 - width, 0), new Point3D(-width, 10 - width, 0), new Point3D(-width, width, 0), new Point3D(-5, width, 0), new Point3D(-5, 0, 0) }; LinearPath profileLp = new LinearPath(profilePoints); Region profile = new Region(profileLp); double length1 = 80; MyHybridMesh m = profile.ExtrudeAsMesh <MyHybridMesh>(new Vector3D(0, 0, length1), 0.1, Mesh.natureType.Plain); m.Rotate(Math.PI / 2, Vector3D.AxisZ); m.Translate(5, 0, 0); m.wireVertices = BuildWire(length1).ToArray(); vp.Entities.Add(m, Color.Red); MyHybridMesh m2 = (MyHybridMesh)m.Clone(); m2.Rotate(Math.PI, Vector3D.AxisZ); m2.Translate(60, 0, 0); vp.Entities.Add(m2, Color.Red); double length2 = 60; MyHybridMesh m3 = profile.ExtrudeAsMesh <MyHybridMesh>(new Vector3D(0, 0, length2), 0.1, Mesh.natureType.Plain); m3.Rotate(Math.PI / 2, Vector3D.AxisZ); m3.Translate(5, 0, 0); m3.wireVertices = BuildWire(length2).ToArray(); m3.Rotate(Math.PI / 2, Vector3D.AxisY); m3.Translate(0, 0, length1); vp.Entities.Add(m3, Color.Green); }
private Mesh BuildMeshWithTexture() { Material mat = new Material("Marble", new Bitmap("../../../../../../dataset/Assets/Textures/Maple.jpg")); model1.Materials.Add(mat); const double tol = 0.01; // chordal error const double radius = 0.4; // holes radius // Plate with holes ICurve profile = new CompositeCurve(new Line(0, 0, 8, 0), new Arc(new Point3D(8, 2, 0), 2, 6 * Math.PI / 4, 2 * Math.PI), new Line(10, 2, 10, 6), new Line(10, 6, 0, 6), new Line(0, 6, 0, 0)); ICurve[] holes = new ICurve[20]; int count = 0; for (int y = 0; y < 4; y++) { for (int x = 0; x < 5; x++) { holes[count] = new Circle(new Point3D(1 + x * 1, 1 + y * 1, 0), radius); holes[count].Reverse(); // holes have wrong orientation, we must reverse them count++; } } List <ICurve> contours = new List <ICurve>() { profile }; contours.AddRange(holes); devDept.Eyeshot.Entities.Region region = new devDept.Eyeshot.Entities.Region(contours, Plane.XY, false); Mesh plate = region.ExtrudeAsMesh(new Vector3D(0, 0, 0.25), tol, Mesh.natureType.RichSmooth); plate.FlipNormal(); plate.NormalAveragingMode = Mesh.normalAveragingType.AveragedByAngle; plate.ApplyMaterial(mat.Name, textureMappingType.Cubic, 1, 1); plate.Translate(10, 0, 0); return(plate); }
protected override void OnContentRendered(EventArgs e) { model1.AutoHideLabels = true; model1.GetGrid().AutoSize = true; model1.GetGrid().Step = 100; string concreteMatName = "Concrete"; string steelMatName = "Blue steel"; model1.Materials.Add(new Material(concreteMatName, System.Drawing.Color.FromArgb(25, 25, 25), System.Drawing.Color.LightGray, System.Drawing.Color.FromArgb(31, 31, 31), .05f, 0)); model1.Materials.Add(new Material(steelMatName, System.Drawing.Color.RoyalBlue)); // square column block Block b = new Block("squareCol"); // creates a gray box Mesh m1 = Mesh.CreateBox(30, 30, 270); m1.ColorMethod = colorMethodType.byEntity; m1.Color = System.Drawing.Color.Gray; m1.MaterialName = concreteMatName; // adds it to the block b.Entities.Add(m1); // creates a new black polyline LinearPath steel = new LinearPath(); steel.Vertices = new Point3D[8]; steel.Vertices[0] = new Point3D(4, 4, -20); steel.Vertices[1] = new Point3D(4, 4, 290); steel.Vertices[2] = new Point3D(4, 26, 290); steel.Vertices[3] = new Point3D(4, 26, -20); steel.Vertices[4] = new Point3D(26, 26, -20); steel.Vertices[5] = new Point3D(26, 26, 290); steel.Vertices[6] = new Point3D(26, 4, 290); steel.Vertices[7] = new Point3D(26, 4, -20); steel.ColorMethod = colorMethodType.byEntity; steel.Color = System.Drawing.Color.Black; // adds it to the block b.Entities.Add(steel); // creates a price tag devDept.Eyeshot.Entities.Attribute at = new devDept.Eyeshot.Entities.Attribute(new Point3D(0, -15), "Price", "$25,000", 10); // adds it to the block b.Entities.Add(at); // adds the block to the master block dictionary model1.Blocks.Add(b); // inserts the "SquareCol" block many times: this is a HUGE memory and graphic resources saving for big models BlockReference reference; for (int k = 0; k < 4; k++) { for (int j = 0; j < 5; j++) { for (int i = 0; i < 5; i++) { if (i < 2 && j < 2) { System.Diagnostics.Debug.WriteLine("No columns here"); } else { reference = new BlockReference(i * 500, j * 400, k * 300, "squareCol", 1, 1, 1, 0); // defines a different price for each one reference.Attributes.Add("Price", "$" + i + ",000"); model1.Entities.Add(reference); } } } } // again as above b = new Block("floor"); double width = 2030; double depth = 1630; double dimA = 1000; double dimB = 800; Point2D[] outerPoints = new Point2D[7]; outerPoints[0] = new Point2D(0, dimB); outerPoints[1] = new Point2D(dimA, dimB); outerPoints[2] = new Point2D(dimA, 0); outerPoints[3] = new Point2D(width, 0); outerPoints[4] = new Point2D(width, depth); outerPoints[5] = new Point2D(0, depth); outerPoints[6] = (Point2D)outerPoints[0].Clone(); LinearPath outer = new LinearPath(Plane.XY, outerPoints); Point2D[] innerPoints = new Point2D[5]; innerPoints[0] = new Point2D(1530, 800); innerPoints[1] = new Point2D(1530, 950); innerPoints[2] = new Point2D(1650, 950); innerPoints[3] = new Point2D(1650, 800); innerPoints[4] = (Point2D)innerPoints[0].Clone(); LinearPath inner = new LinearPath(Plane.XY, innerPoints); devDept.Eyeshot.Entities.Region reg = new devDept.Eyeshot.Entities.Region(outer, inner); Mesh m2 = reg.ExtrudeAsMesh(30, 0.1, Mesh.natureType.Plain); m2.ColorMethod = colorMethodType.byEntity; m2.Color = System.Drawing.Color.White; m2.MaterialName = concreteMatName; b.Entities.Add(m2); model1.Blocks.Add(b); for (int i = 0; i < 4; i++) { reference = new BlockReference(0, 0, 270 + i * 300, "floor", 1, 1, 1, 0); model1.Entities.Add(reference); } string brickMatName = "Wall bricks"; model1.Materials.Add(new Material(brickMatName, new Bitmap("../../../../../../dataset/Assets/Textures/Bricks.jpg"))); b = new Block("brickWall"); Mesh rm = Mesh.CreateBox(470, 30, 270, Mesh.natureType.RichPlain); rm.ApplyMaterial(brickMatName, textureMappingType.Cubic, 1.5, 1.5); rm.ColorMethod = colorMethodType.byEntity; rm.Color = System.Drawing.Color.Chocolate; b.Entities.Add(rm); model1.Blocks.Add(b); for (int j = 1; j < 4; j++) { for (int i = 0; i < 2; i++) { reference = new BlockReference(1030 + i * 500, 0, j * 300, "brickWall", 1, 1, 1, 0); model1.Entities.Add(reference); } } // Cylindrical column b = new Block("CylindricalCol"); Mesh m3 = Mesh.CreateCylinder(20, 270, 32, Mesh.natureType.Smooth); m3.ColorMethod = colorMethodType.byEntity; m3.Color = System.Drawing.Color.RoyalBlue; m3.MaterialName = steelMatName; b.Entities.Add(m3); model1.Blocks.Add(b); for (int j = 0; j < 2; j++) { for (int i = 0; i < 3; i++) { reference = new BlockReference(100 + i * 400, 115 + j * 200, 0, "CylindricalCol", 1, 1, 1, 0); model1.Entities.Add(reference); } } // Roof (not a block this time) Mesh roof = Mesh.CreateBox(880, 280, 30); // Edits vertices to add a slope roof.Vertices[4].Z = 15; roof.Vertices[7].Z = 15; roof.Translate(60, 75, 270); model1.Entities.Add(roof, System.Drawing.Color.DimGray); // Labels LeaderAndText lat = new LeaderAndText(new Point3D(0, 800, 1200), "Height = 12 m", new System.Drawing.Font("Tahoma", 8.25f), System.Drawing.Color.White, new Vector2D(0, 20)); lat.FillColor = System.Drawing.Color.Black; model1.Labels.Add(lat); LeaderAndText ff; ff = new LeaderAndText(new Point3D(1000, 1000, 300), "First floor", new System.Drawing.Font("Tahoma", 8.25f), System.Drawing.Color.White, new Vector2D(0, 10)); ff.FillColor = System.Drawing.Color.Red; ff.Alignment = System.Drawing.ContentAlignment.BottomCenter; model1.Labels.Add(ff); // fits the model in the viewport model1.ZoomFit(); // refresh the viewport model1.Invalidate(); base.OnContentRendered(e); }
public Block CreateRocketBlock() { Block rocketBlock = new Block("Rocket"); // missile bottom LinearPath lpMissileBottom = new LinearPath( new Point3D(0, 0, 1), new Point3D(1.5, 0, 1), new Point3D(1.5, 0, 1.5), new Point3D(0, 0, 1.5), new Point3D(0, 0, 1)); Mesh missileBottom = lpMissileBottom.RevolveAsMesh(0, 2 * Math.PI, new Vector3D(0, 0, 1), new Point3D(0, 0, 1), 20, 0.1, Mesh.natureType.Smooth); missileBottom.ColorMethod = colorMethodType.byEntity; missileBottom.Color = Color.Red; missileBottom.Weld(); rocketBlock.Entities.Add(missileBottom); // missile body LinearPath lpMissileBody = new LinearPath( new Point3D(0, 0, 1.5), new Point3D(1.5, 0, 1.5), new Point3D(1.95, 0, 3.5), new Point3D(2.15, 0, 4.25), new Point3D(2.25, 0, 5.75), new Point3D(2.25, 0, 7.25), new Point3D(2.15, 0, 8.75), new Point3D(1.95, 0, 10.25), new Point3D(1.75, 0, 11), new Point3D(1.15, 0, 13), new Point3D(0, 0, 13), new Point3D(0, 0, 0) ); Mesh missileBody = lpMissileBody.RevolveAsMesh(0, 2 * Math.PI, new Vector3D(0, 0, 1), new Point3D(0, 0, 1.5), 20, 0.1, Mesh.natureType.Smooth); missileBody.ColorMethod = colorMethodType.byEntity; missileBody.Color = Color.White; missileBody.Weld(); rocketBlock.Entities.Add(missileBody); // missile edge LinearPath lpMissileEdge = new LinearPath( new Point3D(0, 0, 13), new Point3D(1.15, 0, 13), new Point3D(0.85, 0, 13.5), new Point3D(0.65, 0, 13.75), new Point3D(0.45, 0, 13.85), new Point3D(0.25, 0, 13.92), new Point3D(0.05, 0, 13.992), new Point3D(0, 0, 14), new Point3D(0, 0, 14) ); Mesh missileEdge = lpMissileEdge.RevolveAsMesh(0, 2 * Math.PI, new Vector3D(0, 0, 1), new Point3D(0, 0, 11), 50, 0.1, Mesh.natureType.Smooth); missileEdge.ColorMethod = colorMethodType.byEntity; missileEdge.Color = Color.Red; missileEdge.Weld(); rocketBlock.Entities.Add(missileEdge); // missile wings LinearPath lpMissileWing = new LinearPath( new Point3D(2.15, 0, 4.25), new Point3D(4, 0, 2), new Point3D(4, 0, 0), new Point3D(1.5, 0, 1.5), new Point3D(1.95, 0, 3.5), new Point3D(2.15, 0, 4.25) ); devDept.Eyeshot.Entities.Region regionWing = new devDept.Eyeshot.Entities.Region(lpMissileWing, Plane.XZ); Mesh missileWing1 = regionWing.ExtrudeAsMesh(0.15, 0.1, Mesh.natureType.Plain); missileWing1.ColorMethod = colorMethodType.byEntity; missileWing1.Color = Color.Red; missileWing1.Weld(); rocketBlock.Entities.Add(missileWing1); Mesh missileWing2 = (Mesh)missileWing1.Clone(); missileWing2.Rotate(Math.PI / 2, Vector3D.AxisZ); rocketBlock.Entities.Add(missileWing2); Mesh missileWing3 = (Mesh)missileWing2.Clone(); missileWing3.Rotate(Math.PI / 2, Vector3D.AxisZ); rocketBlock.Entities.Add(missileWing3); Mesh missileWing4 = (Mesh)missileWing3.Clone(); missileWing4.Rotate(Math.PI / 2, Vector3D.AxisZ); rocketBlock.Entities.Add(missileWing4); return(rocketBlock); }
protected void CreateElements() { // setting scene for saving System.Windows.Media.Brush oldColor = model1.GetBackground().TopColor; model1.Backface.ColorMethod = backfaceColorMethodType.SingleColor; model1.GetBackground().TopColor = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.White); model1.Viewports[0].GetToolBar().Visible = false; model1.GetCoordinateSystemIcon().Visible = false; model1.GetOriginSymbol().Visible = false; model1.GetViewCubeIcon().Visible = false; model1.GetGrid().Visible = false; model1.Flat.EdgeThickness = 10; model1.Flat.SilhouetteThickness = 10; model1.DisplayMode = displayType.Flat; model1.Flat.ColorMethod = flatColorMethodType.EntityMaterial; // sets trimetric view model1.SetView(viewType.Trimetric); // creates the directory to save material elements if (!Directory.Exists(dirName)) { Directory.CreateDirectory(dirName); } else { // deletes all previous files foreach (string filePath in Directory.GetFiles(dirName)) { File.Delete(filePath); } } Entity[] list = new Entity[4]; // initialiazes the plane Plane p = new Plane(); // sets the colors and material of objects Material m = new Material("wood", new Bitmap("../../../../../../dataset/Assets/Textures/Maple.jpg")); model1.Materials.Add(m); Color[] colors = new Color [] { Color.Gray, Color.FromArgb(255, 0xF9, 0x88, 0x66), Color.FromArgb(255, 0xFF, 0x42, 0x0E), Color.FromArgb(255, 0x80, 0xBD, 0x9E), Color.FromArgb(255, 0x89, 0xDA, 0x59) }; // a set of objects #if NURBS // slot devDept.Eyeshot.Entities.Region slot = devDept.Eyeshot.Entities.Region.CreateRoundedRectangle(60, 20, 5, true); devDept.Eyeshot.Entities.Region circle = devDept.Eyeshot.Entities.Region.CreateCircle(3.6); slot = devDept.Eyeshot.Entities.Region.Difference(slot, circle)[0]; circle.Translate(-20, 0, 0); slot = devDept.Eyeshot.Entities.Region.Difference(slot, circle)[0]; circle.Translate(40, 0, 0); slot = devDept.Eyeshot.Entities.Region.Difference(slot, circle)[0]; Brep slotMesh = slot.ExtrudeAsBrep(Vector3D.AxisZ * 5); slotMesh.Rotate(Math.PI / 2, Vector3D.AxisZ); slotMesh.Color = colors[0]; slotMesh.MaterialName = "wood"; slotMesh.ColorMethod = colorMethodType.byEntity; // triangle LinearPath trianglePath = new LinearPath(Point3D.Origin, new Point3D(36, 0, 0), new Point3D(18, 0, 25), Point3D.Origin); devDept.Eyeshot.Entities.Region triangleRegion2 = new devDept.Eyeshot.Entities.Region(trianglePath); Brep triangleMesh = triangleRegion2.ExtrudeAsBrep(Vector3D.AxisY * 5); triangleMesh.Color = colors[1]; triangleMesh.ColorMethod = colorMethodType.byEntity; triangleMesh.Rotate(Utility.DegToRad(90), Vector3D.AxisZ); triangleMesh.Translate(52, -3, 0); // weels Brep weelAxisMesh = Brep.CreateCylinder(3, 65); weelAxisMesh.MaterialName = "wood"; weelAxisMesh.Rotate(Math.PI / 2, Vector3D.AxisY); weelAxisMesh.Color = colors[2]; weelAxisMesh.ColorMethod = colorMethodType.byEntity; devDept.Eyeshot.Entities.Region outer = devDept.Eyeshot.Entities.Region.CreateCircle(Plane.YZ, 12); devDept.Eyeshot.Entities.Region inner = devDept.Eyeshot.Entities.Region.CreateCircle(Plane.YZ, 3); devDept.Eyeshot.Entities.Region weel = devDept.Eyeshot.Entities.Region.Difference(outer, inner)[0]; Brep weelRMesh = weel.ExtrudeAsBrep(10); weelRMesh.Translate(55, 0, 0); weelRMesh.Color = colors[2]; weelRMesh.ColorMethod = colorMethodType.byEntity; Brep weelLMesh = weel.ExtrudeAsBrep(-10); weelLMesh.Translate(10, 0, 0); weelLMesh.Color = colors[2]; weelLMesh.ColorMethod = colorMethodType.byEntity; // cylinder Brep cylMesh = Brep.CreateCylinder(3.5, 40); cylMesh.Color = colors[3]; cylMesh.ColorMethod = colorMethodType.byEntity; //box Brep baseMesh = Brep.CreateBox(40, 40, 5); baseMesh.Color = colors[4]; baseMesh.ColorMethod = colorMethodType.byEntity; #else // slot devDept.Eyeshot.Entities.Region slot = devDept.Eyeshot.Entities.Region.CreateRoundedRectangle(60, 20, 5, true); devDept.Eyeshot.Entities.Region circle = devDept.Eyeshot.Entities.Region.CreateCircle(3.6); slot = devDept.Eyeshot.Entities.Region.Difference(slot, circle)[0]; circle.Translate(-20, 0, 0); slot = devDept.Eyeshot.Entities.Region.Difference(slot, circle)[0]; circle.Translate(40, 0, 0); slot = devDept.Eyeshot.Entities.Region.Difference(slot, circle)[0]; Mesh slotMesh = slot.ExtrudeAsMesh(Vector3D.AxisZ * 5, 0.01, Mesh.natureType.RichSmooth); slotMesh.Rotate(Math.PI / 2, Vector3D.AxisZ); slotMesh.Color = colors[0]; slotMesh.ApplyMaterial("wood", textureMappingType.Cubic, 2, 2); slotMesh.ColorMethod = colorMethodType.byEntity; // triangle LinearPath trianglePath = new LinearPath(Point3D.Origin, new Point3D(36, 0, 0), new Point3D(18, 0, 25), Point3D.Origin); devDept.Eyeshot.Entities.Region triangleRegion2 = new devDept.Eyeshot.Entities.Region(trianglePath); Mesh triangleMesh = triangleRegion2.ExtrudeAsMesh(Vector3D.AxisY * 5, 0.01, Mesh.natureType.RichSmooth); triangleMesh.Color = colors[1]; triangleMesh.ColorMethod = colorMethodType.byEntity; triangleMesh.Rotate(Utility.DegToRad(90), Vector3D.AxisZ); triangleMesh.Translate(52, -3, 0); // weels Mesh weelAxisMesh = Mesh.CreateCylinder(3, 65, 50, Mesh.natureType.RichSmooth); weelAxisMesh.ApplyMaterial("wood", textureMappingType.Cylindrical, 2, 2); weelAxisMesh.Rotate(Math.PI / 2, Vector3D.AxisY); weelAxisMesh.Color = colors[2]; weelAxisMesh.ColorMethod = colorMethodType.byEntity; devDept.Eyeshot.Entities.Region outer = devDept.Eyeshot.Entities.Region.CreateCircle(Plane.YZ, 12); devDept.Eyeshot.Entities.Region inner = devDept.Eyeshot.Entities.Region.CreateCircle(Plane.YZ, 3); devDept.Eyeshot.Entities.Region weel = devDept.Eyeshot.Entities.Region.Difference(outer, inner)[0]; Mesh weelRMesh = weel.ExtrudeAsMesh(10, 0.01, Mesh.natureType.RichSmooth); weelRMesh.Translate(55, 0, 0); weelRMesh.Color = colors[2]; weelRMesh.ColorMethod = colorMethodType.byEntity; Mesh weelLMesh = weel.ExtrudeAsMesh(-10, 0.01, Mesh.natureType.RichSmooth); weelLMesh.Translate(10, 0, 0); weelLMesh.Color = colors[2]; weelLMesh.ColorMethod = colorMethodType.byEntity; // cylinder Mesh cylMesh = Mesh.CreateCylinder(3.5, 40, 50); cylMesh.Color = colors[3]; cylMesh.ColorMethod = colorMethodType.byEntity; //box Mesh baseMesh = Mesh.CreateBox(40, 40, 5); baseMesh.Color = colors[4]; baseMesh.ColorMethod = colorMethodType.byEntity; #endif // blocks containing the geometry Block baseBlock = new Block("Box"); baseBlock.Entities.Add(baseMesh); Block redTriangleBlock = new Block("Slot"); redTriangleBlock.Entities.Add(slotMesh); Block yellowTriangleBlock = new Block("Triangle"); yellowTriangleBlock.Entities.Add(triangleMesh); Block greenBlock = new Block("Cylinder"); greenBlock.Entities.Add(cylMesh); Block weelsBlock = new Block("weels"); weelsBlock.Entities.Add(weelAxisMesh); weelsBlock.Entities.Add(weelRMesh); weelsBlock.Entities.Add(weelLMesh); model1.Blocks.Add(baseBlock); model1.Blocks.Add(redTriangleBlock); model1.Blocks.Add(yellowTriangleBlock); model1.Blocks.Add(greenBlock); model1.Blocks.Add(weelsBlock); // saves entities elements foreach (Block b in model1.Blocks) { // deletes previous entities model1.Entities.Clear(); // adds the entity to the viewport BlockReference reference = new BlockReference(b.Name); model1.Entities.Add(reference); // fits the model in the viewport model1.ZoomFit(); // save image Bitmap materialSphere = model1.RenderToBitmap(1); materialSphere.Save(dirName + "\\" + b.Name + ".bmp"); } // fills ListView with saved images this.listView1.ItemsSource = Fill_listView; // restores scene model1.Backface.ColorMethod = backfaceColorMethodType.EntityColor; model1.GetBackground().TopColor = oldColor; model1.Viewports[0].GetToolBar().Visible = true; model1.GetCoordinateSystemIcon().Visible = true; model1.GetOriginSymbol().Visible = true; model1.GetViewCubeIcon().Visible = true; model1.GetGrid().Visible = true; model1.Flat.EdgeThickness = 1; model1.Flat.SilhouetteThickness = 2; model1.DisplayMode = displayType.Rendered; }
private void RebuildChair() { string currentMatName = (currentFrameMaterial == materialEnum.Cherry) ? cherryMatName : mapleMatName; model1.Entities.Clear(); model1.Labels.Clear(); double legDepth = 3; double legWidth = 3; double legHeight = 56.5; double seatDepth = 29; double seatWidth = sizeTrackBar.Value; double seatHeight = 1.6; double seatY = 27.4; // // Build the legs // Mesh leg1 = MakeBox(legWidth, legDepth, legHeight); Mesh leg4 = (Mesh)leg1.Clone(); Mesh leg2 = MakeBox(legWidth, legDepth, seatY); Mesh leg3 = (Mesh)leg2.Clone(); leg2.Translate(seatDepth - legDepth, 0, 0); leg3.Translate(seatDepth - legDepth, seatWidth - legWidth, 0); leg4.Translate(0, seatWidth - legWidth, 0); AddEntityWithMaterial(ref leg1, currentMatName); AddEntityWithMaterial(ref leg2, currentMatName); AddEntityWithMaterial(ref leg3, currentMatName); AddEntityWithMaterial(ref leg4, currentMatName); // // Build the seat // double dx = 0.3; double dy = 0.2; double delta = 0.1; double seatPartDepth = 4.5; double seatPartOffset = 0.5; Point3D[] seatFirstPartPoints = { new Point3D(legDepth + delta, 0, 0), new Point3D(seatPartDepth, 0, 0), new Point3D(seatPartDepth, seatWidth, 0), new Point3D(legDepth + delta, seatWidth, 0), new Point3D(legDepth + delta, seatWidth - legWidth + dy, 0), new Point3D(-dx, seatWidth - legWidth, 0), new Point3D(-dx, legWidth, 0), new Point3D(legDepth + delta, legWidth + dy, 0), new Point3D(legDepth + delta, 0, 0) }; Region seatFirstPart = new Region(new LinearPath(seatFirstPartPoints)); Mesh seatPart0 = seatFirstPart.ExtrudeAsMesh(new Vector3D(0, 0, seatHeight), 0.01, Mesh.natureType.Smooth); seatPart0.Translate(0, -dy, seatY); Mesh seatPart1 = MakeBox(seatWidth + 2 * dx, seatPartDepth, seatHeight); seatPart1.Translate(seatPartDepth + seatPartOffset, -dy, seatY); Mesh seatPart2 = (Mesh)seatPart1.Clone(); seatPart2.Translate(seatPartDepth + seatPartOffset, 0, 0); Mesh seatPart3 = (Mesh)seatPart2.Clone(); seatPart3.Translate(seatPartDepth + seatPartOffset, 0, 0); Mesh seatPart4 = (Mesh)seatPart3.Clone(); seatPart4.Translate(seatPartDepth + seatPartOffset, 0, 0); Mesh seatPart5 = (Mesh)seatPart4.Clone(); seatPart5.Translate(seatPartDepth + seatPartOffset, 0, 0); model1.Entities.Add(seatPart0, plasticMatName); model1.Entities.Add(seatPart1, plasticMatName); model1.Entities.Add(seatPart2, plasticMatName); model1.Entities.Add(seatPart3, plasticMatName); model1.Entities.Add(seatPart4, plasticMatName); model1.Entities.Add(seatPart5, plasticMatName); // // Build the bars under the seat // double underSeatXBarWidth = legWidth * 0.8; double underSeatXBarDepth = seatDepth - 2 * legDepth; double underSeatXBarHeight = 5.0; double underSeatYBarWidth = seatWidth - 2 * legWidth; double underSeatYBarDepth = legDepth * 0.8; double underSeatYBarHeight = underSeatXBarHeight; Mesh barUnderSeatLeft = MakeBox(underSeatXBarWidth, underSeatXBarDepth, underSeatXBarHeight); barUnderSeatLeft.Translate(legDepth, (legWidth - underSeatXBarWidth) / 2, seatY - underSeatXBarHeight); Mesh barUnderSeatRight = (Mesh)barUnderSeatLeft.Clone(); barUnderSeatRight.Translate(0, seatWidth - legWidth, 0); Mesh barUnderSeatBack = MakeBox(seatWidth - 2 * legWidth, legDepth * 0.8, underSeatYBarHeight); barUnderSeatBack.Translate((legDepth - underSeatYBarDepth) / 2, legWidth, seatY - underSeatYBarHeight); Mesh barUnderSeatFront = (Mesh)barUnderSeatBack.Clone(); barUnderSeatFront.Translate(seatDepth - legDepth, 0, 0); AddEntityWithMaterial(ref barUnderSeatLeft, currentMatName); AddEntityWithMaterial(ref barUnderSeatRight, currentMatName); AddEntityWithMaterial(ref barUnderSeatFront, currentMatName); AddEntityWithMaterial(ref barUnderSeatBack, currentMatName); // // Build the two cylinders on the sides // double CylinderRadius = legWidth / 3; double cylinderY = 14.5; Mesh leftCylinder = MakeCylinder(CylinderRadius, seatDepth - 2 * legDepth, 16); leftCylinder.ApplyMaterial(currentMatName, textureMappingType.Cylindrical, .25, 1); leftCylinder.Rotate(Math.PI / 2, new Vector3D(0, 1, 0)); leftCylinder.Translate(legDepth, legWidth / 2, cylinderY); model1.Entities.Add(leftCylinder); Mesh rightCylinder = (Mesh)leftCylinder.Clone(); rightCylinder.Translate(0, seatWidth - legWidth, 0); model1.Entities.Add(rightCylinder); // // Build the chair back // double chairBackHorizHeight = 4; double chairBackHorizDepth = 2; double horizHeight1 = seatY + seatHeight + 7; Mesh chairBackHorizontal1 = MakeBox(seatWidth - 2 * legWidth, chairBackHorizDepth, chairBackHorizHeight); chairBackHorizontal1.Translate((legDepth - chairBackHorizDepth) / 2.0, legWidth, horizHeight1); double cylinderHeight = 12; double horizHeight2 = cylinderHeight + chairBackHorizHeight; Mesh chairBackHorizontal2 = (Mesh)chairBackHorizontal1.Clone(); chairBackHorizontal2.Translate(0, 0, horizHeight2); AddEntityWithMaterial(ref chairBackHorizontal1, currentMatName); AddEntityWithMaterial(ref chairBackHorizontal2, currentMatName); double chairBackCylinderRadius = chairBackHorizDepth / 4.0; double chairBackCylinderHeight = horizHeight2 - chairBackHorizHeight; Mesh chairBackCylinder = MakeCylinder(chairBackCylinderRadius, chairBackCylinderHeight, 16); chairBackCylinder.Translate(legDepth / 2.0, legWidth, horizHeight1 + chairBackHorizHeight); double chairBackWidth = seatWidth - 2 * legWidth; double cylinderOffset = 7; int nCylinders = (int)(chairBackWidth / cylinderOffset); double offset = (chairBackWidth - (nCylinders + 1) * cylinderOffset) / 2.0; offset += cylinderOffset; for (int i = 0; i < nCylinders; i++, offset += cylinderOffset) { Mesh cyl = (Mesh)chairBackCylinder.Clone(); cyl.ApplyMaterial(currentMatName, textureMappingType.Cylindrical, .25, 1); cyl.Translate(0, offset, 0); model1.Entities.Add(cyl); } // // Add the linear dimension // Point3D dimCorner = new Point3D(0, 0, legHeight); Plane myPlane = Plane.YZ; myPlane.Origin = dimCorner; LinearDim ad = new LinearDim(myPlane, new Point3D(0, 0, legHeight + 1), new Point3D(0, seatWidth, legHeight + 1), new Point3D(seatDepth + 10, seatWidth / 2, legHeight + 10), 3); ad.TextSuffix = " cm"; model1.Entities.Add(ad); model1.Entities.UpdateBoundingBox(); // // Update extents // widthTextBox.Text = model1.Entities.BoxSize.X.ToString("f2") + " cm"; depthTextBox.Text = model1.Entities.BoxSize.Y.ToString("f2") + " cm"; heightTextBox.Text = model1.Entities.BoxSize.Z.ToString("f2") + " cm"; // // Update weight // double totalWeight = CalcWeight(); weightTextBox.Text = totalWeight.ToString("f2") + " kg"; // // Product ID label // devDept.Eyeshot.Labels.LeaderAndText prodIdLabel = new LeaderAndText(seatDepth / 2, seatWidth, 25, "Product ID goes here", new Font("Tahoma", 8.25f), System.Drawing.Color.Black, new Vector2D(20, 0)); model1.Labels.Add(prodIdLabel); }
private void BuildShapesAndTransformations() { inners = new LinearPath[2]; startOrientation = new Quaternion[2]; finalOrientation = new Quaternion[2]; // Hexagon CompositeCurve c = CompositeCurve.CreateHexagon(5); c.Regen(0); inners[0] = new LinearPath(c.Vertices); inners[0].Reverse(); startOrientation[0] = new Quaternion(Vector3D.AxisZ, 180 / 2.0); Transformation transf = new Translation(7, 0, 0) * new Rotation(Math.PI / 2, Vector3D.AxisZ); inners[0].TransformBy(transf); // Triangle inners[1] = new LinearPath(new Point3D[] { new Point3D(0, 0, 0), new Point3D(7, 0, 0), new Point3D(3.5, 7, 0), new Point3D(0, 0, 0) }); inners[1].Reverse(); transf = new Translation(23, 0, 0) * new Rotation(Math.PI / 3, Vector3D.AxisZ); startOrientation[1] = new Quaternion(Vector3D.AxisZ, 180 / 3.0); inners[1].TransformBy(transf); // Extrude the 2 inner profiles to build 2 shapes shapes = new Entity[2]; devDept.Eyeshot.Entities.Region firstInnerReg = new devDept.Eyeshot.Entities.Region(inners[0], Plane.XY, false); shapes[0] = firstInnerReg.ExtrudeAsMesh(4, 0.1, Mesh.natureType.Plain); shapes[0].ColorMethod = colorMethodType.byEntity; shapes[0].Color = System.Drawing.Color.Green; devDept.Eyeshot.Entities.Region secondInnerReg = new devDept.Eyeshot.Entities.Region(inners[1], Plane.XY, false); shapes[1] = secondInnerReg.ExtrudeAsMesh(4, 0.1, Mesh.natureType.Plain); shapes[1].ColorMethod = colorMethodType.byEntity; shapes[1].Color = System.Drawing.Color.Gainsboro; // Save the original shapes for the animation originalShapes = new Entity[] { (Entity)shapes[0].Clone(), (Mesh)shapes[1].Clone() }; LinearPath outer = new LinearPath(new Point3D[] { new Point3D(0, -10, 0), new Point3D(30, -10, 0), new Point3D(30, 10, 0), new Point3D(0, 10, 0), new Point3D(0, -10, 0) }); devDept.Eyeshot.Entities.Region plate = new devDept.Eyeshot.Entities.Region(new ICurve[] { outer, inners[0], inners[1] }, Plane.XY, false); // Build a mesh with 2 holes Mesh m = plate.ExtrudeAsMesh(3, 0.1, Mesh.natureType.Plain); // Transform the mesh and the the 2 inner profiles, to position them in the exact place of the holes transf = new Translation(0, 3, 10) * new Rotation(Math.PI / 2, Vector3D.AxisX); m.TransformBy(transf); model1.Entities.Add(m, System.Drawing.Color.Brown); inners[0].TransformBy(transf); inners[1].TransformBy(transf); // Rotation quaternion of the 2 inners Quaternion q = new Quaternion(Vector3D.AxisX, 90); finalOrientation[0] = q * startOrientation[0]; finalOrientation[1] = q * startOrientation[1]; // Define a Transformation for the 2 shapes, and store the rotation Quaternion transf = new Translation(20, -25, 0) * new Rotation(Math.PI / 9, Vector3D.AxisZ); startOrientation[0] = new Quaternion(Vector3D.AxisZ, 180 / 9.0) * startOrientation[0]; shapesTransform = new Transformation[2]; shapesTransform[0] = transf; transf = new Translation(-10, -44, 0) * new Rotation(Math.PI / 5, Vector3D.AxisZ); shapesTransform[1] = transf; startOrientation[1] = new Quaternion(Vector3D.AxisZ, 180 / 5.0) * startOrientation[1]; if (comboBoxAnimation.SelectedIndex == 1) { // Block Reference Animation // Add the Blocks to the viewport and create the BlockReferences for the animation AddBlockDefinition(new Block("B1"), 0); AddBlockDefinition(new Block("B2"), 1); } else { // Transform the shapes shapes[0].TransformBy(shapesTransform[0]); shapes[1].TransformBy(shapesTransform[1]); } // Add the entities to the viewport model1.Entities.Add(shapes[0]); model1.Entities.Add(shapes[1]); }
public static Entity getEntityFromIfcRepresentationItem(IfcRepresentationItem reprItem, ViewportLayout viewportLayout1 = null, Transformation entityTrs = null) { Entity result = null; if (reprItem is IfcBooleanClippingResult) { IfcBooleanClippingResult bcr = (IfcBooleanClippingResult)reprItem; result = getSolidFromIfcBooleanClippingResult(bcr); } else if (reprItem is IfcCurve) { result = (Entity)getICurveFromIfcCurve((IfcCurve)reprItem, viewportLayout1, entityTrs); } else if (reprItem is IfcExtrudedAreaSolid) { IfcExtrudedAreaSolid extrAreaSolid = (IfcExtrudedAreaSolid)reprItem; // if (!viewportLayout1.Blocks.ContainsKey(extrAreaSolid.Index.ToString())) { Plane pln = Conversion.getPlaneFromPosition(extrAreaSolid.Position); Align3D align = new Align3D(Plane.XY, pln); IfcDirection dir = extrAreaSolid.ExtrudedDirection; Vector3D extDir = new Vector3D(dir.DirectionRatioX, dir.DirectionRatioY, dir.DirectionRatioZ); //extDir.TransformBy(trs * align2); extDir.TransformBy(align); devDept.Eyeshot.Entities.Region region = getRegionFromIfcProfileDef(extrAreaSolid.SweptArea, viewportLayout1); if (region != null) { //region.TransformBy(trs * align2); region.TransformBy(align); result = region.ExtrudeAsMesh(extDir * extrAreaSolid.Depth, 0.1, Mesh.natureType.Plain); // 0.1 tolerance must be computed according to object size //viewportLayout1.Entities.Add(result, 1); //Block b = new Block(); //b.Entities.Add(m); //viewportLayout1.Blocks.Add(extrAreaSolid.Index.ToString(), b); } } // BlockReference br = new IfcBlockReference(trs, extrAreaSolid.Index.ToString()); // viewportLayout1.Entities.Add(br, 0, Color.Gray); } else if (reprItem is IfcFaceBasedSurfaceModel) { IfcFaceBasedSurfaceModel fbs = (IfcFaceBasedSurfaceModel)reprItem; result = new Mesh(0, 0, Mesh.natureType.Plain); foreach (IfcConnectedFaceSet cfs in fbs.FbsmFaces) { Mesh global = new Mesh(0, 0, Mesh.natureType.Plain); foreach (IfcFace face in cfs.CfsFaces) { Point3D[] outerPoints = null; List <Point3D[]> innerPointsList = new List <Point3D[]>(); foreach (IfcFaceBound fb in face.Bounds) // al massimo 2 ? profilo esterno e interno { // bool sense = ifb.mOrientation; if (fb is IfcFaceOuterBound) { IfcFaceOuterBound ifob = (IfcFaceOuterBound)fb; IfcPolyloop pl = (IfcPolyloop)fb.Bound; List <Point3D> pLIst = new List <Point3D>(); for (int i = 0; i < pl.Polygon.Count; i++) { Point3D p = getPoint3DFromIfcCartesianPoint(pl.Polygon[i]); if (!pLIst.Contains(p)) // non copio punti uguali !! { pLIst.Add(p); } } outerPoints = pLIst.ToArray(); if (!outerPoints[0].Equals(outerPoints[outerPoints.Length - 1])) { Array.Resize(ref outerPoints, outerPoints.Length + 1); outerPoints[outerPoints.Length - 1] = (Point3D)outerPoints[0].Clone(); } Array.Reverse(outerPoints); } else { IfcFaceBound ifb = (IfcFaceBound)fb; IfcPolyloop inPl = (IfcPolyloop)ifb.Bound; List <Point3D> pLIst = new List <Point3D>(); for (int i = 0; i < inPl.Polygon.Count; i++) { Point3D p = getPoint3DFromIfcCartesianPoint(inPl.Polygon[i]); if (!pLIst.Contains(p)) // non copio punti uguali !! { pLIst.Add(p); } } Point3D[] innerPoints = pLIst.ToArray(); if (!innerPoints[0].Equals(innerPoints[innerPoints.Length - 1])) { Array.Resize(ref innerPoints, innerPoints.Length + 1); innerPoints[innerPoints.Length - 1] = (Point3D)innerPoints[0].Clone(); } Array.Reverse(innerPoints); innerPointsList.Add(innerPoints); } } if (outerPoints.Length > 3) { Mesh local; List <LinearPath> boundLp = new List <LinearPath>(); boundLp.Add(new LinearPath(outerPoints)); foreach (Point3D[] innerPoints in innerPointsList) { boundLp.Add(new LinearPath(innerPoints)); } local = new devDept.Eyeshot.Entities.Region(boundLp.ToArray()).ConvertToMesh(0, Mesh.natureType.Plain); global.MergeWith(local, true); // fonde i vertici, sarebbe meglio farla una volta sola alla fine } } ((Mesh)result).MergeWith(global, true); } } else if (reprItem is IfcFacetedBrep) //controllare { IfcFacetedBrep facBrep = (IfcFacetedBrep)reprItem; IfcClosedShell cs = facBrep.Outer; Mesh global = new Mesh(0, 0, Mesh.natureType.Plain); foreach (IfcFace face in cs.CfsFaces) { Point3D[] outerPoints = null; List <Point3D[]> innerPointsList = new List <Point3D[]>(); foreach (IfcFaceBound fb in face.Bounds) { // bool sense = ifb.mOrientation; if (fb is IfcFaceOuterBound) { IfcFaceOuterBound ifob = (IfcFaceOuterBound)fb; IfcPolyloop pl = (IfcPolyloop)fb.Bound; List <Point3D> pLIst = new List <Point3D>(); for (int i = 0; i < pl.Polygon.Count; i++) { Point3D p = getPoint3DFromIfcCartesianPoint(pl.Polygon[i]); if (!pLIst.Contains(p)) // non copio punti uguali !! { pLIst.Add(p); } } outerPoints = pLIst.ToArray(); if (!outerPoints[0].Equals(outerPoints[outerPoints.Length - 1])) { Array.Resize(ref outerPoints, outerPoints.Length + 1); outerPoints[outerPoints.Length - 1] = (Point3D)outerPoints[0].Clone(); } Array.Reverse(outerPoints); } else { IfcFaceBound ifb = (IfcFaceBound)fb; IfcPolyloop inPl = (IfcPolyloop)ifb.Bound; List <Point3D> pLIst = new List <Point3D>(); for (int i = 0; i < inPl.Polygon.Count; i++) { Point3D p = getPoint3DFromIfcCartesianPoint(inPl.Polygon[i]); if (!pLIst.Contains(p)) // non copio punti uguali !! { pLIst.Add(p); } } Point3D[] innerPoints = pLIst.ToArray(); if (!innerPoints[0].Equals(innerPoints[innerPoints.Length - 1])) { Array.Resize(ref innerPoints, innerPoints.Length + 1); innerPoints[innerPoints.Length - 1] = (Point3D)innerPoints[0].Clone(); } Array.Reverse(innerPoints); innerPointsList.Add(innerPoints); } } if (outerPoints.Length > 3) { Mesh local; List <LinearPath> boundLp = new List <LinearPath>(); boundLp.Add(new LinearPath(outerPoints)); foreach (Point3D[] innerPoints in innerPointsList) { boundLp.Add(new LinearPath(innerPoints)); } local = new devDept.Eyeshot.Entities.Region(boundLp.ToArray()).ConvertToMesh(0, Mesh.natureType.Plain); global.MergeWith(local, true); // fonde i vertici, sarebbe meglio farla una volta sola alla fine } } result = global; } //else if (repItem is IfcBoundingBox) //{ // IfcBoundingBox bBox = (IfcBoundingBox)iRep.Items[0]; // m = Mesh.CreateBox(bBox.XDim, bBox.YDim, bBox.ZDim); // m.Translate(bBox.Corner.Coordinates.Item1, bBox.Corner.Coordinates.Item1, bBox.Corner.Coordinates.Item1); //} else if (reprItem is IfcMappedItem) { IfcMappedItem mapItem = (IfcMappedItem)reprItem; if (!viewportLayout1.Blocks.ContainsKey("MappingSource " + mapItem.MappingSource.Index.ToString())) { IfcRepresentationMap reprMapSource = mapItem.MappingSource; Entity mapSource = getEntityFromIfcRepresentation(reprMapSource.MappedRepresentation, viewportLayout1, entityTrs); Block b = new Block(); if (mapSource != null) { Plane pln = getPlaneFromPosition((IfcPlacement)reprMapSource.MappingOrigin); Align3D algn = new Align3D(Plane.XY, pln); mapSource.TransformBy(algn); b.Entities.Add(mapSource); } viewportLayout1.Blocks.Add("MappingSource " + mapItem.MappingSource.Index.ToString(), b); } IfcCartesianTransformationOperator3D iTrs = (IfcCartesianTransformationOperator3D)mapItem.MappingTarget; Point3D org = new Point3D(iTrs.LocalOrigin.Coordinates.Item1, iTrs.LocalOrigin.Coordinates.Item2, iTrs.LocalOrigin.Coordinates.Item3); Vector3D vectorX; if (iTrs.Axis1 != null) { vectorX = new Vector3D(iTrs.Axis1.DirectionRatioX, iTrs.Axis1.DirectionRatioY, iTrs.Axis1.DirectionRatioZ); } else { vectorX = new Vector3D(1, 0, 0); } vectorX = vectorX * iTrs.Scale; Vector3D vectorY; if (iTrs.Axis2 != null) { vectorY = new Vector3D(iTrs.Axis2.DirectionRatioX, iTrs.Axis2.DirectionRatioY, iTrs.Axis2.DirectionRatioZ); } else { vectorY = new Vector3D(0, 1, 0); } Vector3D vectorZ; if (iTrs.Axis1 != null) { vectorZ = new Vector3D(iTrs.Axis3.DirectionRatioX, iTrs.Axis3.DirectionRatioY, iTrs.Axis3.DirectionRatioZ); } else { vectorZ = new Vector3D(0, 0, 1); } if (iTrs is IfcCartesianTransformationOperator3DnonUniform) { IfcCartesianTransformationOperator3DnonUniform nut = (IfcCartesianTransformationOperator3DnonUniform)iTrs; vectorY = vectorY * nut.Scale2; vectorZ = vectorZ * nut.Scale3; } Transformation targetTrs = new Transformation(org, vectorX, vectorY, vectorZ); result = new IfcBlockReference(targetTrs, "MappingSource " + mapItem.MappingSource.Index.ToString()); } else if (reprItem is IfcShellBasedSurfaceModel) { IfcShellBasedSurfaceModel sbs = (IfcShellBasedSurfaceModel)reprItem; result = new Mesh(0, 0, Mesh.natureType.Plain); foreach (IfcShell cfs in sbs.SbsmBoundary) { Mesh global = new Mesh(0, 0, Mesh.natureType.Plain); foreach (IfcFace face in cfs.CfsFaces) { Point3D[] outerPoints = null; List <Point3D[]> innerPointsList = new List <Point3D[]>(); foreach (IfcFaceBound fb in face.Bounds) // al massimo 2 ? profilo esterno e interno { // bool sense = ifb.mOrientation; if (fb is IfcFaceOuterBound) { IfcFaceOuterBound ifob = (IfcFaceOuterBound)fb; IfcPolyloop pl = (IfcPolyloop)fb.Bound; List <Point3D> pLIst = new List <Point3D>(); for (int i = 0; i < pl.Polygon.Count; i++) { Point3D p = getPoint3DFromIfcCartesianPoint(pl.Polygon[i]); if (!pLIst.Contains(p)) // non copio punti uguali !! { pLIst.Add(p); } } outerPoints = pLIst.ToArray(); if (!outerPoints[0].Equals(outerPoints[outerPoints.Length - 1])) { Array.Resize(ref outerPoints, outerPoints.Length + 1); outerPoints[outerPoints.Length - 1] = (Point3D)outerPoints[0].Clone(); } Array.Reverse(outerPoints); } else { IfcFaceBound ifb = (IfcFaceBound)fb; IfcPolyloop inPl = (IfcPolyloop)ifb.Bound; List <Point3D> pLIst = new List <Point3D>(); for (int i = 0; i < inPl.Polygon.Count; i++) { Point3D p = getPoint3DFromIfcCartesianPoint(inPl.Polygon[i]); if (!pLIst.Contains(p)) // non copio punti uguali !! { pLIst.Add(p); } } Point3D[] innerPoints = pLIst.ToArray(); if (!innerPoints[0].Equals(innerPoints[innerPoints.Length - 1])) { Array.Resize(ref innerPoints, innerPoints.Length + 1); innerPoints[innerPoints.Length - 1] = (Point3D)innerPoints[0].Clone(); } Array.Reverse(innerPoints); innerPointsList.Add(innerPoints); } } if (outerPoints.Length > 3) { Mesh local; List <LinearPath> boundLp = new List <LinearPath>(); boundLp.Add(new LinearPath(outerPoints)); foreach (Point3D[] innerPoints in innerPointsList) { boundLp.Add(new LinearPath(innerPoints)); } //devDept.Eyeshot.Entities.Region localRegion = new devDept.Eyeshot.Entities.Region(boundLp.ToArray()); //localRegion.TransformBy(entityTrs); //viewportLayout1.Entities.Add(localRegion, 1); local = new devDept.Eyeshot.Entities.Region(boundLp.ToArray()).ConvertToMesh(0, Mesh.natureType.Plain); global.MergeWith(local, true); // fonde i vertici, sarebbe meglio farla una volta sola alla fine } } ((Mesh)result).MergeWith(global, true); } } else { if (!debug.Contains("IfcRepresentationItem not supported: " + reprItem.KeyWord)) { debug += "IfcRepresentationItem not supported: " + reprItem.KeyWord + "\n"; } } if (result != null) { Color color; if (tryGetColorFromIfcRepresentationItem(reprItem, out color)) { result.ColorMethod = colorMethodType.byEntity; result.Color = color; } else { result.ColorMethod = colorMethodType.byParent; } } return(result); }