<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" id="owaParaStyle"></style>
</head>
<body fpstyle="1" ocsi="0">
<div style="direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;">Dear users, 
<div>I am <span style="font-size: 10pt;">creating a macro for automatically clipping a polydata. I would like to have cubic boxes as implicit function for clipping (that is to say, clipping along x,y,z at fixed distances) </span></div>
<div>Unfortunately I was not able to find the documentation for clip type properties in case of box. In particular, I don't understand how the position is computed (is it absolute or relative? is it the position of the center or of the corner of the clip box?)
 . If I understood correctly, the scale is relative to the bounding box (of the object being clipped). </div>
<div><br>
</div>
<div>This is what I have so far:</div>
<div><span style="font-size: 10pt;"><br>
</span></div>
<div><span style="font-size: 10pt;">s = paraview.simple.GetActiveSource()</span></div>
<div>b = s.GetDataInformation().GetBounds()</div>
<div>dims = [b[1] -b[0], b[3] - b[2],b[5] -b[4]]</div>
<div>#l is the side of the cube that will used for clipping (fixed, measure in absolute terms)</div>
<div><span style="font-size: 10pt;">l=0.2</span></div>
<div><span style="font-size: 10pt;">scale = numpy.divide(cube_edge,dims)</span></div>
<div><span style="font-size: 10pt;">#i compute how many times the cube is included in the object</span></div>
<div><span style="font-size: 10pt;">times=[1/scale[0],</span>1/scale<span style="font-size: 10pt;">[1], </span>1/scale<span style="font-size: 10pt;">[2] ]</span></div>
<div><span style="font-size: 10pt;">#start creating clips </span></div>
<div>for x in range(int(ceil(times[0]))) :</div>
<div><span style="font-size: 10pt;">  for y in range(int(ceil(times[1]))) :</span></div>
<div>    for z in range(int(ceil(times[2]))) :</div>
<div>       <span style="font-size: 10pt;">paraview.simple.SetActiveSource(s)</span></div>
<div>       c = paraview.simple.Clip()</div>
<div><span style="font-size: 10pt;">       c.ClipType = "Box"</span></div>
<div><span style="font-size: 10pt;">       c.InsideOut = 1</span></div>
<div><span style="font-size: 10pt;">       c.ClipType.Bounds = b</span></div>
<div><span style="font-size: 10pt;">       c.ClipType.Scale = scale</span></div>
<div><span style="font-size: 10pt;">       c.Crinkleclip = 1</span></div>
<div><span style="font-size: 10pt;">       c.ClipType.Rotation = [0,0,0] </span></div>
<div><span style="font-size: 10pt;">       c.ClipType.Position = [x/times[0] * dims[0], y/times[1] * dims[1], z/times[2] * dims[2]]</span></div>
<div><span style="font-size: 10pt;">       paraview.simple.Show()</span></div>
<div><span style="font-size: 10pt;"><br>
</span></div>
<div><span style="font-size: 10pt;">The macro works if the cube is bigger than the bounding box of the objects, in other cases I see that the position of the clip box is not where I expect it to be (it looks dependent on the scale, especially when the bounding
 box is not centered in the origin)</span></div>
<div><br>
</div>
<div>How can I handle correctly the position?</div>
<div>Thank you</div>
<div><span style="font-size: 10pt;"><br>
</span></div>
<div><span style="font-size: 10pt;"><br>
</span></div>
<div><br>
</div>
</div>
</body>
</html>