13 Parameter Curves, and Meshes
Two things a geometry chapter has to mention because they are in the files: the second, two-dimensional copy of every edge that doubles the size of a B-rep, and the AP242 records that carry a triangle mesh instead of — or alongside — a B-rep.
13.1 The edge that is written twice
The block of Chapter 10 was exported with a setting that suppresses parameter curves. Without it, the same block is 350 records instead of 170, and edge #21 looks like this:
#21 = EDGE_CURVE('',#22,#24,#26,.T.);
#26 = SURFACE_CURVE('',#27,(#31,#43),.PCURVE_S1.);
#27 = LINE('',#28,#29); /* the 3D line, as before */
#31 = PCURVE('',#32,#37);
#32 = PLANE('',#33); /* the x=0 face's own plane, shared */
#37 = DEFINITIONAL_REPRESENTATION('',(#38),#42);
#38 = LINE('',#39,#40); /* a 2D line in parameter space */
#39 = CARTESIAN_POINT('',(0.,0.));
#40 = VECTOR('',#41,1.);
#41 = DIRECTION('',(1.,0.));
#42 = ( GEOMETRIC_REPRESENTATION_CONTEXT(2)
PARAMETRIC_REPRESENTATION_CONTEXT()
REPRESENTATION_CONTEXT('2D SPACE','') );
#43 = PCURVE('',#44,#49);
#44 = PLANE('',#45); /* the y=0 face's own plane, shared */
#49 = DEFINITIONAL_REPRESENTATION('',(#50),#54);
/* ... another 2D line, another 2D context ... */Referred to above: 20 records from block-with-pcurves.step
#22 = VERTEX_POINT('',#23);
#23 = CARTESIAN_POINT('',(0.,0.,0.));
#24 = VERTEX_POINT('',#25);
#25 = CARTESIAN_POINT('',(0.,0.,10.));
#28 = CARTESIAN_POINT('',(0.,0.,0.));
#29 = VECTOR('',#30,1.);
#30 = DIRECTION('',(0.,0.,1.));
#33 = AXIS2_PLACEMENT_3D('',#34,#35,#36);
#34 = CARTESIAN_POINT('',(0.,0.,0.));
#35 = DIRECTION('',(1.,0.,0.));
#36 = DIRECTION('',(0.,0.,1.));
#45 = AXIS2_PLACEMENT_3D('',#46,#47,#48);
#46 = CARTESIAN_POINT('',(0.,0.,0.));
#47 = DIRECTION('',(0.,1.,0.));
#48 = DIRECTION('',(0.,0.,1.));
#50 = LINE('',#51,#52);
#51 = CARTESIAN_POINT('',(0.,0.));
#52 = VECTOR('',#53,1.);
#53 = DIRECTION('',(1.,0.));
#54 = ( GEOMETRIC_REPRESENTATION_CONTEXT(2)
PARAMETRIC_REPRESENTATION_CONTEXT() REPRESENTATION_CONTEXT('2D SPACE',''
) );The edge’s geometry is no longer a LINE but a SURFACE_: a 3D curve (#27, the line) together with a list of one or two entries, each normally a PCURVE, describing the same edge as a 2D curve in the parameter space of one of the faces it borders. Edge #21 lies on two faces, so it has two pcurves.
A PCURVE has a basis_ and a reference_. The reference is a DEFINITIONAL_ — a representation whose single item is a 2D curve and whose context is a 2D parametric context (dimension 2, no units, because parameter space is unitless). Here the 2D curve is a line from (0, 0) in direction (1, 0): the edge runs along the plane’s local X parameter.
The last attribute of the surface curve, master_, says which of the three descriptions is authoritative when they disagree: .CURVE_, .PCURVE_ or .PCURVE_. This exporter says the first pcurve is the master.
A face is a piece of a surface bounded by a loop of edges. To use the face — to mesh it, to find which side of an edge is inside — the kernel needs the boundary in the surface’s own coordinates: the (u, v) parameters, not the (x, y, z) positions. It can compute that by projecting each edge’s 3D curve onto the surface, but projection is slow, numerically delicate, and ambiguous on periodic surfaces (which side of the seam?) and at degenerate points (a cone’s apex maps to a whole line in parameter space). So kernels store the 2D curve directly, for every edge, on every face it bounds. Those are the pcurves. Writing them into the exchange file spares the importing kernel the projection and, more importantly, removes the ambiguities. It also roughly doubles the number of records: each edge gains a SURFACE_ above the 3D line it already had, two PCURVEs, two representations, two 2D contexts, and a 2D line, point, vector and direction for each — fifteen extra records per edge in this file.
The pcurve #31 points at #32, a PLANE — and that is the very record the face #17 uses as its own surface. This exporter shares one plane between a face and every pcurve that lies on it, so the file still holds only six PLANE records for six faces. Other exporters write a fresh copy of the surface for each pcurve, and the same part then carries thirty planes instead of six. Neither is wrong, and this is one reason two files of the same part from two systems can differ by a factor of two in size while describing identical geometry.
Three forms of surface curve turn up in files. Plain SURFACE_ is the ordinary case. SEAM_ is the seam of Chapter 11: a surface curve whose two pcurves lie on the same surface, one on each side of the cut. The pin of Chapter 11 was exported without pcurves. Exported again with them, as pin-with-pcurves.step, its seam is:
#21 = EDGE_CURVE('',#22,#24,#26,.T.);
#26 = SEAM_CURVE('',#27,(#31,#43),.PCURVE_S1.);
#31 = PCURVE('',#32,#37);
#32 = CYLINDRICAL_SURFACE('',#33,3.);
#37 = DEFINITIONAL_REPRESENTATION('',(#38),#42);
#38 = LINE('',#39,#40);
#39 = CARTESIAN_POINT('',(-0.,0.)); /* u = 0 */
#43 = PCURVE('',#32,#44);
#44 = DEFINITIONAL_REPRESENTATION('',(#45),#49);
#45 = LINE('',#46,#47);
#46 = CARTESIAN_POINT('',(-6.28318530718,0.)); /* u = -2*pi */Referred to above: 18 records from pin-with-pcurves.step
#22 = VERTEX_POINT('',#23);
#23 = CARTESIAN_POINT('',(3.,0.,0.));
#24 = VERTEX_POINT('',#25);
#25 = CARTESIAN_POINT('',(3.,0.,30.));
#27 = LINE('',#28,#29);
#28 = CARTESIAN_POINT('',(3.,0.,0.));
#29 = VECTOR('',#30,1.);
#30 = DIRECTION('',(0.,0.,1.));
#33 = AXIS2_PLACEMENT_3D('',#34,#35,#36);
#34 = CARTESIAN_POINT('',(0.,0.,0.));
#35 = DIRECTION('',(-0.,-0.,-1.));
#36 = DIRECTION('',(1.,0.,-0.));
#40 = VECTOR('',#41,1.);
#41 = DIRECTION('',(-0.,-1.));
#42 = ( GEOMETRIC_REPRESENTATION_CONTEXT(2)
PARAMETRIC_REPRESENTATION_CONTEXT() REPRESENTATION_CONTEXT('2D SPACE',''
) );
#47 = VECTOR('',#48,1.);
#48 = DIRECTION('',(-0.,-1.));
#49 = ( GEOMETRIC_REPRESENTATION_CONTEXT(2)
PARAMETRIC_REPRESENTATION_CONTEXT() REPRESENTATION_CONTEXT('2D SPACE',''
) );Both pcurves lie on the one cylinder #32, and both are the same line of constant u in its parameter space, a whole turn apart: u = 0 for the first, u = −2π for the second, the two sides of the cut. Both run in direction (0, −1), decreasing v; this cylinder’s axis points down, so decreasing v is up the pin, the way the 3D line #27 runs.
INTERSECTION_ marks an edge where two surfaces meet, which is nearly all of them; some exporters write it, most write plain SURFACE_.
Are pcurves needed? For a reader that only walks structure, no: an edge’s 3D curve is surface_, one more hop than before, and everything else is unchanged. For a reader that rebuilds solids in a geometric kernel, they are a strong hint and occasionally the only way to trim a face correctly. Most CAD exporters write them. OCCT and a few others make it optional. A file without them is smaller, not wrong.
13.2 Meshes: tessellated geometry
Everything so far has been exact geometry. AP242 added a second kind: tessellated geometry, in which a shape is a set of triangles. It exists because the two things most often done with a CAD model downstream — viewing it, and comparing it — do not need surfaces and are far cheaper on a mesh; because lightweight visualisation formats (JT above all) had been carrying meshes for years and STEP could not; and because some geometry (scanned surfaces, simulation results) never had an exact form. A tessellated shape lives in a TESSELLATED_ and is built from these records:
#500 = TESSELLATED_SHAPE_REPRESENTATION('',(#501),#165);
#501 = TESSELLATED_SOLID('',(#503),#15);
#503 = TRIANGULATED_FACE('',#504,4,((0.,0.,-1.)),#141,(1,2,3,4),((1,3,2),(1,4,3)));
#504 = COORDINATES_LIST('',4,((0.,0.,0.),(60.,0.,0.),(60.,20.,0.),(0.,20.,0.)));Referred to above: 155 records from block-ap242.step
#15 = MANIFOLD_SOLID_BREP('',#16);
#16 = CLOSED_SHELL('',(#17,#57,#97,#119,#141,#153));
#17 = ADVANCED_FACE('',(#18),#52,.F.);
#18 = FACE_BOUND('',#19,.F.);
#19 = EDGE_LOOP('',(#20,#30,#38,#46));
#20 = ORIENTED_EDGE('',*,*,#21,.F.);
#21 = EDGE_CURVE('',#22,#24,#26,.T.);
#22 = VERTEX_POINT('',#23);
#23 = CARTESIAN_POINT('',(0.,0.,0.));
#24 = VERTEX_POINT('',#25);
#25 = CARTESIAN_POINT('',(0.,0.,10.));
#26 = LINE('',#27,#28);
#27 = CARTESIAN_POINT('',(0.,0.,0.));
#28 = VECTOR('',#29,1.);
#29 = DIRECTION('',(0.,0.,1.));
#30 = ORIENTED_EDGE('',*,*,#31,.T.);
#31 = EDGE_CURVE('',#22,#32,#34,.T.);
#32 = VERTEX_POINT('',#33);
#33 = CARTESIAN_POINT('',(0.,20.,0.));
#34 = LINE('',#35,#36);
#35 = CARTESIAN_POINT('',(0.,0.,0.));
#36 = VECTOR('',#37,1.);
#37 = DIRECTION('',(0.,1.,0.));
#38 = ORIENTED_EDGE('',*,*,#39,.T.);
#39 = EDGE_CURVE('',#32,#40,#42,.T.);
#40 = VERTEX_POINT('',#41);
#41 = CARTESIAN_POINT('',(0.,20.,10.));
#42 = LINE('',#43,#44);
#43 = CARTESIAN_POINT('',(0.,20.,0.));
#44 = VECTOR('',#45,1.);
#45 = DIRECTION('',(0.,0.,1.));
#46 = ORIENTED_EDGE('',*,*,#47,.F.);
#47 = EDGE_CURVE('',#24,#40,#48,.T.);
#48 = LINE('',#49,#50);
#49 = CARTESIAN_POINT('',(0.,0.,10.));
#50 = VECTOR('',#51,1.);
#51 = DIRECTION('',(0.,1.,0.));
#52 = PLANE('',#53);
#53 = AXIS2_PLACEMENT_3D('',#54,#55,#56);
#54 = CARTESIAN_POINT('',(0.,0.,0.));
#55 = DIRECTION('',(1.,0.,0.));
#56 = DIRECTION('',(0.,0.,1.));
#57 = ADVANCED_FACE('',(#58),#92,.T.);
#58 = FACE_BOUND('',#59,.T.);
#59 = EDGE_LOOP('',(#60,#70,#78,#86));
#60 = ORIENTED_EDGE('',*,*,#61,.F.);
#61 = EDGE_CURVE('',#62,#64,#66,.T.);
#62 = VERTEX_POINT('',#63);
#63 = CARTESIAN_POINT('',(60.,0.,0.));
#64 = VERTEX_POINT('',#65);
#65 = CARTESIAN_POINT('',(60.,0.,10.));
#66 = LINE('',#67,#68);
#67 = CARTESIAN_POINT('',(60.,0.,0.));
#68 = VECTOR('',#69,1.);
#69 = DIRECTION('',(0.,0.,1.));
#70 = ORIENTED_EDGE('',*,*,#71,.T.);
#71 = EDGE_CURVE('',#62,#72,#74,.T.);
#72 = VERTEX_POINT('',#73);
#73 = CARTESIAN_POINT('',(60.,20.,0.));
#74 = LINE('',#75,#76);
#75 = CARTESIAN_POINT('',(60.,0.,0.));
#76 = VECTOR('',#77,1.);
#77 = DIRECTION('',(0.,1.,0.));
#78 = ORIENTED_EDGE('',*,*,#79,.T.);
#79 = EDGE_CURVE('',#72,#80,#82,.T.);
#80 = VERTEX_POINT('',#81);
#81 = CARTESIAN_POINT('',(60.,20.,10.));
#82 = LINE('',#83,#84);
#83 = CARTESIAN_POINT('',(60.,20.,0.));
#84 = VECTOR('',#85,1.);
#85 = DIRECTION('',(0.,0.,1.));
#86 = ORIENTED_EDGE('',*,*,#87,.F.);
#87 = EDGE_CURVE('',#64,#80,#88,.T.);
#88 = LINE('',#89,#90);
#89 = CARTESIAN_POINT('',(60.,0.,10.));
#90 = VECTOR('',#91,1.);
#91 = DIRECTION('',(0.,1.,0.));
#92 = PLANE('',#93);
#93 = AXIS2_PLACEMENT_3D('',#94,#95,#96);
#94 = CARTESIAN_POINT('',(60.,0.,0.));
#95 = DIRECTION('',(1.,0.,0.));
#96 = DIRECTION('',(0.,0.,1.));
#97 = ADVANCED_FACE('',(#98),#114,.F.);
#98 = FACE_BOUND('',#99,.F.);
#99 = EDGE_LOOP('',(#100,#106,#107,#113));
#100 = ORIENTED_EDGE('',*,*,#101,.F.);
#101 = EDGE_CURVE('',#22,#62,#102,.T.);
#102 = LINE('',#103,#104);
#103 = CARTESIAN_POINT('',(0.,0.,0.));
#104 = VECTOR('',#105,1.);
#105 = DIRECTION('',(1.,0.,0.));
#106 = ORIENTED_EDGE('',*,*,#21,.T.);
#107 = ORIENTED_EDGE('',*,*,#108,.T.);
#108 = EDGE_CURVE('',#24,#64,#109,.T.);
#109 = LINE('',#110,#111);
#110 = CARTESIAN_POINT('',(0.,0.,10.));
#111 = VECTOR('',#112,1.);
#112 = DIRECTION('',(1.,0.,0.));
#113 = ORIENTED_EDGE('',*,*,#61,.F.);
#114 = PLANE('',#115);
#115 = AXIS2_PLACEMENT_3D('',#116,#117,#118);
#116 = CARTESIAN_POINT('',(0.,0.,0.));
#117 = DIRECTION('',(0.,1.,0.));
#118 = DIRECTION('',(0.,0.,1.));
#119 = ADVANCED_FACE('',(#120),#136,.T.);
#120 = FACE_BOUND('',#121,.T.);
#121 = EDGE_LOOP('',(#122,#128,#129,#135));
#122 = ORIENTED_EDGE('',*,*,#123,.F.);
#123 = EDGE_CURVE('',#32,#72,#124,.T.);
#124 = LINE('',#125,#126);
#125 = CARTESIAN_POINT('',(0.,20.,0.));
#126 = VECTOR('',#127,1.);
#127 = DIRECTION('',(1.,0.,0.));
#128 = ORIENTED_EDGE('',*,*,#39,.T.);
#129 = ORIENTED_EDGE('',*,*,#130,.T.);
#130 = EDGE_CURVE('',#40,#80,#131,.T.);
#131 = LINE('',#132,#133);
#132 = CARTESIAN_POINT('',(0.,20.,10.));
#133 = VECTOR('',#134,1.);
#134 = DIRECTION('',(1.,0.,0.));
#135 = ORIENTED_EDGE('',*,*,#79,.F.);
#136 = PLANE('',#137);
#137 = AXIS2_PLACEMENT_3D('',#138,#139,#140);
#138 = CARTESIAN_POINT('',(0.,20.,0.));
#139 = DIRECTION('',(0.,1.,0.));
#140 = DIRECTION('',(0.,0.,1.));
#141 = ADVANCED_FACE('',(#142),#148,.F.);
#142 = FACE_BOUND('',#143,.F.);
#143 = EDGE_LOOP('',(#144,#145,#146,#147));
#144 = ORIENTED_EDGE('',*,*,#31,.F.);
#145 = ORIENTED_EDGE('',*,*,#101,.T.);
#146 = ORIENTED_EDGE('',*,*,#71,.T.);
#147 = ORIENTED_EDGE('',*,*,#123,.F.);
#148 = PLANE('',#149);
#149 = AXIS2_PLACEMENT_3D('',#150,#151,#152);
#150 = CARTESIAN_POINT('',(0.,0.,0.));
#151 = DIRECTION('',(0.,0.,1.));
#152 = DIRECTION('',(1.,0.,0.));
#153 = ADVANCED_FACE('',(#154),#160,.T.);
#154 = FACE_BOUND('',#155,.T.);
#155 = EDGE_LOOP('',(#156,#157,#158,#159));
#156 = ORIENTED_EDGE('',*,*,#47,.F.);
#157 = ORIENTED_EDGE('',*,*,#108,.T.);
#158 = ORIENTED_EDGE('',*,*,#87,.T.);
#159 = ORIENTED_EDGE('',*,*,#130,.F.);
#160 = PLANE('',#161);
#161 = AXIS2_PLACEMENT_3D('',#162,#163,#164);
#162 = CARTESIAN_POINT('',(0.,0.,10.));
#163 = DIRECTION('',(0.,0.,1.));
#164 = DIRECTION('',(1.,0.,0.));
#165 = ( GEOMETRIC_REPRESENTATION_CONTEXT(3)
GLOBAL_UNCERTAINTY_ASSIGNED_CONTEXT((#169)) GLOBAL_UNIT_ASSIGNED_CONTEXT
((#166,#167,#168)) REPRESENTATION_CONTEXT('Context #1',
'3D Context with UNIT and UNCERTAINTY') );
#166 = ( LENGTH_UNIT() NAMED_UNIT(*) SI_UNIT(.MILLI.,.METRE.) );
#167 = ( NAMED_UNIT(*) PLANE_ANGLE_UNIT() SI_UNIT($,.RADIAN.) );
#168 = ( NAMED_UNIT(*) SI_UNIT($,.STERADIAN.) SOLID_ANGLE_UNIT() );
#169 = UNCERTAINTY_MEASURE_WITH_UNIT(LENGTH_MEASURE(1.E-07),#166,
'distance_accuracy_value','confusion accuracy');(These four records are hand-written to the AP242 schema — the bottom face of the block as two triangles — rather than exported; the exporter used in this book does not write tessellation.)
COORDINATES_ is the vertex buffer: a count and a list of 3D points, as bare lists of reals rather than CARTESIAN_ records — the first place in the format where geometry is written without a record per point, precisely because a mesh may have a million of them.
TRIANGULATED_ is the index buffer. Its attributes: the coordinates list; pnmax, the number of points used; normals, a list of either one normal (flat shading, as here) or one per point; an optional geometric_ back to the exact ADVANCED_ it approximates (#141, the bottom face); pnindex, a list of 1-based indices into the coordinates list selecting the points this face uses; and triangles, a list of triples of 1-based indices into pnindex. So (1,3,2) means the first, third and second entries of pnindex, which are points 1, 3 and 2 of the coordinates list. That order winds the triangle clockwise seen from \(+Z\), which is counter-clockwise about this face’s own \(-Z\) normal: that is the agreement graphics pipelines assume, though neither AP242 nor the tessellation recommended practice states it, and a mesh wound the other way renders inside out. If pnindex is empty, the triangles index the coordinates directly.
TESSELLATED_ and TESSELLATED_ are alternatives rather than levels, and each holds its tessellated faces directly: a shell cannot be an item of a solid, because the schema admits only tessellated faces, edges and vertices there. A shell carries an optional topological_ to the exact CONNECTED_, closed or open; a solid carries an optional geometric_ to the exact MANIFOLD_. Here the solid’s geometric_ points at the exact MANIFOLD_ #15, and the face’s own at the exact ADVANCED_ #141: this is how a hybrid file carries the exact B-rep and a mesh of it, and says which is which. A COMPLEX_ is an alternative to TRIANGULATED_ rather than an extension of it: it carries triangle strips and fans instead of a plain triangle list, and must have at least one of them. TRIANGULATED_ and TESSELLATED_ cover meshes and polylines with no solid behind them; TESSELLATED_ covers scanned points.
Tessellated PMI — annotations drawn as triangles rather than curves — uses the same records and is in Chapter 16.
Two things to know when meeting a tessellated file. First, the mesh is approximate, and in most files it carries no statement of how approximate. AP242 does provide TESSELLATED_, which can state a chordal deviation, an angular deviation or a maximum edge length, but writers seldom use it, and a plain TESSELLATED_ records nothing. Second, in a hybrid file the mesh and the B-rep are independent representations of the same PRODUCT_; nothing requires them to agree, and a reader that wants to trust the mesh should check it against the exact geometry or against the validation properties of Chapter 15.
A SURFACE_ is a 3D curve plus its images in the parameter spaces of the faces it bounds (PCURVEs, each a 2D curve in a unitless 2D context); a SEAM_ has both images on one surface. They help importing kernels trim faces and roughly double a file. AP242 tessellation stores a mesh as a COORDINATES_ and TRIANGULATED_s with 1-based indices, optionally linked to the exact topology; it is approximate, and in practice states no tolerance, though AP242 has records for one.