<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">Hi all,<div class=""><br class=""></div><div class="">I've added a batch of new CGM operators to SMTK (and fixed a few things in the process). The operators include:</div><div class=""><br class=""></div><div class="">- create vertex</div><div class="">- create edge (straight, arc, ellipse, parabola, hyperbola... but only straight and arc are tested)</div><div class="">- create face (planar or "best fit" -- which is a synonym for planar as far as I can tell)</div><div class="">- create cylinder</div><div class="">- create brick</div><div class="">- create sphere</div><div class="">- create prism</div><div class="">- union (a boolean, but only tested in a simple case)</div><div class="">- read (from a file supported by CGM)</div><div class=""><br class=""></div><div class="">There are examples of the operators in the smtk/bridge/cgm/testing/python directory.</div><div class=""><br class=""></div><div class="">Some notes:</div><div class=""><br class=""></div><div class="">1. The "create brick" operator is interesting because it demonstrates conditional items.</div><div class="">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 class="">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 class="">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 class="">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 class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>David</div><div class=""><br class=""></div><div class="">PS. As an example, the Python script below created the 4 vertices, 6 edges, and 3 faces in the screenshot.</div><div class=""><br class=""></div><div class="">import smtk<br class="">mgr = smtk.model.Manager.create()<br class="">sess = mgr.createSession('cgm')<br class="">brg = sess.bridge()<br class=""><br class="">def setCoord(x,v):<br class=""> for i in range(len(v)):<br class=""> x.setValue(i,v[i])<br class=""><br class="">def setEntitiesByIndex(p,ep,v):<br class=""> for i in range(len(ep)):<br class=""> p.setValue(i, v[ep[i]])<br class=""><br class="">verts = []<br class="">edges = []<br class="">faces = []<br class="">volus = []<br class=""><br class=""># Create vertices<br class="">pcoords = [ (0,0,0), (1,0,0), (0,1,0), (0,0,1)]<br class="">crv = sess.op('create vertex')<br class="">x = crv.findAsDouble('point')<br class="">c = crv.findAsInt('color')<br class="">c.setValue(0, 1)<br class="">for pt in pcoords:<br class=""> setCoord(x,pt);<br class=""> verts.append(crv.operate().findModelEntity('vertex').value(0))<br class=""><br class=""># Create edges<br class="">epts = [(0,1), (0,2), (0,3), (1,2), (1,3), (2,3)]<br class="">cre = sess.op('create edge')<br class="">t = cre.findAsInt('curve type')<br class="">t.setValue(0,6) # 6 == line segment in OpenCascade<br class="">v = cre.findAsModelEntity('vertices')<br class="">x = cre.findAsDouble('point')<br class="">c = cre.findAsInt('color')<br class="">c.setValue(0, 2)<br class="">for epair in epts:<br class=""> setEntitiesByIndex(v,epair,verts)<br class=""> if epair == (2,3):<br class=""> # Make the last edge an arc:<br class=""> t.setValue(0,1) # 1 == arc<br class=""> setCoord(x,[0,0.6,0.6]) # third point on arc<br class=""> edges.append(cre.operate().findModelEntity('edge').value(0))<br class=""><br class=""># Create faces<br class="">fedg = [<br class=""> (12, 0, 3, 1),<br class=""> (12, 0, 4, 2),<br class=""> (16, 1, 5, 2)<br class=""> ]<br class=""># (16, 3, 5, 4) # <-- OpenCascade cannot infer that this face should be cylindrical<br class="">crf = sess.op('create face')<br class="">t = crf.findAsInt('surface type')<br class="">t.setValue(0, 12)<br class="">e = crf.findAsModelEntity('edges')<br class="">c = crf.findAsInt('color')<br class="">c.setValue(0, 3)<br class="">for face in fedg:<br class=""> e.setNumberOfValues(len(face)-1)<br class=""> setEntitiesByIndex(e,face[1:],edges)<br class=""> t.setValue(face[0]) # These values are OpenCascade enum values.<br class=""> faces.append(crf.operate().findModelEntity('face').value(0))<br class=""><br class=""></div><div class=""><img apple-inline="yes" id="140E56B7-B9AA-4A72-AC02-75D1D103111C" height="346" width="367" apple-width="yes" apple-height="yes" src="cid:60A9A437-B25F-4A0B-AA14-C555ED333C2A@kitwarein.com" class=""></div></body></html>