static AcGePoint3d ProjectPointOfTwoLine( const AcGePoint3d& spt1, const AcGePoint3d& ept1,
        const AcGePoint3d& spt2, const AcGePoint3d& ept2,
        const AcGePoint3d& pt )
{
    // 计算点在直线spt1->ept1上的比例关系
    double c = pt.distanceTo( spt1 ) / ept1.distanceTo( spt1 );

    acutPrintf( _T( "\n比例c:%.4f" ), c );
    acutPrintf( _T( "\nspt->(%.3f, %.3f), ept->(%.3f, %.3f)" ), spt2.x, spt2.y, ept2.x, ept2.y );
    AcGeVector3d v = ept2 - spt2;
    return spt2 + v * c;
}
void CreatePipe( const AcGePoint3d& start, const AcGePoint3d& end, const double& radius)
{
	acutPrintf(L"开始绘制管体\n");

	//得到线段的长度
	double length = start.distanceTo(end);
	if( length < 0.1 )
		return;

	acutPrintf(L"得到管体高度%lf\n",length);

	//绘制圆柱体
	AcDb3dSolid* p3dPipe = CreateCylinder(radius,length);
	if( p3dPipe == NULL )
		return;

	//得到线段与Z轴的垂直向量
	AcGeVector3d line3dVector(end.x - start.x,end.y - start.y, end.z-start.z);
	AcGeVector3d rotateVctor = line3dVector.crossProduct(AcGeVector3d::kZAxis);

	//得到旋转的角度
	double angle = -line3dVector.angleTo(AcGeVector3d::kZAxis);
	acutPrintf(L"得到旋转角度%lf\n",angle);

	//进行旋转
	AcGeMatrix3d rotateMatrix = AcGeMatrix3d::rotation( angle, rotateVctor, AcGePoint3d::kOrigin);
	p3dPipe->transformBy(rotateMatrix);
	
	//得到线段的中心点
	AcGePoint3d center(start.x + end.x, start.y + end.y, start.z + end.z); 
	center /= 2;
	acutPrintf(L"得到中心点[%lf][%lf][%lf]\n",center.x,center.y,center.z);

	//进行偏移
	AcGeMatrix3d moveMatrix;
	moveMatrix.setToTranslation(AcGeVector3d(center.x,center.y,center.z));

	p3dPipe->transformBy(moveMatrix);

	//加入到3D模型中
	PostToModelSpace(p3dPipe);

#ifdef DEBUG
	acutPrintf(L"插入中心线,用于矫正");

	AcDbLine *pLine = new AcDbLine(start, end);
    PostToModelSpace(pLine);
#endif
}
Exemple #3
0
static double CaclWSGas( double q, const AcGePoint3d& spt, const AcGePoint3d& ept )
{
    return q / ( spt.distanceTo( ept ) );
}
double PDEcone::getHeight() const
{
	assertReadEnabled();
	AcGePoint3d orthoPt = getStartPtOrthoInEntPtPlane();
	return orthoPt.distanceTo(m_ptStart);
}