ShapeItemInsertUsingNormalsAllowDuplicates Method |
Inserts a shape to the shape catalog using the shape geometry allowing duplicates. Uses
vertex normals to determine edge visibility. If the normal vectors of the vertices belonging
to one geometrical location are close enough, the edge will be considered smooth and will be
marked as hidden.
Namespace: Tekla.Structures.Catalogs
Assembly: Tekla.Structures.Catalogs (in Tekla.Structures.Catalogs.dll) Version: 2024.0.0+a110b435391768740483e3032720a566518c9a63
Syntax
Examples
using System; using Tekla.Structures.Catalogs; public class Example() { /* One edge inside the hole and one on the outer surface of the box will be hidden. */ var vertices = new[] { /* The main cube vertices. Notice that all vertices are triplicated, because each is present on three different faces. Thus we get three different vertex normals for each physical corner too. */ new Vector( 0.0, 0.0, 0.0 ), // 0 new Vector( 500.0, 0.0, 0.0 ), // 1 new Vector( 500.0, 500.0, 0.0 ), // 2 new Vector( 0.0, 500.0, 0.0 ), // 3 new Vector( 0.0, 0.0, 500.0 ), // 4 new Vector( 500.0, 0.0, 500.0 ), // 5 new Vector( 500.0, 500.0, 500.0 ), // 6 new Vector( 0.0, 500.0, 500.0 ), // 7 new Vector( 0.0, 0.0, 0.0 ), // 8 new Vector( 500.0, 0.0, 0.0 ), // 9 new Vector( 500.0, 500.0, 0.0 ), // 10 new Vector( 0.0, 500.0, 0.0 ), // 11 new Vector( 0.0, 0.0, 500.0 ), // 12 new Vector( 500.0, 0.0, 500.0 ), // 13 new Vector( 500.0, 500.0, 500.0 ), // 14 new Vector( 0.0, 500.0, 500.0 ), // 15 new Vector( 0.0, 0.0, 0.0 ), // 16 new Vector( 500.0, 0.0, 0.0 ), // 17 new Vector( 500.0, 500.0, 0.0 ), // 18 new Vector( 0.0, 500.0, 0.0 ), // 19 new Vector( 0.0, 0.0, 500.0 ), // 20 new Vector( 500.0, 0.0, 500.0 ), // 21 new Vector( 500.0, 500.0, 500.0 ), // 22 new Vector( 0.0, 500.0, 500.0 ), // 23 /* The hole corner vertices */ new Vector( 100.0, 100.0, 0.0 ), // 24 new Vector( 300.0, 100.0, 0.0 ), // 25 new Vector( 300.0, 300.0, 0.0 ), // 26 new Vector( 100.0, 300.0, 0.0 ), // 27 new Vector( 100.0, 100.0, 500.0 ), // 28 new Vector( 300.0, 100.0, 500.0 ), // 29 new Vector( 300.0, 300.0, 500.0 ), // 30 new Vector( 100.0, 300.0, 500.0 ), // 31 new Vector( 100.0, 100.0, 0.0 ), // 32 new Vector( 300.0, 100.0, 0.0 ), // 33 new Vector( 300.0, 300.0, 0.0 ), // 34 new Vector( 100.0, 300.0, 0.0 ), // 35 new Vector( 100.0, 100.0, 500.0 ), // 36 new Vector( 300.0, 100.0, 500.0 ), // 37 new Vector( 300.0, 300.0, 500.0 ), // 38 new Vector( 100.0, 300.0, 500.0 ), // 39 }; var outloop = new[] { new[] { 0, 3, 2, 1 }, new[] { 8, 9, 13, 12 }, new[] { 17, 18, 22, 21 }, new[] { 10, 11, 15, 14 }, new[] { 19, 16, 20, 23 }, new[] { 4, 5, 6, 7 }, new[] { 31, 28, 24, 27 }, new[] { 30, 39, 35, 26 }, new[] { 29, 38, 34, 25 }, new[] { 36, 37, 33, 32 } }; var innerLoop = new Dictionary{int, int[][]} { { 0, new[] { new[] { 24, 25, 26, 27 } } }, { 5, new[] { new[] { 28, 31, 30, 29 } } }, }; var normals = new Vector[] { // Basic cube vertex normals new Vector( 0, 0, -1 ), new Vector( 0, 0, -1 ), new Vector( 0, 0, -1 ), new Vector( 0, 0, -1 ), new Vector( 0, 0, 1 ), new Vector( 0, 0, 1 ), new Vector( 0, 0, 1 ), new Vector( 0, 0, 1 ), new Vector( 0, 0, -1 ), // CHANGE THIS TO (0, -1, 0) FOR A VISIBLE EDGE new Vector( 0, 0, -1 ), // CHANGE THIS TO (0, -1, 0) FOR A VISIBLE EDGE new Vector( 0, 1, 0 ), new Vector( 0, 1, 0 ), new Vector( 0, -1, 0 ), new Vector( 0, -1, 0 ), new Vector( 0, 1, 0 ), new Vector( 0, 1, 0 ), new Vector(-1, 0, 0 ), new Vector( 1, 0, 0 ), new Vector( 1, 0, 0 ), new Vector(-1, 0, 0 ), new Vector(-1, 0, 0 ), new Vector( 1, 0, 0 ), new Vector( 1, 0, 0 ), new Vector(-1, 0, 0 ), // Hole vertex normals new Vector(-1, 0, 0 ), // 24 new Vector( 1, 0, 0 ), // 25 new Vector( 0, 1, 0 ), // 26 new Vector(-1, 0, 0 ), // 27 new Vector(-1, 0, 0 ), // 28 new Vector( 1, 0, 0 ), // 29 new Vector( 0, 1, 0 ), // 30 new Vector(-1, 0, 0 ), // 31 new Vector( 0, -1, 0 ), // 32 new Vector( 0, -1, 0 ), // 33 new Vector( 1, 0, 0 ), // 34 new Vector(-1, 0, 0 ), // 35 CHANGE THIS TO (0, 1, 0) FOR A VISIBLE EDGE new Vector( 0, -1, 0 ), // 36 new Vector( 0, -1, 0 ), // 37 new Vector( 1, 0, 0 ), // 38 new Vector(-1, 0, 0 ), // 39 CHANGE THIS TO (0, 1, 0) FOR A VISIBLE EDGE }; var brep = new FacetedBrepWithNormals(vertices, outloop, innerLoop, normals); var shapeItem1 = new ShapeItem { Name = "CubeWithHoleTwoEdgesHidden", ShapeFacetedBrep = brep, UpAxis = ShapeUpAxis.Z_Axis }; if (shapeItem1.InsertUsingNormals()) { var brep1 = new Brep() { StartPoint = new Point(0, 8000, 0), EndPoint = new Point(1000, 8000, 0), Profile = { ProfileString = "CubeWithHoleTwoEdgesHidden" }, }; brep1.Insert(); } var shapeItem2 = new ShapeItem { Name = "CubeWithHoleTwoEdgesHiddenCopy", ShapeFacetedBrep = brep, UpAxis = ShapeUpAxis.Z_Axis }; if (shapeItem2.InsertUsingNormalsAllowDuplicates()) { var brep2 = new Brep() { StartPoint = new Point(0, 9000, 0), EndPoint = new Point(1000, 9000, 0), Profile = { ProfileString = "CubeWithHoleTwoEdgesHiddenCopy" }, }; brep2.Insert(); } new Model().CommitChanges(); }
See Also