// https://developer.rhino3d.com/guides/cpp/brep-data-structure/ private Topology ByBrep(Brep ghBrep, double tolerance) { BrepFaceList ghBrepFaces = ghBrep.Faces; List <Face> faces = new List <Face>(); foreach (BrepFace ghBrepFace in ghBrepFaces) { Face face = ByBrepFace(ghBrepFace); faces.Add(face); } if (faces.Count == 0) { return(null); } else if (faces.Count == 1) { return(faces[0]); } else { Shell shell = Shell.ByFaces(faces, tolerance); if (ghBrep.IsSolid) { Cell cell = Cell.ByShell(shell); return(cell); } return(shell); } }
public List <Brep> CreateSlabBrep() { List <Brep> newBreps = new List <Brep>(); BrepFaceList faces = this.slabSurface.Faces; for (int faceID = 0; faceID < faces.Count; faceID++) { BrepFace faceItem = faces[faceID]; Point3d cornerPoint = faceItem.Brep.Vertices[0].Location; //Transform transform= Transform.Translation(00, 0, -1 * thickness); //cornerPoint.Transform(transform); Curve extrudeCurve = new Line(cornerPoint, new Vector3d(0, 0, -1 * this.thickness)).ToNurbsCurve(); newBreps.Add(faceItem.CreateExtrusion(extrudeCurve, true)); } return(newBreps); }
internal static void _InitThreadSafe(this BrepFaceList faces) { lock (faces) { var count = faces.Count; if (count > 0) { // we take last element and thus init all list - this make our list threadsafe var last = faces[count - 1]; } foreach (var face in faces) { face.Loops._InitThreadSafe(); } } }
public Surface[] CreateSortedSurfaces(Brep brp, Curve[] sortedEdges, List <Point3d> corners) { Surface[] surfaces = new Surface[6]; BrepFaceList faces = brp.Faces; surfaces[0] = faces[0].DuplicateSurface(); surfaces[1] = faces[1].DuplicateSurface(); surfaces[2] = faces[2].DuplicateSurface(); surfaces[3] = faces[3].DuplicateSurface(); surfaces[4] = faces[4].DuplicateSurface(); surfaces[5] = faces[5].DuplicateSurface(); surfaces = FindSurfaces(corners, surfaces); return(surfaces); }
public static Topology ToTopologic(this Brep brep, double tolerance = Core.Tolerance.Distance) { if (brep == null) { return(null); } BrepFaceList ghBrepFaces = brep.Faces; List <global::Topologic.Face> faces = new List <global::Topologic.Face>(); foreach (BrepFace ghBrepFace in ghBrepFaces) { global::Topologic.Face face = ghBrepFace.ToTopologic(); faces.Add(face); } if (faces.Count == 0) { return(null); } else if (faces.Count == 1) { return(faces[0]); } else { global::Topologic.Shell shell = global::Topologic.Shell.ByFaces(faces, tolerance); if (brep.IsSolid) { Cell cell = Cell.ByShell(shell); return(cell); } return(shell); } }
private IEnumerable <Vector3d> GetBrepNormals(IEnumerable <Point3d> pts) { //Initialize variables List <Surface> brepSrfs = new List <Surface>(); List <Vector3d> normals = new List <Vector3d>(); const double epsilon = 0.0001; //The minimum distance to determine which surface a pt is touching. //Explode brep BrepFaceList brepFaces = environment.Faces; foreach (BrepFace face in brepFaces) { Surface srf = face.ToBrep().Surfaces[0]; if (face.OrientationIsReversed) { brepSrfs.Add(srf.Reverse(0)); } else { brepSrfs.Add(srf); } } /* * for each point, get the closest point to each surface */ foreach (Point3d pt in pts) { List <Plane> framesTemp = new List <Plane>(); foreach (Surface srf in brepSrfs) { double u; double v; srf.ClosestPoint(pt, out u, out v); Plane frame; srf.FrameAt(u, v, out frame); if (pt.DistanceTo(frame.Origin) <= epsilon) { framesTemp.Add(frame); } } /* * if there is 1 close surface: * add the two normal vectors together to get the bisector */ Vector3d brepNormal = framesTemp[0].Normal; /* * if there are 2 equally close surfaces: * add the two normal vectors together to get the bisector */ if (framesTemp.Count > 1) { for (int j = 1; j < framesTemp.Count; j++) { Plane pln = framesTemp[j]; brepNormal = Vector3d.Add(brepNormal, pln.Normal); } } brepNormal.Unitize(); normals.Add(brepNormal); } return(normals); }