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);
    }
}
Ejemplo n.º 2
0
void WritePorousDataFile( const CString& filepath,
                          const AcGePoint3dArray& press_spts,
                          const AcGePoint3dArray& press_epts,
                          const AcGeDoubleArray& press_dirs )
{
    CStdioFile outfile;
    outfile.Open( filepath, CFile::modeCreate | CFile::modeWrite );

    // 写入个数
    CString str;
    str.Format( _T( "%d\n" ), press_dirs.length() );
    outfile.WriteString( str );

    // 写入方向以及中心点坐标
    for( int i = 0; i < press_dirs.length(); i++ )
    {
        str.Format( _T( "%.4f\n" ), press_dirs[i] );

        AcGeVector3d v = press_epts[i] - press_spts[i];
        AcGePoint3d pt = press_spts[i] + v * 0.5;
        str.AppendFormat( _T( "%.4f\t%.4f\t%.4f\n" ), pt.x, pt.y, pt.z );
        outfile.WriteString( str );
    }

    outfile.Close();
}
Ejemplo n.º 3
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();
}
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.º 5
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.º 6
0
/////////////////////////////////////////////////////////////////
//////	求两端圆并进行剖分,将得到的离散放到引用树组中		/////
/////////////////////////////////////////////////////////////////
Acad::ErrorStatus PDEcone::getVertices(int Precision, AcGePoint3dArray& vertexArray, 
                                       AcGeIntArray &stdIdx, int &actPrecision) const
{
    assertReadEnabled();
    AcGeDoubleArray dividDbl;
    getActDivid(Precision, dividDbl, stdIdx);

    int actPrecision__1 = dividDbl.length();
    actPrecision = actPrecision__1 - 1;
    vertexArray.setLogicalLength(actPrecision__1 * 2);

    AcGeVector3d vect = getFaceVect();

    AcGeVector3d Wy(0, 1, 0), Wz(0, 0, 1), Ax;// Ay;
    if (fabs(vect[X]) <1.0/64 && fabs(vect[Y])<1.0/64) 
        Ax = Wy.crossProduct(vect);
    else
        Ax = Wz.crossProduct(vect);
    Ax.normalize();
    //Ay = vect.crossProduct(Ax);
    //Ay.normalize();

    AcGeVector3d AxE = Ax * m_dDiameter2 / 2.0;
    Ax *= m_dDiameter1 / 2.0;
    double rotateAngPre = PI * 2.0 / Precision;

    vertexArray[0] = m_ptStart + Ax;
    vertexArray[actPrecision__1] = m_ptEnd + AxE;
    AcGeVector3d VecSTemp, VecETemp;
    int i;
    for(i = 1; i < actPrecision; ++i)
    {
        VecSTemp = Ax;
        VecETemp = AxE;
        VecSTemp.rotateBy(rotateAngPre * dividDbl[i], vect);
        VecETemp.rotateBy(rotateAngPre * dividDbl[i], vect);
        vertexArray[i] = m_ptStart + VecSTemp;
        vertexArray[i + actPrecision__1] = m_ptEnd + VecETemp;
    }
    vertexArray[actPrecision] = vertexArray[0];
    vertexArray[actPrecision + actPrecision__1] = vertexArray[actPrecision__1];

	return Acad::eOk;
}
Ejemplo n.º 7
0
void Additional_Class::TransFrom( AcGeDoubleArray LineLength, LINEINFO &LengthStr)
{
	for (int index=0; index<LineLength.length(); index++)
	{
		double tempDouble;
		tempDouble = LineLength[index];
		CString tempStr;
		tempStr.Format(_T("%.2f"),tempDouble);
		LengthStr.push_back(tempStr);
	}	
}
Ejemplo n.º 8
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);
}
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.º 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;
}
Ejemplo n.º 11
0
static void DrawFill( const CString& layer, AcGePoint3dArray& bound, const AcGePoint3dArray& pts, const AcGeDoubleArray& zValues, const AcArray<COLORREF>& colors, BOOL bFillColor )
{
    // 删除图层上的所有等值线填充图元
    AcDbObjectIdArray objIds;
    ContourHelper::GetContourGEOnLayer( layer, _T( "ContourFill" ), objIds );
    ArxEntityHelper::EraseObjects2( objIds, true );

    if( bFillColor && colors.length() > zValues.length() )
    {
        // 临时切换图层, 如果图层不存在, 则新建图层
        LayerSwitch ls( layer, true );

        // 绘制等值线填充
        ContourHelper::DrawCountourFill( bound, pts, zValues, colors );
    }
}
Ejemplo n.º 12
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 );
    }
}
Ejemplo n.º 13
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.º 14
0
void ContourColorDlg::FillColorList( const AcGeDoubleArray& zValues, const AcArray<COLORREF>& colors )
{
    DeleteColorListItemDatas();
    AddColorListColumns();

    // 额外增加一个z值(表示最大z值之后的范围)
    AcGeDoubleArray new_zValues;
    new_zValues.append( zValues );
    new_zValues.append( zValues.last() );

    int n = new_zValues.length();
    for( int i = 0; i < n; i++ )
    {
        m_colorList.InsertItem( i, _T( "xx" ) );

        CString str;
        if( i == 0 )
        {
            str.Format( _T( "<%.3f" ), new_zValues[i] );
        }
        else if( i == n - 1 )
        {
            str.Format( _T( ">%.3f" ), new_zValues[i - 1] );
        }
        else
        {
            str.Format( _T( "%.3f ~ %.3f" ), new_zValues[i - 1], new_zValues[i] );
        }
        m_colorList.SetItemText( i, 0, str );
        m_colorList.SetItemText( i, 1, _T( "填充颜色" ) );

        COLORREF rgb = GetColorRGB( colors, i );
        m_colorList.SetCellColors( i, 1, rgb, -1 );

        ColorListItemData* pData = new ColorListItemData();
        pData->z = new_zValues[i];
        pData->rgb = rgb;;
        m_colorList.SetItemData( i, ( DWORD_PTR )pData );
    }
}
Ejemplo n.º 15
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;
}
Acad::ErrorStatus
getUniformKnots(int numCtrlPts, int degree, int form, AcGeDoubleArray& knots)
{
    Acad::ErrorStatus ecode = Acad::eOk;
    int i, nspans;

    nspans = numCtrlPts - degree; 

    knots.setLogicalLength(nspans + (2*degree) + 1);

    double dt = 1.0; // (tn - t0) / n. Usually tn = n and t0 = 0

    for (i = 0; i < degree; i++) {
        if (form == 2) {
            knots[i] = -(degree - i) * dt;
        } else { 
            knots[i] = 0.0;
	}
    }

    knots[degree] = 0.0;
    for (i = degree + 1; i < nspans + degree + 1; i++) {
        knots[i] = knots[i - 1] + dt; 
    }

    for (i = 1; i <= degree; i++) {
        if (form == 2) {
            knots[nspans + degree + i] = 
		knots[nspans + degree] + i * dt;
        } else {
            knots[nspans + degree + i] = knots[nspans + degree]; 
	}
    }

    return ecode;
}
Ejemplo n.º 17
0
////////////////////////////////////////////////////////////////////////////////
///////		将球在圆上分成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;
}
Ejemplo n.º 18
0
void Additional_Class::Get_PolyLineFirst( CString First_P, AcGeDoubleArray LineLengthList, LINEINFO &First_List )
{
	AcGeDoubleArray Total_Length;
	int num = LineLengthList.length();
	for (int index=0; index<num; index++)
	{
		double total_temp = 0;
		for (int i =0; i<=index; i++)
		{
			total_temp = total_temp + LineLengthList[i];
		}
		Total_Length.append(total_temp);
	}
	//////////////////////////////////////////////////////////////////////////
	num = Total_Length.length();
	for (int index=0; index<num; index++)
	{
		double temp_Double;
		temp_Double = Total_Length[index];
		CString temp_CStr;
		temp_CStr.Format(_T("%.2f"),temp_Double);
		int temp_CStr_len = temp_CStr.GetLength();
		if (temp_CStr_len > 6)
		{
			CString temp_String;
			int Num_P = temp_CStr_len-6;
			for (int ro=0; ro<Num_P; ro++)
			{
				CString tt = temp_CStr.GetAt(ro);
				temp_String.Append(tt);
				//temp_String.Insert(0,temp_CStr.GetAt(ro));
			}

			CString Last_String;
			for (int ro = Num_P; ro<temp_CStr_len; ro++)
			{
				CString tt = temp_CStr.GetAt(ro);
				Last_String.Append(tt);
			}
			Last_String.Insert(0,_T("+"));
			int temp_len = temp_String.GetLength();
			CString result_String;
			int x = 0;
			for (int index=0;index<temp_len;index++)
			{
				int roo = x/3;
				if (roo == 1)
				{
					CString tempt = temp_String.GetAt(temp_len-index-1);
					result_String.Insert(0,_T("+"));
					result_String.Insert(0,tempt);
					x=0;
				}
				CString temptt = temp_String.GetAt(temp_len-index-1);
				result_String.Insert(0,temptt);
				x = x+1;
			}

			result_String.Insert(0,First_P);
			result_String.Append(Last_String);
			First_List.push_back(result_String);
		}//////////////////////////////////////////////////////////////////////////
		else
		{
			int Num_S = 5 - temp_CStr_len;
			CString Zero;
			Zero.Append(First_P);
			Zero.Append(_T("0+"));
			for (int num_roo=0; num_roo<=Num_S; num_roo++)
			{
				Zero.Append(_T("0"));
			}
			Zero.Append(temp_CStr);
			First_List.push_back(Zero);
		}
	}
}