<div dir="ltr">Just to clarify, I was running from ModelBuilder_v4, which uses cmbForwardingBridge to launch the cgm operators and collects their results, then uses paraview's rendering framework to display the geometry. So this is not exactly the same flow as Dave uses. My flow includes UI components and extra paraview proxy layers.</div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Nov 13, 2014 at 5:01 PM, Yumin Yuan <span dir="ltr"><<a href="mailto:yumin.yuan@kitware.com" target="_blank">yumin.yuan@kitware.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">That's great, Dave.<div><br></div><div>I updated a few things from cmb_v4, and here is what I got:</div><div><br></div><div>* Creating Prism, Brick, Cylinder are working, see attached screenshot.</div><div>* Creating sphere return a sphere, sort of (see attached )</div><div>* Creating Vertex, Edge, Face did not work for me. No geometry returned, and sometime crash. I believe the crashes were from cgm, and I don't have useful backtrace info from the crash.</div><div><br></div><div>Yumin</div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On Thu, Nov 13, 2014 at 2:49 PM, David Thompson <span dir="ltr"><<a href="mailto:david.thompson@kitware.com" target="_blank">david.thompson@kitware.com</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div style="word-wrap:break-word">Hi all,<div><br></div><div>I've added a batch of new CGM operators to SMTK (and fixed a few things in the process). The operators include:</div><div><br></div><div>- create vertex</div><div>- create edge (straight, arc, ellipse, parabola, hyperbola... but only straight and arc are tested)</div><div>- create face (planar or "best fit" -- which is a synonym for planar as far as I can tell)</div><div>- create cylinder</div><div>- create brick</div><div>- create sphere</div><div>- create prism</div><div>- union (a boolean, but only tested in a simple case)</div><div>- read (from a file supported by CGM)</div><div><br></div><div>There are examples of the operators in the smtk/bridge/cgm/testing/python directory.</div><div><br></div><div>Some notes:</div><div><br></div><div>1. The "create brick" operator is interesting because it demonstrates conditional items.</div><div>2. the "union" operator is interesting because it expects the models you wish to unite to be associated with it rather than passed in via an smtk::attribute::ModelEntityItem.</div><div>3. The edge and face creation operators currently take vertices and edges to connect as input items, but will probably move to using an association in the future.</div><div>4. Yumin has discovered that the union operator exposes an issue in the model manager... the result of the operation does not appear to be properly transcribed when using a forwarding bridge.</div><div>5. Some of the operator XML descriptions are marked as requiring a "b" association. This is a new type of association and indicates that the operator should be associated to a bridge session. Creation operators in general should have this type of association so that the user can choose which session/kernel to use.</div><div><br></div><div><span style="white-space:pre-wrap">        </span>David</div><div><br></div><div>PS. As an example, the Python script below created the 4 vertices, 6 edges, and 3 faces in the screenshot.</div><div><br></div><div>import smtk<br>mgr = smtk.model.Manager.create()<br>sess = mgr.createSession('cgm')<br>brg = sess.bridge()<br><br>def setCoord(x,v):<br>  for i in range(len(v)):<br>    x.setValue(i,v[i])<br><br>def setEntitiesByIndex(p,ep,v):<br>  for i in range(len(ep)):<br>    p.setValue(i, v[ep[i]])<br><br>verts = []<br>edges = []<br>faces = []<br>volus = []<br><br># Create vertices<br>pcoords = [ (0,0,0), (1,0,0), (0,1,0), (0,0,1)]<br>crv = sess.op('create vertex')<br>x = crv.findAsDouble('point')<br>c = crv.findAsInt('color')<br>c.setValue(0, 1)<br>for pt in pcoords:<br>  setCoord(x,pt);<br>  verts.append(crv.operate().findModelEntity('vertex').value(0))<br><br># Create edges<br>epts = [(0,1), (0,2), (0,3), (1,2), (1,3), (2,3)]<br>cre = sess.op('create edge')<br>t = cre.findAsInt('curve type')<br>t.setValue(0,6) # 6 == line segment in OpenCascade<br>v = cre.findAsModelEntity('vertices')<br>x = cre.findAsDouble('point')<br>c = cre.findAsInt('color')<br>c.setValue(0, 2)<br>for epair in epts:<br>  setEntitiesByIndex(v,epair,verts)<br>  if epair == (2,3):<br>    # Make the last edge an arc:<br>    t.setValue(0,1) # 1 == arc<br>    setCoord(x,[0,0.6,0.6]) # third point on arc<br>  edges.append(cre.operate().findModelEntity('edge').value(0))<br><br># Create faces<br>fedg = [<br>    (12, 0, 3, 1),<br>    (12, 0, 4, 2),<br>    (16, 1, 5, 2)<br>    ]<br>#   (16, 3, 5, 4) # <-- OpenCascade cannot infer that this face should be cylindrical<br>crf = sess.op('create face')<br>t = crf.findAsInt('surface type')<br>t.setValue(0, 12)<br>e = crf.findAsModelEntity('edges')<br>c = crf.findAsInt('color')<br>c.setValue(0, 3)<br>for face in fedg:<br>  e.setNumberOfValues(len(face)-1)<br>  setEntitiesByIndex(e,face[1:],edges)<br>  t.setValue(face[0]) # These values are OpenCascade enum values.<br>  faces.append(crf.operate().findModelEntity('face').value(0))<br><br></div><div><img height="346" width="367" src="cid:60A9A437-B25F-4A0B-AA14-C555ED333C2A@kitwarein.com"></div></div><br></div></div>_______________________________________________<br>
Smtk-developers mailing list<br>
<a href="mailto:Smtk-developers@smtk.org" target="_blank">Smtk-developers@smtk.org</a><br>
<a href="http://public.kitware.com/mailman/listinfo/smtk-developers" target="_blank">http://public.kitware.com/mailman/listinfo/smtk-developers</a><br>
<br></blockquote></div><br></div>
</blockquote></div><br></div>