Pointcloud - Joining the Dots
-
Could someone explain how I might join the dots of a pointcloud in the order that they are tabulated in the .csv file that created them.
Thank you. -
There are several points-cloud tools, they will all use a Delauney algorithm to make a triangulated mesh.
If you have a set of XYZ values that you know make a 'surface' you need to write a customized tool to read then in in order and add lines from them.
Presumably they are triangulated points... so your list repeats many points so that every three points read in make a triangular facet ?
Without sight of your CSV file it's impossible to progress this much... -
@gilboe said:
Could someone explain how I might join the dots of a pointcloud in the order that they are tabulated in the .csv file that created them.
Thank you.This is how I do it.
def import_csv mod=Sketchup.active_model ent=mod.entities @csv_dir = "c;/users/public/temp/" if !@csv_dir @csv_file = "csv_export.csv" if !@csv_file ctd_file=UI.openpanel("File to Import from;", @csv_dir,@csv_file) if !ctd_file then; return; end ctd_input=File.open(ctd_file,'r') x,y,z = ctd_input.readline.split(",") pp=Geom;;Point3d.new(x.to_f,y.to_f,z.to_f) while !ctd_input.eof? x,y,z = ctd_input.readline.split(",") pt=Geom;;Point3d.new(x.to_f,y.to_f,z.to_f) ent.add_line(pp,pt) pp=pt end ctd_input.close end
-
Of course, that sample code only draws new edges.
But you could easily add a command to 'force faces' for the new_edges if required.
next if pp==pt ### trap for coincident points in CSV new_edge=ent.add_line(pp,pt) new_edge.find_face
Also it'd be much 'safer' if you included a group thus
ents=mod.**active_**entities
then
gp=ents.add_group() gp.name=File.basename(@csv_file, ".*")
and then
ent=gp.entities
before adding the edges/faces intoent
- so the new mesh's geometry is kept quite separate from other existing geometry etc... -
The attached file will hopefully illustrate what I'm trying to achieve. (Please ignore my ridiculous scale)
The Point-cloud consists of six individual Point-clouds of 360 points. Each describing the inner or the outer edge of an ellipse resulting in three different, flat elliptical rings.
The intention is to create a solid ring from these, two representing the side of the solid and the remaining, the middle. It is the edge forms of this solid ring that I wish to achieve, more quickly than I have been able.
The 'stitching' that I have done in the attached file joins the outer points n together and similarly the inner points n.
The edge form is covered (triangulated) by joining sides n to middle n+1 from 0 to 180 and by joining sides n to middle n-1 from 181 to 360.
Having articulated this, I realise now, that this could be coded but I have no knowledge how it might be dome.
-
This could be coded - sdmitch is probably on to it as I type!
The 'manual' way can be done much easier if you subgroup the cpoints in sets and overdraw them.
Then use a tool like CurviLoft or EEbyRails on the 'face's edges/curves to make individual meshes for each of the four faces of the ring [the centerline seems superfluous??]
-
What defines the 3rd ring?
I used this code to triangulate two of them after I figured out how they were ordered in the model.
mod = Sketchup.active_model ent = mod.entities sel = mod.selection # collect the construction point locations in groups of 360 pts=[];ring=[] ent.each{|e| if e.class==Sketchup;;ConstructionPoint ring<<e.position if ring.length>=360 pts<<ring; ring=[] end end } # triangulate the rings for i in 0...360 ent.add_face(pts[0][i],pts[2][i-1],pts[2][i]) ent.add_face(pts[0][i],pts[0][i-1],pts[2][i-1]) ent.add_face(pts[0][i],pts[4][i-1],pts[4][i]) ent.add_face(pts[0][i],pts[0][i-1],pts[4][i-1]) ent.add_face(pts[1][i],pts[3][i-1],pts[3][i]) ent.add_face(pts[1][i],pts[1][i-1],pts[3][i-1]) ent.add_face(pts[1][i],pts[5][i-1],pts[5][i]) ent.add_face(pts[1][i],pts[1][i-1],pts[5][i-1]) end
-
The central ring isn't superfluous. It was unfortunate that I chose the 0/360 point to example my triangulation as both the inner and outer edge forms show little cross sectional form at this point unlike at 90. The inner edge form's concave, the outer, convex.
I'm not at home as I write. I will use your ideas as soon as I can though. Unfortunately, I've not the first idea how to code. Thank you
-
Thank you Sam!
Not having done any coding, would you mind telling me how I can use the code that you've made?
-
It needs to be included in a method and a module to identify and isolate it from the other plugins that may be loaded. I have made the necessary additions to allow you to copy the plugin to the plugins folder and have it appear in the plugins menu.
Please understand that this plugin, as written, applies to this single case only and the construction points near the model origin must be deleted before the plugin is run so that there are only the 2160 construction points that define the 6 rings.
-
This is some what off topic so please delete if not correct;
I attempted to convert skp file to dae and then see what MeshLab does with the data but it appears dae does not convert cpoints and only the vertices are showing??
There is a plugin to go from vertex to cpoint. Is there one for the cpoint to vertex?? -
My guess is no because you would have lost the relationship between the vertices that have been converted to construction points.
-
@sdmitch said:
It needs to be included in a method and a module to identify and isolate it from the other plugins that may be loaded. I have made the necessary additions to allow you to copy the plugin to the plugins folder and have it appear in the plugins menu.
Please understand that this plugin, as written, applies to this single case only and the construction points near the model origin must be deleted before the plugin is run so that there are only the 2160 construction points that define the 6 rings.
While trying not to appear stupid, I must ask what you mean by '......included in a method and a module and isolate it from other plugins....
...... would you mind explaining as if I am?
-
In Ruby, sub-routines are refered to as methods and are defined by "def method_name" as the first line and "end" as the last line. Modules contain any number of methods and are defined by "module Module_Name" as the first line and "end" as the last line. When a method is placed inside a module, it is normally coded def self.method_name where self. refers to the module containing it. Two modules can contain methods with same name but do different things and there is no conflict because the modules will have different names.
You should get a Ruby programming reference book if you ever expect to read and understand what the various code statements mean.
Advertisement