5
$\begingroup$

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

$\endgroup$
  • 2
    $\begingroup$ 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. $\endgroup$ – Yves Klett Jul 6 '12 at 8:28
  • 1
    $\begingroup$ My 2GB RAM was not enough. $\endgroup$ – István Zachar Jul 6 '12 at 16:15
  • $\begingroup$ It runs with 3 GB $\endgroup$ – Dr. belisarius Jul 6 '12 at 17:52
  • $\begingroup$ @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. $\endgroup$ – rm -rf Jul 6 '12 at 18:06
  • 1
    $\begingroup$ @Jay, I do not understand the question. You have a set of points, do you want the volume of the convex hull? $\endgroup$ – user21 Jul 17 '12 at 23:38
5
$\begingroup$

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

$\endgroup$
  • 3
    $\begingroup$ this looks rather like an excercise in epileptogenic cristallography. $\endgroup$ – Yves Klett Jul 19 '12 at 8:15
  • 3
    $\begingroup$ @YvesKlett I was hopping it may inspire Jay into providing us with correct data set ;-) $\endgroup$ – Vitaliy Kaurov Jul 19 '12 at 8:17
4
$\begingroup$

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.

$\endgroup$
  • 1
    $\begingroup$ Great idea. But org is not defined I think. $\endgroup$ – Vitaliy Kaurov Jul 21 '12 at 8:11
  • $\begingroup$ Cool! Nice cluster ;-) +1 $\endgroup$ – Vitaliy Kaurov Jul 21 '12 at 22:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy