Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I want to extract the cluster of points inside 3D box, is there any way one can do this in Mathematica?

share|improve this question
2  
Please do explain in more detail what you want to achieve specifically (i.e. aks an answerable question). Consider providing a smaller data set if possible to take the work load of possible answerers. –  Yves Klett Jul 6 '12 at 8:28
1  
My 2GB RAM was not enough. –  István Zachar Jul 6 '12 at 16:15
    
It runs with 3 GB –  belisarius Jul 6 '12 at 17:52
    
@Jay On this site we generally prefer to have posts either self contained or supplementary material hosted someplace where it is always retrievable (i.e., even after you delete the file from your dropbox) so that the question can help future users. I've uploaded your data file to a community github account for this reason. See also my answer here for why it was created and what the goals for the repository are. –  rm -rf Jul 6 '12 at 18:06
1  
@Jay, I do not understand the question. You have a set of points, do you want the volume of the convex hull? –  user21 Jul 17 '12 at 23:38
show 4 more comments

2 Answers 2

up vote 5 down vote accepted

OK, there is good news and bad news: as it seems Version 8 can not import the vtk cluster data directly (and I filed this as a suggestion for future improvement). The good new is that this does not matter too much. Here is a starting point, for more details you will have to look at the vtk documentation and what is stored in your vtk files.

file = "http://dl.dropbox.com/u/68983831/Step_0990.vtk";
(* smaller file *)
(*file="http://dl.dropbox.com/u/68983831/Step_005.vtk";*)

in = Import[file, "Table"];
p1 = Position[
   in, _?(If[Head[#] === String, StringMatchQ[#, "Cell*"], 
       False] &), {2}][[All, 1]]
(* {10, 114489} *)

p2 = Position[
   in, _?(If[Head[#] === String, StringMatchQ[#, "Cluster*"], 
       False] &), {2}][[All, 1]]
(* {228968} *)

dim = in[[5, {2, 3, 4}]];
sp = in[[6, {2, 3, 4}]];
org = in[[7, {2, 3, 4}]];
Union[d = Join @@ in[[p1[[1]] + 1 ;; p1[[2]] - 1]]]
(* {0, 1, 2} *)

u2 = Union[d2 = Join @@ in[[p1[[2]] + 1 ;; p2[[1]] - 1]]]
(* {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, \
19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, \
36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, \
53, 54, 55, 56, 57, 58, 59, 60, 61, 62} *)

coords = Flatten[
   Table[{i, j, k}, {i, org[[1]], dim[[1]] - 1, sp[[1]]}, {j, 
     org[[2]], dim[[2]] - 1, sp[[2]]}, {k, org[[3]], dim[[3]] - 1, 
     sp[[3]]}], 2];
Graphics3D[Point[Pick[coords, d, 1]]]

enter image description here

You can also use

Graphics3D[
 Point[Pick[coords, d2, Alternatives @@ Select[u2, # > 7 &]]]]

to look at different sub-clusters.

share|improve this answer
1  
Great idea. But org is not defined I think. –  Vitaliy Kaurov Jul 21 '12 at 8:11
    
Cool! Nice cluster ;-) +1 –  Vitaliy Kaurov Jul 21 '12 at 22:39
    
@ruebenko +1 thanks. –  Jay Jul 22 '12 at 5:01
    
@ruebenko I was trying to export above Graphics3d into .vtk format, and then import as .vtk file, I am missing polygondata, as i understand those are just data points, is any way I can get polygondata of those points without using convex hull. –  Jay Jul 24 '12 at 18:13
add comment

EDIT

OK, I think it is fair to say that the stuff below illustrates the quote "it seems Version 8 can not import the vtk cluster data directly" from the nice answer by @ruebenko .

------------------ old answer -----------------------------

It may happen that providing a smaller data set of your original data you lost the cluster points. If you zoom out of the center of the cube you can see that points fill the space rather uniformly - so there is no way for some of them to be more special than the others. It looks like there is no cluster. Could you please check and resubmit a verified data set with cluster points?

file = "http://dl.dropbox.com/u/68983831/Step_005.vtk";

data = Import[file, "VertexData"];

Manipulate[Graphics3D[Point[data], 
  PlotRange -> {{0 + r, 30 - r}, {0 + r, 30 - r}, {0 + r, 30 - r}}, 
  Axes -> True, ViewPoint -> {2 Cos[r], 2 Sin[r], Sin[r]}, 
  SphericalRegion -> True, ImageSize -> {400, 400}], {r, 14, 0}]

enter image description here

share|improve this answer
3  
this looks rather like an excercise in epileptogenic cristallography. –  Yves Klett Jul 19 '12 at 8:15
3  
@YvesKlett I was hopping it may inspire Jay into providing us with correct data set ;-) –  Vitaliy Kaurov Jul 19 '12 at 8:17
    
@ Vitaliy Kaurov, sure let me update my data set, hopefully memory issue will not come into effect. –  Jay Jul 19 '12 at 15:07
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.