void ArxDbgUtils::collectVertices(const AcDb3dPolyline* pline, AcGePoint3dArray& pts) { ASSERT(pline != NULL); ASSERT(pts.isEmpty()); AcDbObjectIterator* vertexIter = pline->vertexIterator(); ASSERT(vertexIter != NULL); if (vertexIter == NULL) return; AcDb3dPolylineVertex* vertex; for (; !vertexIter->done(); vertexIter->step()) { if (acdbOpenObject(vertex, vertexIter->objectId(), AcDb::kForRead) == Acad::eOk) { if (vertex->vertexType() != AcDb::k3dControlVertex) pts.append(vertex->position()); vertex->close(); } } delete vertexIter; ASSERT(pts.isEmpty() == false); if (pline->isClosed()) { AcGePoint3d tmpPt = pts[0]; // used to be a bug in dynamic arrays (not sure if its still there??) pts.append(tmpPt); } }
void ArxDbgUtils::collectVertices(const AcDb2dPolyline* pline, AcGePoint3dArray& pts, AcGeDoubleArray& bulges, bool asWcsPts) { ASSERT(pline != NULL); ASSERT(pts.isEmpty() && bulges.isEmpty()); AcDbObjectIterator* vertexIter = pline->vertexIterator(); ASSERT(vertexIter != NULL); if (vertexIter == NULL) return; AcDb2dVertex* vertex; for (; !vertexIter->done(); vertexIter->step()) { if (acdbOpenObject(vertex, vertexIter->objectId(), AcDb::kForRead) == Acad::eOk) { if (vertex->vertexType() != AcDb::k2dSplineCtlVertex) { if (asWcsPts) pts.append(pline->vertexPosition(*vertex)); // returns WCS else pts.append(vertex->position()); // returns ECS bulges.append(vertex->bulge()); } vertex->close(); } } delete vertexIter; ASSERT(pts.isEmpty() == Adesk::kFalse); if (pline->isClosed()) { AcGePoint3d tmpPt = pts[0]; // used to be a bug in dynamic arrays (not sure if its still there??) pts.append(tmpPt); bulges.append(0.0); } }
void ArxDbgUtils::collectVertices(const AcDb2dPolyline* pline, AcGePoint3dArray& pts, AcDbIntArray& types, AcGeDoubleArray& bulges, AcGeDoubleArray& startWidths, AcGeDoubleArray& endWidths, bool& hasWidth) { ASSERT(pline != NULL); ASSERT(pts.isEmpty() && bulges.isEmpty()); hasWidth = false; AcDbObjectIterator* vertexIter = pline->vertexIterator(); ASSERT(vertexIter != NULL); if (vertexIter == NULL) return; AcDb2dVertex* vertex; for (; !vertexIter->done(); vertexIter->step()) { if (acdbOpenObject(vertex, vertexIter->objectId(), AcDb::kForRead) == Acad::eOk) { if (vertex->vertexType() != AcDb::k2dSplineCtlVertex) { pts.append(pline->vertexPosition(*vertex)); // returns WCS bulges.append(vertex->bulge()); startWidths.append(vertex->startWidth()); endWidths.append(vertex->endWidth()); if (vertex->startWidth() || vertex->endWidth()) hasWidth = true; types.append(vertex->vertexType()); } vertex->close(); } } delete vertexIter; ASSERT(pts.isEmpty() == false); if (pline->isClosed()) { AcGePoint3d tmpPt = pts[0]; // used to be a bug in dynamic arrays (not sure if its still there??) pts.append(tmpPt); bulges.append(0.0); int tmpType = types[0]; types.append(tmpType); double tmpWidth = startWidths[0]; startWidths.append(tmpWidth); tmpWidth = endWidths[0]; endWidths.append(tmpWidth); } }
void ContourColorDlg::OnBnClickedOk() { UpdateData( TRUE ); // 获取图层名称 CString layer; if( !GetLayer( layer ) ) { MessageBox( _T( "没有选择包含等值线的图层" ) ); return; } AcGeDoubleArray zValues; AcArray<COLORREF> colors; int n = m_colorList.GetItemCount(); for( int i = 0; i < n; i++ ) { ColorListItemData* pData = ( ColorListItemData* )m_colorList.GetItemData( i ); zValues.append( pData->z ); colors.append( pData->rgb ); } // 删除最后一个z值 zValues.removeLast(); // 删除color list上的附加数据 DeleteColorListItemDatas(); // 获取图层上的等值线信息图元 AcDbObjectId objId = GetContourInfoOnLayer( layer ); SetContourInfo( objId, zValues, colors, m_bFillColor ); // 获取边界坐标数据 AcGePoint3dArray bounds; GetBoundaryPoints( bounds ); if( bounds.isEmpty() ) { MessageBox( _T( "请添加一个闭合的井田边界" ) ); return; } // 获取点集数据 AcGePoint3dArray datas; GetContourDatas( objId, datas ); //assert((colors.length()-zValues.length()) == 1); // 绘制填充 DrawFill( layer, bounds, datas, zValues, colors, m_bFillColor ); OnOK(); }
void DrawPolygonHatch( AcGiWorldDraw* mode, const AcGePoint3dArray& pts, const CString& patName, double scale ) { if( pts.isEmpty() ) return; AcDbHatch hatch; // set color //AcCmColor color; //color.setRGB(r, g, b); //pHatch->setColor(color); CreatePreDefinedHatch( &hatch, patName, scale ); CreatePolygonLoop( &hatch, pts ); // Elaborate solid fill hatch.evaluateHatch(); hatch.worldDraw( mode ); }
// 查找所有只关联一条直线的点坐标对应的分支以及方向 void FindInletBoundary( const AcDbObjectIdArray& objIds, const AcDbVoidPtrArray& lines, AcGePoint3dArray& inlet_spts, AcGePoint3dArray& inlet_epts, AcGeDoubleArray& inlet_dirs, AcDbObjectIdArray& inlet_objIds ) { // 查找所有的点 AcGePoint3dArray pts; GetNodePoints( lines, pts ); if( pts.isEmpty() ) return; for( int i = 0; i < pts.length(); i++ ) { // 查找点关联的双线 AcDbIntArray linePos; FindLinesByPoint( lines, pts[i], linePos ); if( linePos.length() != 1 ) continue; // 获取双线的始末点坐标 int pos = linePos[0]; DoubleLine* pLine = ( DoubleLine* )lines[pos]; AcGePoint3d spt, ept; pLine->getSEPoint( spt, ept ); // 判断当前点是始点还是末点 AcGePoint3d line_spt, line_ept; if( spt == pts[i] ) { pLine->getStartPoints( line_spt, line_ept ); } else { pLine->getEndPoints( line_spt, line_ept ); } inlet_spts.append( line_spt ); inlet_epts.append( line_ept ); inlet_dirs.append( pLine->getAngle() ); inlet_objIds.append( objIds[pos] ); } }
//////////////////////////////////////////////////////////////////////////////// /////// 将球在圆上分成m_nPrecision段,然后求相应处圆的半径 /////// /////// 再将此圆分成m_nPrecision份。 //////// /////// 所以共 (m_nPrecision+1)*(m_nPrecision+1)个点 //// //////////////////////////////////////////////////////////////////////////////// Acad::ErrorStatus PDSphere::getVertices(int Precision, AcGePoint3dArray& vertexArray, AcGeIntArray &stdIdx, int &actPrecision) const { assertReadEnabled(); while(!vertexArray.isEmpty()) vertexArray.removeLast(); AcGeDoubleArray dividDbl; getActDivid(Precision, dividDbl, stdIdx); int actPrecision__1 = dividDbl.length(); int actPrecision___2__1 = (dividDbl.length() - 1) * 2 + 1; actPrecision = actPrecision__1 - 1; vertexArray.setLogicalLength(actPrecision__1*actPrecision___2__1); AcGePoint3d varPt = m_ptCenter; //变截面的中心点 double varR = 0; double deltaAngle = PI / Precision; ///////////////////////////////////////////////////////////// /////// begin the division ///////// AcGeCubicSplineCurve3d varcur; AcGePoint3d point; for(int i = 0; i < actPrecision__1; ++i) { varPt.z=m_ptCenter.z- m_dRadius*cos(deltaAngle*dividDbl[i]); double tt = m_dRadius * m_dRadius - (m_ptCenter.z - varPt.z) * (m_ptCenter.z - varPt.z); if(tt < 0) tt = 0; varR = sqrt(tt); int j; for(j = 0; j <actPrecision__1; ++j) { if(i == 0) { point = m_ptCenter - AcGeVector3d(0, 0, 1) * m_dRadius; vertexArray[i*actPrecision___2__1+j]=point; } else if(i == actPrecision__1) { point = m_ptCenter + AcGeVector3d(0, 0, 1) * m_dRadius; vertexArray[i*actPrecision___2__1+j]=point; } else { point=varPt + AcGeVector3d(1, 0, 0) * varR; point.rotateBy(deltaAngle * dividDbl[j], AcGeVector3d(0, 0, 1), varPt); vertexArray[i*actPrecision__1+j]=point; } } for(j = 1; j <actPrecision__1; ++j) { if(i == 0) { point = m_ptCenter - AcGeVector3d(0, 0, 1) * m_dRadius; vertexArray[i*actPrecision__1 + j + actPrecision]=point; } else if(i == actPrecision__1) { point = m_ptCenter + AcGeVector3d(0, 0, 1) * m_dRadius; vertexArray[i*actPrecision__1 + j + actPrecision]=point; } else { point=varPt + AcGeVector3d(1, 0, 0) * varR; point.rotateBy(deltaAngle * dividDbl[j] + PI, AcGeVector3d(0, 0, 1), varPt); vertexArray[i*actPrecision__1 + j + actPrecision]=point; } } } return Acad::eOk; }