void InteriorPointsConstructor::printFirstInteriorPoints(int color, bool flag)
{
	int i = 1;
	int j = 0;
		
		
		AcGePoint3dArray ptArr;
		ptArr.setLogicalLength(_interiorArray[i].length()+1);
		
		
		while (j < _interiorArray[i].length())
		{
			
			ptArr[j].set(_interiorArray[i][j].x, _interiorArray[i][j].y, _interiorArray[i][j].z);
			
			
		
			j++;
		}
		ptArr[j].set(_interiorArray[0][0].x, _interiorArray[0][0].y, _interiorArray[0][0].z);
			

		AcDb3dPolyline *pNewPline = new AcDb3dPolyline(AcDb::k3dSimplePoly , ptArr, Adesk::kFalse);
		
		pNewPline->setColorIndex(color);

		AcDbBlockTable *pBlockTable;
		AcDbBlockTableRecord *pBlockTableRecord;


		acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pBlockTable, AcDb::kForRead);

		
		
		pBlockTable->getAt(ACDB_MODEL_SPACE, pBlockTableRecord, AcDb::kForWrite);


		AcDbObjectId plineObjId;
		pBlockTableRecord->appendAcDbEntity(plineObjId, pNewPline);
		
		pBlockTable->close();
		pBlockTableRecord->close();

		//pNewPline->setLayer(_T("0"));
		//pNewPline->setClosed(Adesk::kFalse);
		pNewPline->close();
		//}
		//delete pNewPline;
		
	
	
}
Example #2
0
void
createPolyline()
{
    // Set four vertex locations for the pline.
    //
    AcGePoint3dArray ptArr;
    ptArr.setLogicalLength(4);
    for (int i = 0; i < 4; i++) {
        ptArr[i].set((double)(i/2), (double)(i%2), 0.0);
    }

    // Dynamically allocate an AcDb2dPolyline object,
    // given four vertex elements whose locations are supplied
    // in ptArr.  The polyline has no elevation, and is
    // explicitly set as closed.  The polyline is simple;
    // that is, not curve fit or a spline.  By default, the
    // widths are all 0.0 and there are no bulge factors.
    //
    AcDb2dPolyline *pNewPline = new AcDb2dPolyline(
        AcDb::k2dSimplePoly, ptArr, 0.0, Adesk::kTrue);

    pNewPline->setColorIndex(3);

    // Get a pointer to a Block Table object.
    //
    AcDbBlockTable *pBlockTable;
    acdbHostApplicationServices()->workingDatabase()
        ->getSymbolTable(pBlockTable, AcDb::kForRead);

    // Get a pointer to the MODEL_SPACE BlockTableRecord.
    //
    AcDbBlockTableRecord *pBlockTableRecord;
    pBlockTable->getAt(ACDB_MODEL_SPACE, pBlockTableRecord,
        AcDb::kForWrite);

    pBlockTable->close();

    // Append the pline object to the database and
    // obtain its Object ID.
    //
    AcDbObjectId plineObjId;
    pBlockTableRecord->appendAcDbEntity(plineObjId,
        pNewPline);

    pBlockTableRecord->close();

    // Make the pline object reside on layer "0".
    //
    pNewPline->setLayer("0");

    pNewPline->close();
}
//addded by linlin 20050819
Acad::ErrorStatus  PDSphere::getVertices(int Precision, AcGePoint3dArray& vertexArray, AcGeVector3dArray &vertexNors) const
{  
	assertReadEnabled();

	int actPrecision__1 = Precision + 1;   
	int actPrecision___2__1 = Precision * 2 + 1;   
	vertexArray.setLogicalLength(actPrecision__1*actPrecision___2__1);
	vertexNors.setLogicalLength(actPrecision__1*actPrecision___2__1);


	AcGePoint3d varPt = m_ptCenter;        //变截面的中心点
	double varR = 0;
	double deltaAngle = PI / Precision;

	/////////////////////////////////////////////////////////////
	///////		begin the division						/////////
	AcGePoint3d point;

	for(int i = 0; i < actPrecision__1; ++i)
	{
		varPt.z=m_ptCenter.z- m_dRadius*cos(deltaAngle*i);

		varR = m_dRadius * sin(deltaAngle * i);
		int j;
		for(j = 0; j <actPrecision___2__1; ++j)
		{		  
			if(i == 0)
			{
				point = m_ptCenter;
				point.z -= m_dRadius;
			}
			else	 if(i == actPrecision__1)
			{ 
				point = m_ptCenter;
				point.z += m_dRadius;
			}         
			else
			{ 
				point=varPt;
				point.x += varR;
				point.rotateBy(deltaAngle * j, AcGeVector3d(0, 0, 1), varPt);
			}  	
			vertexArray[i*actPrecision___2__1+j]=point;
			vertexNors[i*actPrecision___2__1+j] = point - m_ptCenter;
		}
	}
	return Acad::eOk;
}//addded by linlin 20050819
/////////////////////////////////////////////////////////////////
//////	求两端圆并进行剖分,将得到的离散放到引用树组中		/////
/////////////////////////////////////////////////////////////////
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;
}
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) ;
}
////////////////////////////////////////////////////////////////////////////////
///////		将球在圆上分成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;
}
void InteriorPointsConstructor::printInteriorPoints(int color, bool flag)
{
	int i = 0;

	

	while (i < _contourArray->length()/2 + 1)
	{
		int j = 0;
		
		
		AcGePoint3dArray ptArr;

		if ((flag)|| (_interiorArray[i].length() <2)) ptArr.setLogicalLength(_interiorArray[i].length());
		else  ptArr.setLogicalLength(_interiorArray[i].length()-1);
		
		if ((flag)|| (_interiorArray[i].length() < 2))
		while (j < _interiorArray[i].length())
		{
			
			ptArr[j].set(_interiorArray[i][j].x, _interiorArray[i][j].y, _interiorArray[i][j].z);
			

		
			j++;
		}
		else
		{
				while (j < _interiorArray[i].length()-2)
				{
			
						ptArr[j].set(_interiorArray[i][j].x, _interiorArray[i][j].y, _interiorArray[i][j].z);
						if (sqrt(_interiorArray[i][j].x*_interiorArray[i][j].x + _interiorArray[i][j].y*_interiorArray[i][j].y + _interiorArray[i][j].z*_interiorArray[i][j].z) < 100)
							acutPrintf(_T("The shitty: %d, %d\n"), i, j);

		
				j++;
				}
				j++;
				ptArr[j].set(_interiorArray[i][j].x, _interiorArray[i][j].y, _interiorArray[i][j].z);
			
		}
		//if (i == 10){
		AcDb3dPolyline *pNewPline = new AcDb3dPolyline(AcDb::k3dSimplePoly , ptArr, Adesk::kFalse);
		
		pNewPline->setColorIndex(color);

		AcDbBlockTable *pBlockTable;
		AcDbBlockTableRecord *pBlockTableRecord;


		acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pBlockTable, AcDb::kForRead);

		
		
		pBlockTable->getAt(ACDB_MODEL_SPACE, pBlockTableRecord, AcDb::kForWrite);


		AcDbObjectId plineObjId;
		pBlockTableRecord->appendAcDbEntity(plineObjId, pNewPline);
		
		pBlockTable->close();
		pBlockTableRecord->close();

		//pNewPline->setLayer(_T("0"));
		//pNewPline->setClosed(Adesk::kFalse);
		pNewPline->close();
		//}
		//delete pNewPline;
		
		i++;
	}
}