Ejemplo n.º 1
1
void aSquare()
{
	
	AsdkSquare* mySquare = new AsdkSquare();

	if( !mySquare ) {
		acutPrintf("\n Memory allocation error.");
		return;
	}

	ads_point pt1, pt2, pt3;
	struct resbuf UCS, WCS;
	
	WCS.restype = RTSHORT;
	WCS.resval.rint = 0;

	UCS.restype = RTSHORT;
	UCS.resval.rint = 1;

	acedGetPoint(NULL, "\nPick a point for the center: ", pt1);
	acedGetPoint(pt1, "\nPick a direction for corner and size: ", pt2);

	pt2[X] = pt2[X] - pt1[X];
	pt2[Y] = pt2[Y] - pt1[Y];
	pt2[Z] = pt2[Z] - pt1[Z];

	pt3[X] = pt3[Y] = 0.0;
	pt3[Z] = 1.0;

	acedTrans(pt1, &UCS, &WCS, 0, pt1);
	acedTrans(pt2, &UCS, &WCS, 1, pt2);
	acedTrans(pt3, &UCS, &WCS, 1, pt3);

	mySquare->setSquareCenter(AcGePoint3d(pt1[X],pt1[Y],pt1[Z]));
	mySquare->setSquareOrient(AcGeVector3d(pt2[X],pt2[Y],pt2[Z]));	
	mySquare->setSquareNormal(AcGeVector3d(pt3[X],pt3[Y],pt3[Z]));

	append(mySquare);

	mySquare->close();

	return;

}
Ejemplo n.º 2
0
void
makeABlock()
{
     // Create and name a new block table record.
     //
     AcDbBlockTableRecord *pBlockTableRec
         = new AcDbBlockTableRecord();
     pBlockTableRec->setName("ASDK-NO-ATTR");

     // Get the block table.
     //
     AcDbBlockTable *pBlockTable = NULL;
     acdbHostApplicationServices()->workingDatabase()
        ->getSymbolTable(pBlockTable, AcDb::kForWrite);

     // Add the new block table record to the block table.
     //
     AcDbObjectId blockTableRecordId;
     pBlockTable->add(blockTableRecordId, pBlockTableRec);
     pBlockTable->close();

     // Create and add a line entity to the component's
     // block record.
     //
     AcDbLine *pLine = new AcDbLine();
     AcDbObjectId lineId;

     pLine->setStartPoint(AcGePoint3d(3, 3, 0));
     pLine->setEndPoint(AcGePoint3d(6, 6, 0));
     pLine->setColorIndex(3);

     pBlockTableRec->appendAcDbEntity(lineId, pLine);
     pLine->close();
     pBlockTableRec->close();
}
Ejemplo n.º 3
0
PDEcone::PDEcone(bool HasSnap/* = false*/) : PDPrimary3D(HasSnap)
{
	m_dDiameter1 = m_dDiameter2 = 1.0;
	m_ptStart = AcGePoint3d (0, 0, 0);
	m_ptEnd = AcGePoint3d (0, 0, 1);
	m_dDividPrecision = PRIMARY3D_DEFAULT_PRECISION;
	m_vect.set(1, 0, 0);
#ifdef _USEAMODELER_
    createBody();
#endif
}
Ejemplo n.º 4
0
void asdkBolt::createSolids()
{
	Acad::ErrorStatus es;
	if(pHead) {
		delete pHead;
		pHead = new AcDb3dSolid;
	}
	if(pShaft) {
		delete pShaft;
		pShaft = new AcDb3dSolid;
	}

	pHead->setDatabaseDefaults();
	pShaft->setDatabaseDefaults();
	
	// Create the Bolt Head
	// Perimeter = 2n r sin(Pi/n)=2n r tan(Pi/n)
	double edgeLength=(2*headSides * headDiameter * sin(PI/headSides))/headSides;
	double inscribedDiameter=sqrt(pow(edgeLength/2,2)+pow(headDiameter/2,2));
	double vertexAngle=PI2/headSides;

	AcDb3dPolyline *pPoly=new AcDb3dPolyline;
	pPoly->setDatabaseDefaults();
	double startAngle=vertexAngle/2;
	for(int c=0;c<headSides;c++)
	{
		AcDb3dPolylineVertex *pVertex=new AcDb3dPolylineVertex(AcGePoint3d(sin(startAngle)*inscribedDiameter,cos(startAngle)*inscribedDiameter,0));
		pPoly->appendVertex(pVertex);
		startAngle+=vertexAngle;
	}
	pPoly->makeClosed();
	
	AcDbVoidPtrArray curves,regions,shaftRegions,shaftCurves;
	curves.append(pPoly);

	// Error here!!
	es=AcDbRegion::createFromCurves(curves,regions);// Create the region...note:	static member function.
	es=pHead->extrude((AcDbRegion*)(regions[0]),headHeight,0);
	//delete regions[0];
	delete pPoly;
		
	// Now make the shaft...
	AcDbCircle *pCircle=new AcDbCircle(AcGePoint3d(0,0,headHeight),AcGeVector3d(0,0,1),shaftDiameter/2);
	shaftCurves.append(pCircle);
	es=AcDbRegion::createFromCurves(shaftCurves,shaftRegions);// Create the region...note:	static member function.
	es=pShaft->extrude((AcDbRegion*)(shaftRegions[0]),shaftLength,0);
	//delete shaftRegions[0];
	delete pCircle;
}
Ejemplo n.º 5
0
asdkBolt::asdkBolt()
{
	//{{AFX_ARX_DATA_INIT(asdkBolt)
	//}}AFX_ARX_DATA_INIT

	pHead=NULL;
	pShaft=NULL;
	alignment=AcGeVector3d(0,0,1);
	position=AcGePoint3d(0,0,0);

	pHead=new AcDb3dSolid;
	pShaft=new AcDb3dSolid;

	// Default Values...
	headSides=6;
	headHeight=2.0f;
	shaftLength=10.0f;
	threadLength=3.0f;
	threadWidth=.2f;
	headDiameter=5.0f;
	shaftDiameter=3.0f;

	createSolids();

}
Ejemplo n.º 6
0
// ----------------------------------------------------------------------------
// Constructor.
//
CRectInfo::CRectInfo()
{
    m_topLeftCorner = AcGePoint3d();
    m_first = m_second = m_bulge = m_elev = m_thick = m_width = m_radius = 0.0;
    m_cornerTreatment = FALSE;
    m_elevHandSet = FALSE;
}
Ejemplo n.º 7
0
//-----------------------------------------------------------------------------
//----- This is the Custom Entity Implementation
OarxEmployee::OarxEmployee () : AcDbEntity () {
	mID =-1 ;
	mCubeNumber =-1 ;
	mFirstName =NULL ;
	mLastName =NULL ;
	mCenter =AcGePoint3d () ;
}
Ejemplo n.º 8
0
PDSphere::PDSphere(bool HasSnap/* = false*/) : PDPrimary3D(HasSnap)
{
	m_dRadius =1.0;
	m_ptCenter = AcGePoint3d();

	m_dDividPrecision = PRIMARY3D_DEFAULT_PRECISION;
}
Ejemplo n.º 9
0
void PDEcone::setDefault()
{
  PDPrimary3D::setDefault();
#if defined(NDEBUG) || !defined(_DEBUG)
  m_dDiameter1 = m_dDiameter2 = 1.0;
  m_ptStart = AcGePoint3d (0, 0, 0);
  m_ptEnd = AcGePoint3d (0, 0, 1);
  m_dDividPrecision = PRIMARY3D_DEFAULT_PRECISION;
  m_vect.set(1, 0, 0);
#else
  m_dDiameter1 = m_dDiameter2 = 1000;
  m_ptStart = AcGePoint3d (0, 0, 0);
  m_ptEnd = AcGePoint3d (0, 0, 1000);
  m_dDividPrecision = PRIMARY3D_DEFAULT_PRECISION;
  m_vect.set(1, 0, 0);
#endif
}
Ejemplo n.º 10
0
void PDSphere::setDefault()
{
	PDPrimary3D::setDefault();
#if defined(NDEBUG) || !defined(_DEBUG)
	m_dRadius =1.0;
	m_ptCenter = AcGePoint3d();
#else
	m_dRadius =1000;
	m_ptCenter.set(0,0,0);
#endif
}
void 
AsdkBodyAModelerCallBack::outputTriangle(Edge* edges[], int numSides)
{
    if (!m_pCurWorldDraw)
        return;

    // 
    // assume, the numSide must be < 5
    // 
    if (numSides < 3 || numSides > 4)   
        return;

    AcGePoint3d points[4];
    Adesk::UInt32 face_list_size = 1 + numSides;
    Adesk::Int32* face_list = new Adesk::Int32[face_list_size];
    AcGiEdgeData edge_data;
    Adesk::UInt8* edge_vis_array = new Adesk::UInt8[numSides];
    face_list[0] = numSides;
    for (int i = 0; i < numSides; ++i)
    {
        points[i] = AcGePoint3d(edges[i]->point().x, 
            edges[i]->point().y, edges[i]->point().z);
                                                                                
        face_list[i+1] = i;
        if (edges[i]->next() != edges[(i+1)%numSides] 
            || edges[i]->isFlagOn(BEF)) 
        {
            // 
            // triangle edge 
            // 
            edge_vis_array[i] = kAcGiInvisible;
        }
        else if (edges[i]->isFlagOn(AEF))
        {
            edge_vis_array[i] = kAcGiSilhouette;
        }
        else
        {
            edge_vis_array[i] = kAcGiVisible;
        }
    }
    edge_data.setVisibility(edge_vis_array);

    // 
    // set color
    // Need to figure out wall side to assign correct color
    // 
    m_pCurWorldDraw->geometry().shell(numSides, points, face_list_size, 
        face_list, &edge_data);

    delete [] face_list;
    delete [] edge_vis_array;
}
Ejemplo n.º 12
0
void createDatabase()
{
	// Create a new Database.
	AcDbDatabase *pDb = new AcDbDatabase();

	// Get the BlockTable.
	AcDbBlockTable *pBTable = NULL;
	pDb->getSymbolTable(pBTable, AcDb::kForRead);

	// Get the ModelSpace.
	AcDbBlockTableRecord *pRecord = NULL;
	pBTable->getAt(ACDB_MODEL_SPACE, pRecord, AcDb::kForWrite);
	pBTable->close();

	// Create a new Circle.
	AcDbCircle *pCircle1 = new AcDbCircle(AcGePoint3d(100,100,0),
		AcGeVector3d(0,0,1),
		50.0);
	// Create another new Circle.
	AcDbCircle *pCircle2 = new AcDbCircle(AcGePoint3d(200,200,0),
		AcGeVector3d(0,0,1),
		30.0);

	// Append Circle1 to ModelSpace
	pRecord->appendAcDbEntity(pCircle1);
	pCircle1->close();

	// Append Circle2 to ModelSpace
	pRecord->appendAcDbEntity(pCircle2);
	pCircle2->close();

	pRecord->close();

	// Save to file
	// MUST append a DWG file extension.
	acutPrintf(_T("\nSave file to \"d:\\temp\\testfile.dwg\"."));
	pDb->saveAs(_T("d:\\temp\\testfile.dwg"));

	delete pDb;
}
Ejemplo n.º 13
0
void generateCutRegion(AcDb3dSolid* pSolid, int offset, int direction)
{
	//创建切面
	AcGePlane plane;

	if( direction == 1)
		plane.set(AcGePoint3d(offset,0,0),AcGeVector3d(1,0,0));
	else if( direction == 2)
		plane.set(AcGePoint3d(0,offset,0),AcGeVector3d(0,1,0));
	else if( direction == 3)
		plane.set(AcGePoint3d(0,0,offset),AcGeVector3d(0,0,1));

	//得到实体与切面相切的截面
	AcDbRegion *pSelectionRegion = NULL;
	pSolid->getSection(plane, pSelectionRegion);

	//将其移动到YZ平面
	//moveToBottom(pSelectionRegion);

	//将截面加入到模型空间
	PostToModelSpace(pSelectionRegion);
}
Ejemplo n.º 14
0
AcDbObjectId CSDCIDlg::createObject()
{
    AcDbObjectId objId;

    CSDCI* pCSDCI = CreateCSDCI( AcGePoint3d( m_xPos, m_yPos, m_zPos ) );
    if( ArxUtilHelper::PostToModelSpace( pCSDCI ) )
    {
        objId = pCSDCI->objectId();
        pCSDCI->close();
    }
    else
    {
        delete pCSDCI;
    }
    return objId;
}
Ejemplo n.º 15
0
AcDbObjectId TGFPDlg::createObject()
{
    AcDbObjectId objId;

    TGFP* pTGFP = CreateTGFP( AcGePoint3d( m_xPos, m_yPos, m_zPos ) );
    if( ArxUtilHelper::PostToModelSpace( pTGFP ) )
    {
        objId = pTGFP->objectId();
        pTGFP->close();
    }
    else
    {
        delete pTGFP;
    }
    return objId;
}
Ejemplo n.º 16
0
AcDbObjectId PPPDlg::createObject()
{
    AcDbObjectId objId;

    PPP* pPPP = CreatePPP( AcGePoint3d( m_xPos, m_yPos, m_zPos ) );
    if( ArxUtilHelper::PostToModelSpace( pPPP ) )
    {
        objId = pPPP->objectId();
        pPPP->close();
    }
    else
    {
        delete pPPP;
    }
    return objId;
}
void
ArxDbgDbAdeskLogo::drawLabel(AcGiCommonDraw* drawContext, ArxDbgDbAdeskLogoStyle* lStyle)
{
    if (drawContext->isDragging())	// don't draw text when dragging, slow proformance
        return;

    CString labelStr;
    if (lStyle)
        labelStr = lStyle->label();

        // short circut if label is Nullstr
    if (labelStr.IsEmpty())
        return;

    // we use an in-memory Mtext object to do the dirty work of writing out
    // the text since it is extremely hard to write text with the AcGi::text()
    // signatures.  This in-memory Mtext object is kept as a member of the class
	// and destroyed either here, since the context is recreated or at the
	// destructor of the class.

	if(NULL != m_tmpMtext)// prevent the memory leak...
		delete m_tmpMtext;

	m_tmpMtext = new AcDbMText;
    m_tmpMtext->setLocation(AcGePoint3d(1.25, 0.0, 0.0)); // set to be just to the right of the logo
    m_tmpMtext->setTextHeight(1.0);                       // unit-block concept where scaling will adjust height
    m_tmpMtext->setWidth(0.0);
    m_tmpMtext->setContents(labelStr);
    m_tmpMtext->setAttachment(AcDbMText::kBottomLeft);

    AcDbDatabase* db = database();
    if (db == NULL)
        db = acdbHostApplicationServices()->workingDatabase();

    m_tmpMtext->setDatabaseDefaults(db);

    if (lStyle && (lStyle->textStyleId() != AcDbObjectId::kNull))
        m_tmpMtext->setTextStyle(lStyle->textStyleId());

    drawContext->rawGeometry()->draw(m_tmpMtext);
}
Ejemplo n.º 18
0
void drawCylinder()
{
	// 创建特定参数的圆柱体(实际上最后一个参数决定了实体是一个圆锥体还是圆柱) 
	AcDb3dSolid *pSolid = new AcDb3dSolid(); 
	pSolid->createFrustum(30, 10, 10, 10);

	// 将圆锥体添加到模型空间
	PostToModelSpace(pSolid);

	//创建切面
	AcGePlane plane;
    plane.set(AcGePoint3d(8,0,0),AcGeVector3d(1,0,0));

	//得到实体与切面相切的截面
	AcDbRegion *pSelectionRegion = NULL;
	pSolid->getSection(plane, pSelectionRegion);

	//将其移动到YZ平面
	moveToBottom(pSelectionRegion);
	
	//将截面加入到模型空间
	PostToModelSpace(pSelectionRegion);
}
void

createDwg()

{

    AcDbDatabase *pDb = new AcDbDatabase();

  

    AcDbBlockTable *pBtbl;

    pDb->getSymbolTable(pBtbl, AcDb::kForRead);



    AcDbBlockTableRecord *pBtblRcd;

    pBtbl->getAt(ACDB_MODEL_SPACE, pBtblRcd,

        AcDb::kForWrite);

    pBtbl->close();



    AcDbCircle *pCir1 = new AcDbCircle(AcGePoint3d(1,1,1),

                                       AcGeVector3d(0,0,1),

                                       1.0),

               *pCir2 = new AcDbCircle(AcGePoint3d(4,4,4),

                                       AcGeVector3d(0,0,1),

                                       2.0);



    pBtblRcd->appendAcDbEntity(pCir1);

    pCir1->close();

    

    pBtblRcd->appendAcDbEntity(pCir2);

    pCir2->close();

    pBtblRcd->close();



    // AcDbDatabase::saveAs() does NOT automatically

    // append a DWG file extension, so it

    // must be specified.

    //

    pDb->saveAs(_T("./test1.dwg"));

    delete pDb;

}
Ejemplo n.º 20
0
Adesk::Boolean
AsdkTextStyleSamp::worldDraw(AcGiWorldDraw* pW)
{
    AcGePoint3d pos(4.0, 4.0, 0.0);
    AcGeVector3d norm(0.0, 0.0, 1.0);
    AcGeVector3d dir(-1.0, -0.2, 0.0);
    char *pStr = "This is a percent, '%%%'.";
    int len = strlen(pStr);
    AcGiTextStyle style;

    AcGeVector3d vec = norm;
    vec = vec.crossProduct(dir);
    dir = vec.crossProduct(norm);

    style.setFileName("txt.shx");
    style.setBigFontFileName("");
    int status;
    if (!((status = style.loadStyleRec()) & 1))
        pStr = "Font not found.";

    pW->geometry().text(pos, norm, dir, pStr, len,
        Adesk::kFalse, style);

    pos.y += 2.0;

    style.setTrackingPercent(0.8); 
	style.setObliquingAngle(0.5);

    AcGePoint2d ext = style.extents(pStr, Adesk::kFalse,
        strlen(pStr), Adesk::kFalse);

    pW->geometry().text(pos, norm, dir, pStr, len,
        Adesk::kFalse, style);

    // Draw a rectangle around the last text drawn.
    // First you have to create a polyline the size of the
    // bounding box, then you have to transform it to the
    // correct orientation, and then to the location of the
    // text.
    
    // Compute the matrix that orients the box.
    //
    AcGeMatrix3d textMat;
    norm.normalize();
    dir.normalize();
    AcGeVector3d yAxis = norm;
    yAxis = yAxis.crossProduct(dir);
    yAxis.normalize();
    textMat.setCoordSystem(AcGePoint3d(0.0, 0.0, 0.0), dir,
        yAxis, norm);

    // Create the bounding box and enlarge it somewhat.
    //
    double offset = ext.y / 2.0;
    AcGePoint3d verts[5];
    verts[0] = verts[4] = AcGePoint3d(-offset, -offset, 0.0);
    verts[1] = AcGePoint3d(ext.x + offset, -offset, 0.0);
    verts[2] = AcGePoint3d(ext.x + offset, ext.y + offset, 0.0);
    verts[3] = AcGePoint3d(-offset, ext.y + offset, 0.0);

    // Orient and then translate each point in the
    // bounding box.
    //
    for (int i = 0; i < 5; i++) {
        verts[i].transformBy(textMat);
        verts[i].x += pos.x;
        verts[i].y += pos.y;
        verts[i].z += pos.z;
    }
    pW->geometry().polyline(5, verts);

    return Adesk::kTrue;
}
Ejemplo n.º 21
0
Acad::ErrorStatus createBlockRecord(/*[in]*/const char* name)
{
	AcDbCircle* pFace = NULL;
	AcDbCircle* pLeftEye = NULL;
	AcDbCircle* pRightEye = NULL;
	AcDbArc* pMouth = NULL;
	AcDbBlockTable* pBlockTable = NULL;
	AcDbBlockTableRecord* pBlockTableRecord = NULL;

	try
	{
		// First, check if a block of the same name already exists
		// by verifying in the current database block table.
		//
		// Open the block table for read
		//
		ARXOK(acdbCurDwg()->getBlockTable(pBlockTable, AcDb::kForRead));

		if (pBlockTable->has(name) == Adesk::kTrue)
		{
			pBlockTable->close();
			return Acad::eDuplicateKey;
		}

		// Now we know the block does not exist, so we create it
		// using the name passed in.
		//
		pBlockTableRecord = new AcDbBlockTableRecord();
		if (!pBlockTableRecord)
			throw Acad::eOutOfMemory;

		pBlockTableRecord->setName(name);

		// To keep it simple, we use the origin for the insertion point
		//
		pBlockTableRecord->setOrigin(AcGePoint3d::kOrigin);

		// Open the block table for write
		// since we are adding a new block definition
		//
		ARXOK(pBlockTable->upgradeOpen());

		// Add the new block table record to the block table.
		// For now, the block table record is empty.
		//
		ARXOK(pBlockTable->add(pBlockTableRecord));
		pBlockTable->close();
		pBlockTable = NULL;

		// Now the block table record is in the database, but is empty
		// (has no sub-entity).
		// Note that after having been added to the database, an object or an entity
		// is implicitely opened for write.
		//
		// So we create the sub entities to append to the block
		// which will represent a "happy face":
		// the block should consist of a round yellow face (circle)
		// two blue eyes (circles) and a red mouth (arc)
		//
		pFace = new AcDbCircle(AcGePoint3d::kOrigin, AcGeVector3d::kZAxis, 1.0);
		pLeftEye = new AcDbCircle(AcGePoint3d(0.33, 0.25, 0.0), AcGeVector3d::kZAxis, 0.1);
		pRightEye = new AcDbCircle(AcGePoint3d(-0.33, 0.25, 0.0), AcGeVector3d::kZAxis, 0.1);
		pMouth = new AcDbArc(AcGePoint3d(0, 0.5, 0), 1.0, PI + (PI * 0.3), PI + (PI * 0.7));
		if (!pFace || !pLeftEye || !pRightEye || !pMouth)
		{
			delete pFace;
			delete pLeftEye;
			delete pRightEye;
			delete pMouth;
			throw Acad::eOutOfMemory;
		}

		// Set the color property.
		//
		pFace->setColorIndex(2);
		pLeftEye->setColorIndex(5);
		pRightEye->setColorIndex(5);
		pMouth->setColorIndex(1);

		ARXOK(pBlockTableRecord->appendAcDbEntity(pFace));
		ARXOK(pBlockTableRecord->appendAcDbEntity(pLeftEye));
		ARXOK(pBlockTableRecord->appendAcDbEntity(pRightEye));
		ARXOK(pBlockTableRecord->appendAcDbEntity(pMouth));

		pFace->close();
		pLeftEye->close();
		pRightEye->close();
		pMouth->close();

		pBlockTableRecord->close();
		return Acad::eOk;
	}

	catch(const Acad::ErrorStatus es)
	{

		if(pBlockTable)
			pBlockTable->close();

		if(pBlockTableRecord)
			// if the id is NULL, it means that the object
			// is not in the database and that we can sefely delete it
			if(pBlockTableRecord->objectId() == AcDbObjectId::kNull)
				delete pBlockTableRecord;
			else
			{
				pBlockTableRecord->erase();
				pBlockTableRecord->close();
			}
		
		if(pFace)
			if(pFace->objectId() == AcDbObjectId::kNull)
				delete pFace;
			else
				pFace->close();
		if(pLeftEye)
			if(pLeftEye->objectId() == AcDbObjectId::kNull)
				delete pLeftEye;
			else
				pLeftEye->close();
		if(pRightEye)
			if(pRightEye->objectId() == AcDbObjectId::kNull)
				delete pRightEye;
			else
				pRightEye->close();
		if(pMouth)
			if(pMouth->objectId() == AcDbObjectId::kNull)
				delete pMouth;
			else
				pMouth->close();

		return es;
	}

}
Ejemplo n.º 22
0
AcGePoint3d Point2D_To_3D( const AcGePoint2d& pt )
{
    return AcGePoint3d( pt.x, pt.y, 0 );
}
Ejemplo n.º 23
0
Acad::ErrorStatus  
AcCircle::getGripPoints(AcDbGripDataPtrArray& grips,
					   const double			 viewSize,
					   const int			 gripSize,
					   const AcGeVector3d&   curViewDir, 
  					   const int			 bitflags) const
{
	assertReadEnabled();

	double xCord1(0),xCord2(0),xCord3(0),xCord4(0);
	double yCord1(0),yCord2(0),yCord3(0),yCord4(0);
	
	appDataType::iterator appIter = putAppData();

	//All the GripData pointer are deallocated automatically
	AcDbGripData *pCenterCoordGrip = new AcDbGripData();
	pCenterCoordGrip = new AcDbGripData();
	pCenterCoordGrip->setGripPoint(mCenter);
	pCenterCoordGrip->setAppData((void*)&(*appIter));
	pCenterCoordGrip->setToolTipFunc(GripCback::GripToolTipFunc);
	pCenterCoordGrip->setHotGripFunc(GripCback::hotGripfunc);
	pCenterCoordGrip->setHoverFunc(GripCback::hoverGripfunc);
	pCenterCoordGrip->setGripOpStatFunc(GripCback::OpStatusfunc);
	pCenterCoordGrip->setWorldDraw(GripCback::WorldDrawfunc);
	pCenterCoordGrip->setRtClk(GripCback::Rtclkfunc);
	pCenterCoordGrip->setGripOpStatFunc(GripCback::OpStatusfunc);
	 grips.append(pCenterCoordGrip);	
	 appIter+=1;
	

	AcDbGripData *pFirstCoordGrip   = new AcDbGripData();
	//Computing the x and the y coordinate for the first grip 
	//point 
	xCord1 = (cos(45*PI/180) * mRadius + mCenter[0]);
	yCord1 = (sin(45*PI/180) * mRadius + mCenter[1]);
	
	pFirstCoordGrip->setGripPoint(AcGePoint3d(xCord1,yCord1,0));
	pFirstCoordGrip->setAppData((void*)&(*appIter));
	pFirstCoordGrip->setToolTipFunc(GripCback::GripToolTipFunc);
	pFirstCoordGrip->setHotGripFunc(GripCback::hotGripfunc);
	pFirstCoordGrip->setHoverFunc(GripCback::hoverGripfunc);
	//pFirstCoordGrip->setGripOpStatFunc(GripCback::OpStatusfunc);
	//pFirstCoordGrip->setWorldDraw(GripCback::WorldDrawfunc);
	//pFirstCoordGrip->setRtClk(GripCback::Rtclkfunc);
	//pCenterCoordGrip->setGripOpStatFunc(GripCback::grigripOpStatusCbackfunc);
	grips.append(pFirstCoordGrip);	
	appIter+=1;

	AcDbGripData *pSecondCoordGrip  = new AcDbGripData();
	xCord2 = (cos(135*PI/180) * mRadius + mCenter[0]);
	yCord2 = (sin(135*PI/180) * mRadius + mCenter[1]);

	pSecondCoordGrip->setGripPoint(AcGePoint3d(xCord2,yCord2,0));
	pSecondCoordGrip->setAppData((void*)&(*appIter));
	pSecondCoordGrip->setToolTipFunc(GripCback::GripToolTipFunc);
	pSecondCoordGrip->setHotGripFunc(GripCback::hotGripfunc);
	pSecondCoordGrip->setHoverFunc(GripCback::hoverGripfunc);
	//pSecondCoordGrip->setGripOpStatFunc(GripCback::OpStatusfunc);
	//pSecondCoordGrip->setWorldDraw(GripCback::WorldDrawfunc);
	//pSecondCoordGrip->setRtClk(GripCback::Rtclkfunc);
	//pCenterCoordGrip->setGripOpStatFunc(GripCback::grigripOpStatusCbackfunc);
	grips.append(pSecondCoordGrip);	
	appIter+=1;

	AcDbGripData *pThirdCoordGrip   = new AcDbGripData();
	
	xCord3 = (cos(225*PI/180) * mRadius + mCenter[0]);
	yCord3 = (sin(225*PI/180) * mRadius + mCenter[1]);

	pThirdCoordGrip->setGripPoint(AcGePoint3d(xCord3,yCord3,0));
	pThirdCoordGrip->setAppData((void*)&(*appIter));
	pThirdCoordGrip->setToolTipFunc(GripCback::GripToolTipFunc);
	pThirdCoordGrip->setHotGripFunc(GripCback::hotGripfunc);
	pThirdCoordGrip->setHoverFunc(GripCback::hoverGripfunc);
	//pThirdCoordGrip->setGripOpStatFunc(GripCback::OpStatusfunc);
	//pThirdCoordGrip->setWorldDraw(GripCback::WorldDrawfunc);
	//pThirdCoordGrip->setRtClk(GripCback::Rtclkfunc);
	//pThirdCoordGrip->setGripOpStatFunc(GripCback::grigripOpStatusCbackfunc);
	grips.append(pThirdCoordGrip);	
	appIter+=1;

	
	AcDbGripData *pFourthCoordGrip  = new AcDbGripData();

	xCord4 = (cos(315*PI/180) * mRadius + mCenter[0]);
	yCord4 = (sin(315*PI/180) * mRadius + mCenter[1]);

	pFourthCoordGrip->setGripPoint(AcGePoint3d(xCord4,yCord4,0));
	pFourthCoordGrip->setAppData((void*)&(*appIter));
	pFourthCoordGrip->setToolTipFunc(GripCback::GripToolTipFunc);
	pFourthCoordGrip->setHotGripFunc(GripCback::hotGripfunc);
	//pFourthCoordGrip->setHoverFunc(GripCback::hoverGripfunc);
	//pFourthCoordGrip->setGripOpStatFunc(GripCback::OpStatusfunc);
//	pFourthCoordGrip->setWorldDraw(GripCback::WorldDrawfunc);
	//pFourthCoordGrip->setRtClk(GripCback::Rtclkfunc);
	//pFourthCoordGrip->setGripOpStatFunc(GripCback::grigripOpStatusCbackfunc);
	grips.append(pFourthCoordGrip);	
	appIter+=1;
	return Acad::eOk;
}
Adesk::Boolean
AsdkShellSamp::subWorldDraw(AcGiWorldDraw* pW)
{
    // Fill the faces with the current color.
    //
    pW->subEntityTraits().setFillType(kAcGiFillAlways);

    // Create vertices.
    //
    Adesk::UInt32 numVerts = 4;
    AcGePoint3d *pVerts = new AcGePoint3d[numVerts];
    pVerts[0] = AcGePoint3d(0.0, 0.0, 0.0);
    pVerts[1] = AcGePoint3d(0.0, 1.0, 0.0);
    pVerts[2] = AcGePoint3d(1.0, 1.0, 0.0);
    pVerts[3] = AcGePoint3d(1.0, 0.0, 2.0);

    // Create 2 faces.
    //
    Adesk::UInt32 faceListSize = 8;
    Adesk::Int32 *pFaceList
        = new Adesk::Int32[faceListSize];

    // Assign vertices for face #1.
    //
    pFaceList[0] = 3;   // 3 vertices in the face
    pFaceList[1] = 0;   // pVerts[0]
    pFaceList[2] = 1;   // pVerts[1]
    pFaceList[3] = 2;   // pVerts[2]

    // assign vertices for face #2.
    //
    pFaceList[4] = 3;   // 3 vertices in the face
    pFaceList[5] = 0;   // pVerts[0]
    pFaceList[6] = 2;   // pVerts[2]
    pFaceList[7] = 3;   // pVerts[3]

    // Apply colors to edges.
    //
    AcGiEdgeData edgeData;
    int numEdges = 6;
    short *pEdgeColorArray = new short[numEdges];

    pEdgeColorArray[0] = kRed;
    pEdgeColorArray[1] = kYellow;
    pEdgeColorArray[2] = kGreen;
    pEdgeColorArray[3] = kCyan;
    pEdgeColorArray[4] = kBlue;
    pEdgeColorArray[5] = kMagenta;

	edgeData.setColors(pEdgeColorArray);

    // Apply visibility to edges and make common edge
    // between two faces have silhouette visibility during
    // the HIDE command with ACAD variable DISPSILH = 1.
    //
    Adesk::UInt8 *pEdgeVisArray
        = new Adesk::UInt8[numEdges];
    edgeData.setVisibility(pEdgeVisArray);

    pEdgeVisArray[0] = kAcGiVisible;
    pEdgeVisArray[1] = kAcGiVisible;
    pEdgeVisArray[2] = kAcGiSilhouette;
    pEdgeVisArray[3] = kAcGiSilhouette;
    pEdgeVisArray[4] = kAcGiVisible;
    pEdgeVisArray[5] = kAcGiVisible;
    
    // Apply colors to faces.
    //
    AcGiFaceData faceData;
    int numFaces = 2;
    short *pFaceColorArray = new short[numFaces];

    pFaceColorArray[0] = kBlue;
    pFaceColorArray[1] = kRed;

	faceData.setColors(pFaceColorArray);

    pW->geometry().shell(numVerts, pVerts, faceListSize,
        pFaceList, &edgeData, &faceData);

    delete [] pVerts;
    delete [] pFaceList;
    delete [] pEdgeColorArray;
    delete [] pFaceColorArray;
 
    return Adesk::kTrue;
}
Ejemplo n.º 25
0
//-----------------------------------------------------------------------------
// Constructor that accepts a reference to a CRectInfo class which
// contains all the information need to initialize the polyline entitiy
// that will be used for dragging and ultimately be the polyline that
// gets to the database if all goes well. 
//
AsdkRectangleJig::AsdkRectangleJig()
{ 
    m_pLWPoly = new AcDbPolyline();
    samplerCorner = AcGePoint3d();
    plineInfo.m_cornerTreatment = plineInfo.m_first != 0.0
        || plineInfo.m_second != 0.0
        || plineInfo.m_radius != 0.0;

    // Now need to get the current UCS Z-Axis to be used as the normal vector 
    // for the rectangle. At the same time, we get the x and y unit direction 
    // vectors used later.
    //
    if(inPaperSpace()) {
      m_vecUnitX = acdbHostApplicationServices()->workingDatabase()->pucsxdir();
      m_vecUnitY = acdbHostApplicationServices()->workingDatabase()->pucsydir();
    } else {
      m_vecUnitX = acdbHostApplicationServices()->workingDatabase()->ucsxdir();
      m_vecUnitY = acdbHostApplicationServices()->workingDatabase()->ucsydir();
    }

    m_vecUnitZ = m_vecUnitX.crossProduct(m_vecUnitY);

    // Convert the incomming UCS point to ECS coordinate system
    //
    acdbUcs2Ecs(asDblArray(plineInfo.m_topLeftCorner), 
        asDblArray(m_TopLeftCorner), asDblArray(m_vecUnitZ), Adesk::kFalse);
    acdbUcs2Ecs(asDblArray(plineInfo.m_topLeftCorner), 
        asDblArray(plineInfo.m_topLeftCorner), asDblArray(m_vecUnitZ),
        Adesk::kFalse);
    AcGePoint2d initPoint;
    initPoint = AcGePoint2d(m_TopLeftCorner[X], m_TopLeftCorner[Y]);

    // If the user has set the elev option from the main command prompt,
    // then this will be the default until the user again sets it to 0.0.
    // If however the user simply picks a point with or without an object
    // snap, then use the Z value of the first point picked.
    //
    if (plineInfo.m_elevHandSet == TRUE)
        m_pLWPoly->setElevation(plineInfo.m_elev);
    else
        m_pLWPoly->setElevation(m_TopLeftCorner[Z]);

    // If we are indeed filleting or chamfering the corners, then
    // we'll add the extra verticies here to have their bulges and
    // distances from the real corner changed on the fly.
    // 
    if (plineInfo.m_cornerTreatment == TRUE) {
        for (int i = 0 ; i < 8; i++)
                m_pLWPoly->addVertexAt(i, initPoint);
    } else {
        for (int i = 0 ; i < 4; i++)
                m_pLWPoly->addVertexAt(i, initPoint);
    }

    m_pLWPoly->setNormal(m_vecUnitZ);
    m_pLWPoly->setClosed(Adesk::kTrue);
    m_pLWPoly->setThickness(plineInfo.m_thick);
    m_pLWPoly->setConstantWidth(plineInfo.m_width);
    // Get the current default linetype scale
    m_pLWPoly->setLinetypeScale(acdbHostApplicationServices()
        ->workingDatabase()->celtscale());
    // Now for jig dragger purposes, convert the point back to world
    // coordinates.
    //
    acdbEcs2Wcs(asDblArray(m_TopLeftCorner), 
        asDblArray(m_TopLeftCorner), asDblArray(m_vecUnitZ), Adesk::kFalse);
    acdbEcs2Wcs(asDblArray(plineInfo.m_topLeftCorner), 
        asDblArray(plineInfo.m_topLeftCorner), asDblArray(m_vecUnitZ),
        Adesk::kFalse);
}
Ejemplo n.º 26
0
AsdkEmployee::AsdkEmployee() : AcDbEllipse (AcGePoint3d (), AcGeVector3d (0, 0, 1), AcGeVector3d (1, 0, 0), 1)
{
	// TODO: do your initialization.
	m_firstName =m_lastName =NULL ;
}
Ejemplo n.º 27
0
void LineCutPosDialog::OnBnClickedOk()
{
	GetTransformData();

	/*
	//绘制圆柱
	{
		//得到半径和高度
		double radius = _wtof(m_A00.GetBuffer());
		double height = _wtof(m_A01.GetBuffer());

		m3dSolid = CreateCylinder(radius,height);
		if( m3dSolid == NULL )
			return;
	}
	*/

	//绘制管道

	double radius = _wtof(m_A00.GetBuffer());

	double startX = _wtof(m_A10.GetBuffer());
	double startY = _wtof(m_A11.GetBuffer());
	double startZ = _wtof(m_A12.GetBuffer());

	double endX = _wtof(m_A20.GetBuffer());
	double endY = _wtof(m_A21.GetBuffer());
	double endZ = _wtof(m_A22.GetBuffer());

	CreatePipe(AcGePoint3d(startX,startY,startZ),AcGePoint3d(endX,endY,endZ),radius);

	/*
	{
		acutPrintf(L"首先绘制线段\n");
		point = AcGePoint3d(x,y,z);
		ArxWrapper::createLine(AcGePoint3d(),point,L"测试矩阵旋转");
	}

	//首先进行旋转
	{
		//AcGeMatrix3d rotateMatrix = AcGeMatrix3d::alignCoordSys(AcGePoint3d::kOrigin,AcGeVector3d::kXAxis,AcGeVector3d::kYAxis,AcGeVector3d::kZAxis,
		//	AcGePoint3d::kOrigin,AcGeVector3d::kXAxis,AcGeVector3d::kYAxis,AcGeVector3d(point.x,point.y,point.z));
		
		//得到垂直向量
		AcGeVector3d line3dVector(x,y,z);
		AcGeVector3d rotateVctor = line3dVector.crossProduct(AcGeVector3d::kZAxis);

		//得到角度
		double angle = line3dVector.angleTo(AcGeVector3d::kZAxis)/-2;

		//double angle = _wtof(m_A10.GetBuffer());
		acutPrintf(L"向量角度,除以-2,进行旋转[%lf]\n",angle);

		//AcGeMatrix3d rotateMatrix = AcGeMatrix3d::rotation( (3.14159265358979323846 * angle ) / 360,AcGeVector3d(point.x,point.y,point.z),AcGePoint3d::kOrigin);
		AcGeMatrix3d rotateMatrix = AcGeMatrix3d::rotation( angle, rotateVctor, AcGePoint3d::kOrigin);
		m3dSolid->transformBy(rotateMatrix);

		//X轴旋转
		//AcGeVector3d vecX(_wtof(m_A20.GetBuffer()),_wtof(m_A21.GetBuffer()),_wtof(m_A22.GetBuffer()));

		//得到

		//rotateMatrix = AcGeMatrix3d::rotation( ( 3.14159265358979323846 * _wtof(m_A10.GetBuffer()) ) / 180 , vecX );
		m3dSolid->transformBy(rotateMatrix);

		//Y轴旋转
		//AcGeVector3d vecY(0,1,0);
		//rotateMatrix = AcGeMatrix3d::rotation( ( 3.14159265358979323846 * _wtof(m_A11.GetBuffer()) ) / 180, vecY );
		//m3dSolid->transformBy(rotateMatrix);

		//Z轴旋转
		//AcGeVector3d vecZ(0,0,1);
		//rotateMatrix = AcGeMatrix3d::rotation( ( 3.14159265358979323846 * _wtof(m_A12.GetBuffer()) ) / 180, vecZ );
		//m3dSolid->transformBy(rotateMatrix);
	}

	//然后进行相应的位移
	{
		AcGeVector3d moveVec(_wtof(m_T0.GetBuffer()), _wtof(m_T1.GetBuffer()), _wtof(m_T2.GetBuffer()));

		AcGeMatrix3d moveMatrix;
		moveMatrix.setToTranslation(moveVec);

		m3dSolid->transformBy(moveMatrix);
	}

	// 将圆锥体添加到模型空间
	PostToModelSpace(m3dSolid);
	*/

	/*
	//AcGePoint3d orignal(_wtof(m_T0.GetBuffer()), _wtof(m_T1.GetBuffer()), _wtof(m_T2.GetBuffer()));
		
	int offset = 0;
	
	if( m_strOffset.GetLength())
		offset = _wtoi(m_strOffset);

	//generateCutRegion(pSolid,offset,m_Direction);
	*/

	CAcUiDialog::OnOK();
}
void asdktest3 () {
    //----- Create a line and a circle (memory only)
    AcDbLine *pLine =new AcDbLine (AcGePoint3d (), AcGePoint3d (100, 100, -100)) ;
    AcDbCircle *pCircle =new AcDbCircle (AcGePoint3d (50, 50, 0), AcGeVector3d (0, 0, 1) , 25.0) ;

    //----- Create a region from the circle
    AcDbVoidPtrArray arr1, arr2 ;
    arr1.append (pCircle) ;
    AcDbRegion::createFromCurves (arr1, arr2) ;
    AcDbRegion *pRegion =(AcDbRegion *)arr2.at (0) ;
    delete pCircle ;

    //----- Add the line and the region objects to the collector
    //----- NB: Remember those object are memory objects only
    AsdkHlrCollector collector ;
    collector.setDeleteState (true) ;
    collector.addEntity (pLine) ;
    collector.addEntity (pRegion) ;

    //----- Process hidden line removal
    AsdkHlrEngine hlr (AcGePoint3d (50, 50,0), AcGeVector3d (0, 0, 1), kEntity | kBlock | kShowAll | kProject | kHonorInternals) ;
    hlr.run (collector) ;

    //----- To easily see the result, we do append resulting entities to the current database
    //----- and use the color convention used in command 'TEST1'
    int n =collector.mOutputData.logicalLength () ;
    for ( int i =0 ; i < n ; i++ ) {
        AsdkHlrData *p =collector.mOutputData [i] ;

        AcDbEntity *pEnt =p->getResultEntity () ;
        AsdkHlrData::Visibility vis =p->getVisibility () ;
        if ( vis == AsdkHlrData::kVisible )
            pEnt->setColorIndex (1) ;
        else
            pEnt->setColorIndex (5) ;
        AcDbObjectId id ;
        if ( postToDatabase (NULL, pEnt, id) != Acad::eOk ) {
            acutPrintf (_T("Failed to add entity to current space.\n")) ;
            break ;
        }

        //----- Entity originator path
        AcDbObjectIdArray ids =p->getObjectIds () ;
        if ( ids.logicalLength () > 0 ) {
            acutPrintf (ACRX_T("\n%ld, "), pEnt->objectId ().asOldId ()) ;
            for ( int j =0 ; j < ids.logicalLength () ; j++ ) {
                acutPrintf (ACRX_T("%ld, "), ids.at (j).asOldId ()) ;
            }
        }

        pEnt->close () ;
    }
}