Acad::ErrorStatus AcRectJig::setPlane() { // Acquire current UCS transformation matrix. // We save the matrix for later use. // acdbUcsMatrix(mUcsToWcsMat); mWcsToUcsMat = mUcsToWcsMat.inverse(); // Get data from user coordinate system. // AcGePoint3d orgPt; AcGeVector3d xAxis, yAxis, zAxis; mUcsToWcsMat.getCoordSystem(orgPt, xAxis, yAxis, zAxis); // Get the current elevation w.r.t current UCS, w.r.t the current space. // struct resbuf rb; ads_getvar(/*MSG0*/"CVPORT", &rb); double elev; if (rb.resval.rint == 1) elev = mpDb->pelevation(); // Paper space else elev = mpDb->elevation(); // Model space // Convert elevation from UCS to WCS. // orgPt += elev * zAxis; mElevation = zAxis.dotProduct(orgPt.asVector()); mNormal = zAxis; mHorizDir = xAxis; mVertDir = mNormal.crossProduct(mHorizDir); return Acad::eOk; }
MaterialJig::MaterialJig( const AcGePoint3d& center, const AcDbObjectId& materialId) { mpMaterialEnt = (AsdkMaterial*)AsdkMaterial::desc()->create(); mpMaterialEnt->setDatabaseDefaults(); mpMaterialEnt->setMaterialId(materialId); AcGeMatrix3d translateMat; translateMat.setToTranslation(center.asVector()); mpMaterialEnt->setTransform(translateMat); }
AcDbObjectId CArxHelper::CreateText(const CString& strText, const AcGePoint3d& pt1, const AcGePoint3d& pt2, double dDist, BOOL bUp /* = TRUE */) { AcDbObjectId textId = AcDbObjectId::kNull; AcGePoint3d pt = (pt1 + pt2.asVector()) / 2.0; AcDbMText* pMText = new AcDbMText(); pMText->setContents(strText); pMText->setLocation(pt); pMText->setDirection(pt2-pt1); textId = AddToCAD(pMText,4); AcDbExtents extents; pMText->getGeomExtents(extents); AcGeVector3d vect = (pt2-pt1).normal() * (extents.maxPoint().x - extents.minPoint().x) / 2.0; AcGeMatrix3d xform = AcGeMatrix3d::translation(-vect); acdbOpenObject(pMText,textId,AcDb::kForWrite); pMText->transformBy(xform); pMText->close(); return textId; }
void ArxDbgUtils::getUcsToWcsOriginMatrix(AcGeMatrix3d& m, const AcGePoint3d& wcsBasePt, AcDbDatabase* db) { ASSERT(db != NULL); AcGeMatrix3d tmpMat; if (acdbUcsMatrix(tmpMat, db)) { AcGePoint3d origin; AcGeVector3d xDir, yDir, zDir; tmpMat.getCoordSystem(origin, xDir, yDir, zDir); origin += wcsBasePt.asVector(); m.setToAlignCoordSys(origin, xDir, yDir, zDir, AcGePoint3d::kOrigin, AcGeVector3d::kXAxis, AcGeVector3d::kYAxis, AcGeVector3d::kZAxis); } else { ASSERT(0); m = AcGeMatrix3d::kIdentity; } }
void ArxDbgDbAdeskLogo::drawSingleCaliper(AcGiCommonDraw* drawContext, AcGePoint3d* pts, ArxDbgDbAdeskLogoStyle* lStyle) { AcGeVector3d viewDir; AcGiViewportDraw* vportDraw = AcGiViewportDraw::cast(drawContext); if (vportDraw) viewDir = vportDraw->viewport().viewDir(); else { // cheat and get viewdir for current viewport from the system variable AcGePoint3d tmpPt; getSysVar(_T("viewdir"), tmpPt); viewDir = tmpPt.asVector(); } if (viewDir == AcGeVector3d::kZAxis) { // if solid fill is on we have to save the current state // first and then restore it. If we don't, then if we // are drawn as part of some other entity, we'll mess it up // for them. if (lStyle && (lStyle->isSolidFill()) && (drawContext->isDragging() == Adesk::kFalse)) { AcGiFillType savedFillType = drawContext->subEntityTraits().fillType(); drawContext->subEntityTraits().setFillType(kAcGiFillAlways); drawContext->rawGeometry()->polygon(5, pts); drawContext->subEntityTraits().setFillType(savedFillType); } else { drawContext->rawGeometry()->polygon(5, pts); } } else { AcGePoint3d allPts[10]; allPts[0] = pts[0]; allPts[1] = pts[1]; allPts[2] = pts[2]; allPts[3] = pts[3]; allPts[4] = pts[4]; allPts[5].set(pts[0].x, pts[0].y, 1.0); allPts[6].set(pts[1].x, pts[1].y, 1.0); allPts[7].set(pts[2].x, pts[2].y, 1.0); allPts[8].set(pts[3].x, pts[3].y, 1.0); allPts[9].set(pts[4].x, pts[4].y, 1.0); Adesk::Int32 faceList[37]; // bottom face faceList[0] = 5; // number of vertices faceList[1] = 0; faceList[2] = 1; faceList[3] = 2; faceList[4] = 3; faceList[5] = 4; // top face faceList[6] = 5; // number of vertices faceList[7] = 5; faceList[8] = 6; faceList[9] = 7; faceList[10] = 8; faceList[11] = 9; // inside left face faceList[12] = 4; // number of vertices faceList[13] = 0; faceList[14] = 1; faceList[15] = 6; faceList[16] = 5; // inside right face faceList[17] = 4; // number of vertices faceList[18] = 1; faceList[19] = 2; faceList[20] = 7; faceList[21] = 6; // outside right face faceList[22] = 4; // number of vertices faceList[23] = 2; faceList[24] = 3; faceList[25] = 8; faceList[26] = 7; // outside top face faceList[27] = 4; // number of vertices faceList[28] = 3; faceList[29] = 4; faceList[30] = 9; faceList[31] = 8; // outside left face faceList[32] = 4; // number of vertices faceList[33] = 4; faceList[34] = 0; faceList[35] = 5; faceList[36] = 9; drawContext->rawGeometry()->shell(10, allPts, 37, faceList); } }