Point Cloud Crop VBNET
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
New to the forum!
I'm working on tailoring Madhukar Moogala's excellent code on point cloud cropping to fit some specific needs. You can find his code here:
https://adndevblog.typepad.com/autocad/2017/02/how-to-crop-a-point-cloud-using-api.html
I've got the code transcribed to VB.NET and am able to verify that it is performing the crop operation. However, I am having difficulty understanding how to meaningfully adjust the crop area. Right now I'm just trying to crop a rectangle out, but when I run the code, my entire cloud disappears because it is cropping somewhere outside the bounds of my point cloud. I know it's cropping because if I invert the crop, my cloud re-appears. I've made sure my point cloud is around the origin of 0,0,0 similar to the example, but still cannot get it to crop anything within the bound of my cloud. I think I am not understanding the logic of defining a plane and the crop vertices.
From what I understanding from reading the documentation , a point cloud crop needs a CropPlane and Vertices. Here's the key part of Madhukar's code converted to VBNET with the arguments coded into the function for simplification:
Public Shared Function addcropping(ByVal pointcloud As PointCloudEx) As ErrorStatus Dim crop As PointCloudCrop = PointCloudCrop.Create(IntPtr.Zero) Dim points As Point3dCollection = New Point3dCollection() Dim pt1 As New Point3d(-7, 12, 0) Dim pt2 As New Point3d(-4, 9, 0) points.Add(pt1) 'add points to the point3dCollection points.Add(pt2) 'confused as to why he only supplied two points when the crop type is rectangle. Documentation appears to call for 5: (1,2,3,4, and 1st again) crop.Vertices = points Dim norm As Vector3d = New Vector3d(0, 1, 0) 'I understand plane to form an XY plane because both pt1 (-7,12,0) and norm (0,1,0) have a value of 0 for the Z axis.
' 'maybe this is where I'm wrong in my thinking? Dim cropPlane As Plane = New Plane(pt1, norm) crop.CropPlane = cropPlane crop.CropType = PointCloudCropType.Rectangular crop.Inside = True crop.Inverted = False pointcloud.addCroppingBoundary(crop) Return ErrorStatus.OK End Function
By changing the values for pt1 and pt2, I am unable to intelligently "move" the cropped area into my point cloud. In my mind, the above code should cut out a rectangle looking at the cloud from the top down. But I'm obviously errant in my thinking because it seems that no matter what I change those values to, I can't get the crop to touch my cloud. Could someone explain to me how the plane and points in the plane work? Has anyone been able to implement madhukar's code? Any help is appreciated. Been stuck on this for a while.