Exemplo n.º 1
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();
}
Exemplo n.º 2
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);
	}	
}
Exemplo n.º 3
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 );
    }
}
Exemplo n.º 4
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;
}
Exemplo n.º 5
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;
}
Exemplo n.º 6
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);
		}
	}
}