I have struggled to find a way to do this as well. I believe that my solution lacks "elegance" and is rather brute forced in its nature, but here we go:
- Create a desired CAD model(I assume you have done this already) and save it as an .stl-file.
- For the next step, I use MeshLab(simply download it if you don't have it installed on your computer already). Import the .stl-file that you created earlier. Change the visualization of the model to "Points".
- Go to Filters -> Remeshing, Simplification and Reconstruction -> Refine User-Defined, then click "apply".
At this point, you should be able to see that your CAD model becomes a point cloud when you click on the "apply" button. When you are happy with your point cloud, convert your .stl-file to the .ply format. As soon as you have obtained the .ply-file, you should be able to convert it to a .pcd-file by using the ply2pcd functionality in the PCL.
In summary, I convert .stl->.ply, and then .ply->.pcd, but I use MeshCad to obtain the point cloud of my CAD model.
Any decent CAD software (Autocad, MicroStation) has built in functions to extract points from cad objects ( surface, primitives, b-spline...).
By setting up different input parameters you can control point cloud density in different directions.
Just throwing my two cents in. Given the assumption that your mesh is already subdivided enough (which it would be if it is exported as an stl from a cad program), you can just straight up convert it to a ply file (using Blender or something similar) and load up the resulting file in pcl. Ply can store mesh data but pcl ignores it!