网格是存储参数化矩形顶点网格的有效方法。网格的几何体按行顺序指定为行数、列数和顶点列表: virtual Adesk::Boolean AcGiWorldGeometry::mesh( const Adesk::UInt32 rows, const Adesk::UInt32 columns, const AcGePoint3d* pVertexList, const AcGiEdgeData* pEdgeData = NULL, const AcGiFaceData* pFaceData = NULL, const AcGiVertexData* pVertexData = NULL) const = 0; 该函数有三个可选参数,用于将属性数据附加到边、面或顶点。对于网格中的边,可以附加颜色、图层、线型、GS 标记和可见性属性。例如,您可以使用 将不同的颜色附加到网格的每个边缘。在颜色列表中,首先列出所有行边缘的颜色,然后列出所有列边缘的颜色。下图显示了示例网格的边缘属性数据的顺序:mesh()AcGiEdgeData::setColors()
以下示例代码创建一个网格,并使用边缘数据和面数据分配颜色。它构造一个包含青色行和绿色列的四乘四网格。 Adesk::Boolean AsdkMeshSamp::subWorldDraw(AcGiWorldDraw* pW) { Adesk::UInt32 i, j, k; Adesk::UInt32 numRows = 4; Adesk::UInt32 numCols = 4; AcGePoint3d *pVerts = new AcGePoint3d[numRows * numCols]; for (k = 0, i = 0; i < numRows; i++) { for (j = 0; j < numCols; j++, k++) { pVerts[k].x = (double)j; pVerts[k].y = (double)i; pVerts[k].z = 0.; } } // Construct an array of colors to be applied to each // edge of the mesh. Here, let the rows be cyan and // the columns be green. // AcGiEdgeData edgeInfo; Adesk::UInt32 numRowEdges = numRows * (numCols - 1); Adesk::UInt32 numColEdges = (numRows - 1) * numCols; Adesk::UInt32 numEdges = numRowEdges + numColEdges; short *pEdgeColorArray = new short[numEdges]; for (i = 0; i < numEdges; i++) { pEdgeColorArray[i] = i < numRowEdges ? kCyan : kGreen; } edgeInfo.setColors(pEdgeColorArray); // Make the first face transparent and the rest // different colors. // Adesk::UInt32 numFaces = (numRows - 1) * (numCols - 1); Adesk::UInt8 *pFaceVisArray = new Adesk::UInt8[numFaces]; short *pFaceColorArray = new short[numFaces]; AcGiFaceData faceInfo; faceInfo.setVisibility(pFaceVisArray); for (i = 0; i < numFaces; i++) { pFaceVisArray [i] = i ? kAcGiVisible : kAcGiInvisible; pFaceColorArray[i] = (short)(i + 1); } faceInfo.setColors(pFaceColorArray); // If the fill type is kAcGiFillAlways, then a shell, // mesh, or polygon will be interpreted as faces; // otherwise, they will be interpreted as edges. // Output mesh as faces. // pW- >subEntityTraits().setFillType(kAcGiFillAlways); pW->geometry ().mesh(numRows, numCols, pVerts, NULL, &faceInfo); // Output mesh as edges over the faces. // pW- >subEntityTraits().setFillType(kAcGiFillNever); pW->geometry ().mesh(numRows, numCols, pVerts, &edgeInfo); delete [] pVerts; delete [] pEdgeColorArray; delete [] pFaceColorArray; delete [] pFaceVisArray; return Adesk::kTrue; } 对于网格中的面,您可以附加颜色、图层、GS 标记、法线和可见性特征。要为网格中的面分配属性,请按行顺序列出面的值,如下图所示: 网格的顶点数据的列出顺序与顶点列表中的顺序相同。可以设置的属性是法线和方向。AcGiVertexData |
|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 苏公网安备32011402011833)
GMT+8, 2025-1-8 19:09
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.