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);
    }
}
Acad::ErrorStatus 
rx_scanPline(AcDb2dPolyline*        pline,
             AcGePoint3dArray&      points,
             AcGeDoubleArray&       bulges)
{
    Acad::ErrorStatus es = Acad::eOk;

    AcDb2dVertex*  vert   = NULL;
    AcDbObjectId   vId;

    AcDbObjectIterator *vIter;
    vIter = pline->vertexIterator();

    for (; !vIter->done(); vIter->step()) {
		vId = vIter->objectId();

		if ( (es =pline->openVertex(vert, vId, AcDb::kForRead)) != Acad::eOk )
			return es;

		points.append(vert->position());
		bulges.append(vert->bulge());
    }

    delete vIter;
    
    return es;
}
Ejemplo n.º 3
0
static void AppendNewGoafPolygon( const AcGePoint3dArray& polygons,
                                  const AcDbIntArray& polygon_counts,
                                  const AcDbIntArray& colinearEdges,
                                  const AcDbIntArray& parTypes,
                                  const AcGePoint3dArray& ex_spts,
                                  const AcGePoint3dArray& ex_epts,
                                  const AcGeDoubleArray& ex_dirs,
                                  const AcDbIntArray& linePos,
                                  int k,
                                  AcGePoint3dArray& spts,
                                  AcGePoint3dArray& epts,
                                  AcGeDoubleArray& dirs,
                                  AcDbIntArray& gas_types,
                                  AcDbIntArray& gas_linePos )
{
    int s = 0;
    for( int i = 0; i < k; i++ )
    {
        s += polygon_counts[i];
    }
    int t = s + polygon_counts[k];

    for( int i = s; i < t; i++ )
    {
        if( colinearEdges[i] == 0 )
        {
            spts.append( ex_spts[i] );
            epts.append( ex_epts[i] );
            dirs.append( ex_dirs );
            gas_types.append( parTypes[i] );
            gas_linePos.append( linePos[i] );
        }
    }
}
Ejemplo n.º 4
0
void Additional_Class::Get_PolyLine_Length( AcDbObjectId PolyLineId, AcGeDoubleArray &LengthArray )
{
	double PI=3.1415926535897932384626433832795;
	AcDbEntity *pEnt_Temp = NULL;
	Acad::ErrorStatus es = acdbOpenAcDbEntity(pEnt_Temp, PolyLineId, AcDb::kForRead);
	if (es != Acad::eOk)
	{
		acutPrintf(_T("\nOPEN POLYLINE ERROR"));
		return;
	}
	if (!pEnt_Temp->isKindOf(AcDbPolyline::desc()))
	{
		acutPrintf(_T("\nENTITY NOT POLYLINE"));
		return;
	}
	AcDbPolyline *pPolyLine = AcDbPolyline::cast(pEnt_Temp);
	int num = pPolyLine->numVerts();
	for (int index=0; index<num; index++)
	{
		if (pPolyLine->segType(index) == AcDbPolyline::kLine)
		{
			AcGeLineSeg3d tempLine;
			pPolyLine->getLineSegAt(index,tempLine);
			double LineLength = tempLine.length();
			LengthArray.append(LineLength);
		}
		else if (pPolyLine->segType(index) == AcDbPolyline::kArc)
		{
			AcGeCircArc2d tempArc;
			pPolyLine->getArcSegAt(index,tempArc);
			double StartAngle = tempArc.startAng();
			double EndAngle = tempArc.endAng();
			double Angle = EndAngle-StartAngle;
			//Angle = (180/PI)*Angle;
			double Radius = tempArc.radius();
			double ArcLength = Radius*Angle;
			LengthArray.append(ArcLength);
		}
	}
	LengthArray.insertAt(0,0);
}
Ejemplo n.º 5
0
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();
}
Ejemplo n.º 6
0
static void AdjustAndExplodeGoafPolygons( const AcDbVoidPtrArray& lines,
        const AcGePoint3dArray& polygons,
        const AcDbIntArray& polygon_counts,
        AcGePoint3dArray& spts,
        AcGePoint3dArray& epts,
        AcGeDoubleArray& dirs )
{
    for( int i = 0; i < polygon_counts.length(); i++ )
    {
        AcGePoint3dArray goaf_spts, goaf_epts;
        AcGeDoubleArray goaf_dirs;
        AdjustAndExplodeGoafPolygon( lines, polygons, polygon_counts, i, goaf_spts, goaf_epts, goaf_dirs );

        spts.append( goaf_spts );
        epts.append( goaf_epts );
        dirs.append( goaf_dirs );
    }
}
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);
    }
}
Ejemplo n.º 8
0
// 查找所有只关联一条直线的点坐标对应的分支以及方向
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] );
    }
}
Ejemplo n.º 9
0
static void GetEdgeWidths( const AcDbObjectIdArray& objIds, AcGeDoubleArray& widths )
{
    //srand ( time(NULL) );

    GambitParam gp;
    GambitParamHelper::ReadGambitParam( gp );

//	double width = 8;
    double width = gp.width;

    // 后续再修改
    // 考虑在属性数据中增加字段"巷道宽度", 读取该数据作为巷道实际宽度
    int n = objIds.length();
    for( int i = 0; i < n; i++ )
    {
        //double w = 20 + rand()%20;
        double w = width;
        widths.append( w );
    }

    //widths[0] = 100;
    //widths[1] = 40;
}
Ejemplo n.º 10
0
int CArxHelper::CreateHatch(AcDbHatch*& pHatch, const AcGePoint3dArray& arrPt,double dScale)
{
	AcGePoint2dArray vertices;
	AcGeDoubleArray bulges;
	for (int i = 0; i < arrPt.length(); ++ i)
	{
		vertices.append(arrPt.at(i).convert2d(AcGePlane::kXYPlane));
		bulges.append(0.0);
	}

	if (vertices.length() > 0)
	{
		pHatch = new AcDbHatch();
		AcGeVector3d normal(0.0, 0.0, 1.0);
		pHatch->setNormal(normal);
		pHatch->setElevation(0.0);
		pHatch->setAssociative(Adesk::kFalse);
		pHatch->setPattern(AcDbHatch::kPreDefined, _T("SOLID"));
		pHatch->appendLoop(AcDbHatch::kExternal,vertices,bulges); 
		pHatch->evaluateHatch();
		pHatch->setPatternScale(dScale);
	}
	return 0;
}