Example #1
0
void DrawRect( AcGiWorldDraw* mode, const AcGePoint3d& insertPt, double angle, double width, double height, bool fill )
{
    AcGiSubEntityTraits& traits = mode->subEntityTraits();

    AcGeVector3d v1( AcGeVector3d::kXAxis ), v2( AcGeVector3d::kXAxis );
    v1.rotateBy( angle, AcGeVector3d::kZAxis );
    v2.rotateBy( angle + PI / 2, AcGeVector3d::kZAxis );

    AcGePoint3dArray pts;
    pts.append( CaclPt( insertPt, v1, width, v2, height ) );

    v1.rotateBy( PI, AcGeVector3d::kZAxis );
    pts.append( CaclPt( insertPt, v1, width, v2, height ) );

    v2.rotateBy( PI, AcGeVector3d::kZAxis );
    pts.append( CaclPt( insertPt, v1, width, v2, height ) );

    v1.rotateBy( PI, AcGeVector3d::kZAxis );
    pts.append( CaclPt( insertPt, v1, width, v2, height ) );

    // 是否填充
    AcGiFillType ft = traits.fillType();
    traits.setFillType( fill ? kAcGiFillAlways : kAcGiFillNever );

    mode->geometry().polygon( pts.length(), pts.asArrayPtr() );

    traits.setFillType( ft );
}
Example #2
0
Adesk::Boolean SingleTunnelDraw::subWorldDraw( AcGiWorldDraw* mode )
{
    assertReadEnabled () ;

    AcGePoint3dArray pts;
    pts.append( m_startPt );
    pts.append( m_endPt );
    mode->geometry().worldLine( pts.asArrayPtr() );

    return Adesk::kTrue;
}
static void DrawLinePoints( AcGiWorldDraw* mode, const AcGePoint3dArray& pts )
{
    int len = pts.length();
    for( int i = 0; i < len - 1; i++ )
    {
        AcGePoint3dArray tpts;
        tpts.append( pts[i] );
        tpts.append( pts[i + 1] );
        mode->geometry().worldLine( tpts.asArrayPtr() );
    }
}
Example #4
0
void DrawPolygon( AcGiWorldDraw* mode, const AcGePoint3dArray& polygon, bool fill )
{
    AcGiSubEntityTraits& traits = mode->subEntityTraits();

    // 是否填充
    AcGiFillType ft = traits.fillType();
    traits.setFillType( fill ? kAcGiFillAlways : kAcGiFillNever );

    mode->geometry().polygon( polygon.length(), polygon.asArrayPtr() );

    traits.setFillType( ft );
}
Example #5
0
void DrawCross( AcGiWorldDraw* mode, const AcGePoint3d& pt, double radius )
{
    AcGeVector3d v( AcGeVector3d::kXAxis );
    v *= radius;

    for( int i = 0; i < 4; i++ )
    {
        AcGePoint3dArray pts;
        pts.append( pt );
        pts.append( pt + v );
        mode->geometry().worldLine( pts.asArrayPtr() );

        v.rotateBy( PI / 2, AcGeVector3d::kZAxis );
    }
}
Example #6
0
void DrawRect( AcGiWorldDraw* mode, const AcGePoint3d& pt, double angle, double width, double height, bool fill )
{
    AcGiSubEntityTraits& traits = mode->subEntityTraits();

    AcGePoint3dArray pts;
    BuildRect( pt, angle, width, height, pts );

    // 是否填充
    AcGiFillType ft = traits.fillType();
    traits.setFillType( fill ? kAcGiFillAlways : kAcGiFillNever );

    mode->geometry().polygon( pts.length(), pts.asArrayPtr() );

    traits.setFillType( ft );
}
void asdktest6 () {
    int nPoints =8 ;
    int nTriangles =12 ;
    int nIndices =3 * nTriangles ;

    double p [] ={
        0, 0, 0,
        1, 0, 0,
        1, 1, 0,
        0, 1, 0,
        0, 0, 1,
        1, 0, 1,
        1, 1, 1,
        0, 1, 1
    } ;

    int i [] ={
        0, 1, 5,    0, 5, 4,
        1, 6, 5,    1, 2, 6,
        4, 5, 6,    4, 6, 7,
        7, 0, 4,    7, 3, 0,
        2, 0, 3,    2, 1, 0,
        7, 6, 3,    6, 2, 3
    } ;

    AcGeIntArray indices (nIndices) ;
    indices.setLogicalLength (nIndices) ;
    indices.setPhysicalLength (nIndices) ;
    memcpy (indices.asArrayPtr (), i, nIndices * sizeof (int)) ;

    AcGePoint3dArray gePts (nPoints) ;
    gePts.setLogicalLength (nPoints) ;
    gePts.setPhysicalLength (nPoints) ;
    memcpy (gePts.asArrayPtr (), p, nPoints * sizeof (AcGePoint3d)) ;

    void *acisBody =createBodyFromTriangles (gePts, indices) ;
    AcDb3dSolid *b =new AcDb3dSolid ;
    b->setASMBody(acisBody);
        
    AcDbObjectId id ;
    postToDatabase (NULL, b, id) ;
}
Adesk::Boolean PDSphere::worldDraw(AcGiWorldDraw* mode)
#endif
{
	assertReadEnabled();
	//if(acdbHostApplicationServices()->workingDatabase()->useri1() == 1)
	//	return Adesk::kTrue;

#ifdef _USEAMODELER_
#ifdef _OBJECTARX2010_
	PDPrimary3D::subWorldDraw(mode);
#else
	PDPrimary3D::worldDraw(mode);
#endif
#endif
	if (mode->regenAbort()) {
		return Adesk::kTrue;
	}
#ifndef _USEAMODELER_
	int Precision = m_dDividPrecision;
	Adesk::Int16 nRating = getCalMaxPrecision();

	if(nRating == PRIMARY3D_SIMPLIZE_RATE1 ||
		nRating == PRIMARY3D_SIMPLIZE_RATE2)
	{
		Precision = (int)	(PI / acos(1.0 - mode->deviation(kAcGiMaxDevForCircle, m_ptCenter) / m_dRadius));
		if(Precision < PRIMARY3D_SIMPLIZE_SCALE)
		{
			if (nRating == PRIMARY3D_SIMPLIZE_RATE2)
			{
				AcGePoint3d pts[2];
				pts[0] = pts[1] = m_ptCenter;
				mode->geometry().polyline(2,pts);
			}
			else if (nRating == PRIMARY3D_SIMPLIZE_RATE1)
			{
				//Precision = PRIMARY3D_WIREFRAME_LINENUM4;
				//getVertices(Precision, pArray, vertexNors);
				//actPrecision__1 = Precision + 1;
				if(mode -> geometry().circle( m_ptCenter,m_dRadius,AcGeVector3d(1,0,0)))
					return Adesk::kTrue;
				if(mode -> geometry().circle( m_ptCenter,m_dRadius,AcGeVector3d(1,1,0)))
					return Adesk::kTrue;
				if(mode -> geometry().circle( m_ptCenter,m_dRadius,AcGeVector3d(0,1,0)))
					return Adesk::kTrue;
				if(mode -> geometry().circle( m_ptCenter,m_dRadius,AcGeVector3d(-1,1,0)))
				{
					return Adesk::kTrue;
				}
				if(mode -> geometry().circle( m_ptCenter,m_dRadius,AcGeVector3d(0,0,1)))
				{
					return Adesk::kTrue;
				}
				if(mode -> geometry().circle( m_ptCenter - AcGeVector3d(0, 0, 1) * m_dRadius * cos(PI / 4.0),m_dRadius * sin(PI / 4.0),AcGeVector3d(0,0,1)))
				{
					return Adesk::kTrue;
				}
				mode -> geometry().circle( m_ptCenter + AcGeVector3d(0, 0, 1) * m_dRadius *  cos(PI / 4.0),m_dRadius * sin(PI / 4.0),AcGeVector3d(0,0,1));
			}
			Adesk::kTrue;
		}
	}
#ifndef _ALWAYSSHOWWIRE_	
	switch(mode->regenType())
	{
	case kAcGiHideOrShadeCommand:
	case kAcGiRenderCommand:
#endif
		{
			int PreStep = 1;	
			AcGePoint3dArray pArray;
			AcGeVector3dArray vertexNors;
			int actPrecision__1 = Precision + 1;
			if(Precision < PRIMARY3D_WIREFRAME_LINENUM * 2)
				Precision = PRIMARY3D_WIREFRAME_LINENUM;
			else
			{
				if(Precision > m_dDividPrecision)
					Precision = m_dDividPrecision;
				PreStep = Precision / PRIMARY3D_WIREFRAME_LINENUM;
				Precision = PreStep * PRIMARY3D_WIREFRAME_LINENUM;
			}
			getVertices(Precision, pArray, vertexNors);
			actPrecision__1 = Precision + 1;
			AcGiEdgeData edgeData;
			int edgeDataLen = Precision * 2 * (actPrecision__1)* 2;
			Adesk::UInt8* edgeVisibility = new Adesk::UInt8[edgeDataLen];
			int i, j;
			for(i = 0; i < edgeDataLen; ++i)
				edgeVisibility[i] = kAcGiInvisible;//kAcGiSilhouette;

// 			int actPrecision___2 = Precision * 2;
// 			for (i =0; i < actPrecision__1; i += PreStep )
// 			{
// 				for(j = 0; j < actPrecision___2; j++)
// 				{
// 					edgeVisibility[i * actPrecision___2 + j] = kAcGiVisible;
// 				}
// 			}
// 			int PrecisionArc___Cir = actPrecision__1 * Precision * 2;
// 			for (i = 0; i < actPrecision___2; i += PreStep)
// 			{	
// 				for(j = 0; j < Precision;  j ++)
// 				{
// 					edgeVisibility[PrecisionArc___Cir + i * Precision + j] = kAcGiVisible;
// 				}
// 			}
			int actPrecision___2 = Precision * 2;
 			for (i = Precision / 4; i < Precision; i += Precision / 4 )
 			{
				for(j = 0; j < actPrecision___2; j++)
				{
					edgeVisibility[i * actPrecision___2 + j] = kAcGiVisible;
				}
 			}
			int PrecisionArc___Cir = actPrecision__1 * Precision * 2;
			for (i = 0; i < actPrecision___2; i += actPrecision___2 / 8)
			{	
				for(j = 0; j < Precision;  j ++)
				{
					edgeVisibility[PrecisionArc___Cir + i * Precision + j] = kAcGiVisible;
				}
			}

			edgeData.setVisibility(edgeVisibility);

			// 因为下面代码会导致球体的render效果图不正确,所以将其注释。
			//AcGiVertexData vertexData;
			//vertexData.setNormals(vertexNors.asArrayPtr());
			//vertexData.setOrientationFlag(kAcGiCounterClockwise);
			
			//添加球面的GS标记,与线框模型的GS标记分开处理
			//added by szw 2009.11.18 : begin
			int gsIndex = 8;
			mode->subEntityTraits().setSelectionMarker(gsIndex);
			//added by szw 2009.11.18 : end

			mode->geometry().mesh(actPrecision__1,actPrecision___2 + 1,pArray.asArrayPtr(),&edgeData/*, NULL, &vertexData*/);
			delete [] edgeVisibility;
		}
#ifndef _ALWAYSSHOWWIRE_
		break;
	case kAcGiStandardDisplay:
	case kAcGiSaveWorldDrawForR12:
	case kAcGiSaveWorldDrawForProxy:
#endif
		{
			//Precision = PRIMARY3D_WIREFRAME_LINENUM;
			//getVertices(Precision, pArray, vertexNors);
			//actPrecision__1 = Precision + 1;
			int gsIndex = 0;
			mode->subEntityTraits().setSelectionMarker(++gsIndex);
			if(mode -> geometry().circle( m_ptCenter,m_dRadius,AcGeVector3d(1,0,0)))
				return Adesk::kTrue;
			mode->subEntityTraits().setSelectionMarker(++gsIndex);
			if(mode -> geometry().circle( m_ptCenter,m_dRadius,AcGeVector3d(1,1,0)))
				return Adesk::kTrue;
			mode->subEntityTraits().setSelectionMarker(++gsIndex);
			if(mode -> geometry().circle( m_ptCenter,m_dRadius,AcGeVector3d(0,1,0)))
				return Adesk::kTrue;
			mode->subEntityTraits().setSelectionMarker(++gsIndex);
			if(mode -> geometry().circle( m_ptCenter,m_dRadius,AcGeVector3d(-1,1,0)))
			{
				return Adesk::kTrue;
			}
			mode->subEntityTraits().setSelectionMarker(++gsIndex);
			if(mode -> geometry().circle( m_ptCenter,m_dRadius,AcGeVector3d(0,0,1)))
			{
				return Adesk::kTrue;
			}
			mode->subEntityTraits().setSelectionMarker(++gsIndex);
			if(mode -> geometry().circle( m_ptCenter - AcGeVector3d(0, 0, 1) * m_dRadius * cos(PI / 4.0),m_dRadius * sin(PI / 4.0),AcGeVector3d(0,0,1)))
			{
				return Adesk::kTrue;
			}
			mode->subEntityTraits().setSelectionMarker(++gsIndex);
			mode -> geometry().circle( m_ptCenter + AcGeVector3d(0, 0, 1) * m_dRadius *  cos(PI / 4.0),m_dRadius * sin(PI / 4.0),AcGeVector3d(0,0,1));
		}
#ifndef _ALWAYSSHOWWIRE_
		break;
	default:
		break;
	}
#endif
#endif
	return Adesk::kTrue;
}//added by linlin 20050819
Adesk::Boolean PDEcone::worldDraw(AcGiWorldDraw* mode)
#endif
{
	assertReadEnabled();
	//if(acdbHostApplicationServices()->workingDatabase()->useri1() == 1)
	//	return Adesk::kTrue;

#ifdef _USEAMODELER_
#ifdef _OBJECTARX2010_
	PDPrimary3D::subWorldDraw(mode);
#else
	PDPrimary3D::worldDraw(mode);
#endif
#endif
	if (mode->regenAbort()) {
		return Adesk::kTrue;
	}
#ifndef _USEAMODELER_

	AcGePoint3dArray pArray;
	int PreStep = 1;
	int actPrecision = m_dDividPrecision;
	Adesk::Int16 nRating = getCalMaxPrecision();
	int i;
	int actPrecision__1 = actPrecision +1;
	if(nRating == PRIMARY3D_SIMPLIZE_RATE2 
		|| nRating == PRIMARY3D_SIMPLIZE_RATE1)
	{
		//优化
		if(m_dDiameter1 > m_dDiameter2)
		{
			actPrecision = (int)(PI / acos(1.0 - mode->deviation(kAcGiMaxDevForCircle, m_ptStart)
				* 2.0 / m_dDiameter1));
		}
		else
		{
			actPrecision = (int)(PI / acos(1.0 - mode->deviation(kAcGiMaxDevForCircle, m_ptEnd)
				* 2.0 / m_dDiameter2));
		}
		if(actPrecision < PRIMARY3D_SIMPLIZE_SCALE)
		{
			if (nRating == PRIMARY3D_SIMPLIZE_RATE2)
			{
				AcGePoint3d pt[2];
				pt[0] = m_ptStart;
				pt[1] = m_ptEnd;
				/*if*/(mode->geometry().polyline(2, pt));
			} 
			else if(nRating == PRIMARY3D_SIMPLIZE_RATE1)
			{
				AcGeVector3d faceVect = getFaceVect();
				if(mode->geometry().circle(m_ptStart, m_dDiameter1 / 2.0, faceVect))
					return Adesk::kTrue;
				if(mode->geometry().circle(m_ptEnd, m_dDiameter2 / 2.0, faceVect))
					return Adesk::kTrue;
				actPrecision = PRIMARY3D_WIREFRAME_LINENUM4;
				getVertices(actPrecision,pArray);
				actPrecision__1 = actPrecision + 1;
				AcGePoint3d pt[2];
				for(i = 0; i < actPrecision; i += PreStep)
				{
					pt[0] = pArray[i];
					pt[1] = pArray[i + actPrecision__1];
					if(mode->geometry().polyline(2, pt))
						return Adesk::kTrue;
				}
			}
			return Adesk::kTrue;
		}
	}
#ifndef _ALWAYSSHOWWIRE_
	switch(mode->regenType())
	{
	case kAcGiStandardDisplay:
	case kAcGiSaveWorldDrawForR12:
	case kAcGiSaveWorldDrawForProxy:
#endif
		{
			int gsIndex = 0;
			AcGeVector3d faceVect = getFaceVect();
			//统一线框模型和实体模型的GS标记
			//modified by szw 2009.11.18 : begin
			mode->subEntityTraits().setSelectionMarker(++gsIndex);
			if(mode->geometry().circle(m_ptStart, m_dDiameter1 / 2.0, faceVect))
				return Adesk::kTrue;
			mode->subEntityTraits().setSelectionMarker(++gsIndex);
			if(mode->geometry().circle(m_ptEnd, m_dDiameter2 / 2.0, faceVect))
				return Adesk::kTrue;
			actPrecision = PRIMARY3D_WIREFRAME_LINENUM;
			getVertices(actPrecision,pArray);
			actPrecision__1 = actPrecision + 1;

			AcGePoint3d pt[2];
			++gsIndex;
			for(i = 0; i < actPrecision; i += PreStep)
			{
				pt[0] = pArray[i];
				pt[1] = pArray[i + actPrecision__1];
				mode->subEntityTraits().setSelectionMarker(gsIndex);
				if(mode->geometry().polyline(2, pt))
					return Adesk::kTrue;
			}
			//modified by szw 2009.11.18 : end
		}
#ifndef _ALWAYSSHOWWIRE_
		break;
	case kAcGiHideOrShadeCommand:
	case kAcGiRenderCommand:
#endif
		{
			int gsIndex = 0;
			mode->subEntityTraits().setFillType(kAcGiFillAlways);
			if(actPrecision < PRIMARY3D_WIREFRAME_LINENUM * 2)
				actPrecision = PRIMARY3D_WIREFRAME_LINENUM;
			else
			{
				if(actPrecision > m_dDividPrecision)
					actPrecision = m_dDividPrecision;
				PreStep = actPrecision / PRIMARY3D_WIREFRAME_LINENUM;
				actPrecision = PreStep * PRIMARY3D_WIREFRAME_LINENUM;
			}
			getVertices(actPrecision,pArray);
			actPrecision__1 = actPrecision + 1;
			///////////////////////////////////////////////////////
			///////		画两端面						
			///////////////////////////////////////////////////////
			//添加实体模型各面的GS标记
			//added by szw 2009.11.18 : begin
			mode->subEntityTraits().setSelectionMarker(++gsIndex);
			//added by szw 2009.11.18 : end
			if(mode->geometry().polygon(actPrecision, &pArray[0]))
				return Adesk::kTrue;
			//added by szw 2009.11.18 : begin
			mode->subEntityTraits().setSelectionMarker(++gsIndex);
			//added by szw 2009.11.18 : end
			if(mode->geometry().polygon(actPrecision, &pArray[actPrecision__1]))
				return Adesk::kTrue;

			AcGiEdgeData edgeData;
			int edgeDataLen = actPrecision__1 * 3 - 2;
			Adesk::UInt8* edgeVisibility = new Adesk::UInt8[edgeDataLen];
			for(i = 0; i < edgeDataLen; ++i)
				edgeVisibility[i] = kAcGiInvisible;//kAcGiSilhouette;
			int actPrecision___2 = actPrecision * 2;
			for(i = actPrecision___2;i < edgeDataLen; i += PreStep)
			{
				edgeVisibility[i] = kAcGiVisible;
				if(PreStep > 1 && i != edgeDataLen - 1)
				{
					for(int j = 1; j < PreStep; ++j)
						edgeVisibility[i + j] = kAcGiInvisible;
				}
			}
			edgeData.setVisibility(edgeVisibility);
			///////////////////////////////////////////////////////////
			///////画旋转曲面	
			///////////////////////////////////////////////////////////
			//added by szw 2009.11.18 : begin
			mode->subEntityTraits().setSelectionMarker(++gsIndex);
			//added by szw 2009.11.18 : end
			mode->geometry().mesh(2, actPrecision__1, pArray.asArrayPtr(), &edgeData);
			delete [] edgeVisibility;
		}
#ifndef _ALWAYSSHOWWIRE_
		break;
	default:
		break;
	}
#endif
#endif
	return Adesk::kTrue;
}