AcDbObjectId CCalculation::ConvexHull(AcGePoint2dArray Points) { AcDbPolyline *CHull = new AcDbPolyline(); AcGePoint2dArray SortPoints = CCalculation::SortByLexi(Points); CHull->addVertexAt(); AcDbObjectId Convexhull = CCreateEnt::PostToModelSpace(CHull); return Convexhull; }
void AcDbDoubleClickEditPline::startEdit(AcDbEntity *pEnt, AcGePoint3d clickpt) { // Implement the startEdit notification handler to catch when // a user double-clicks a 'POLYLINE' entity // Get the Current Document AcApDocument *pDoc=acDocManager->curDocument(); AcDbPolyline *pLine; // Cast the AcDbEntity pointer to AcDbPolyline if(pEnt->isKindOf(AcDbPolyline::desc()) == Adesk::kTrue) pLine=AcDbPolyline::cast(pEnt); else { acutPrintf("Error: Invalid AcDbPolyline Object"); return; } acDocManager->lockDocument(pDoc,AcAp::kWrite); // Upgrade to write if(pLine->upgradeOpen()!=Acad::eOk) { acutPrintf("Error: Could Not open AcDbPolyline Object"); return; } // iterate through all the vertices to find which // segment was clicked on, and place a vertex there. for(unsigned int c=0;c<pLine->numVerts()-1;c++) { AcGePoint3d pt1,pt2; pLine->getPointAt(c,pt1); pLine->getPointAt(c+1,pt2); AcGeVector3d lineVec(pt2-pt1),clickVec(clickpt-pt1), clickVec2(pt2-clickpt); double ang=lineVec.angleTo(clickVec); // This is the filter... // .05 (5% of lineVec length) is an arbitrary length... if((sin(ang)*clickVec.length()<.05*lineVec.length()) && clickVec.length()<lineVec.length() && clickVec2.length()<lineVec.length()) { // Add the point Here! ads_point outPt; acdbWcs2Ecs(asDblArray(clickpt),outPt,asDblArray(pLine->normal()),Adesk::kFalse); pLine->addVertexAt(c+1,asPnt2d(outPt)); break; } } pLine->close(); acDocManager->unlockDocument(pDoc); // invoking acedSSSetFirst(NULL,NULL) here will clear the // pickfirst selection, if desired (not With pline though). //acedSSSetFirst(NULL,NULL); // Update the graphics... pLine->draw(); actrTransactionManager->flushGraphics(); acedUpdateDisplay(); }
AcDbObjectId Additional_Class::Draw_Rectangle( AcGePoint2d stPt, double length, double height ) { AcDbPolyline *pPolyline = new AcDbPolyline(4); AcGePoint2d stPt1, stPt2, stPt3, stPt4; stPt1 = stPt; pPolyline->addVertexAt(0, stPt1, 0, 0, 0); stPt2.x = stPt.x +length; stPt2.y = stPt.y; pPolyline->addVertexAt(1, stPt2, 0, 0, 0); stPt3.x = stPt2.x; stPt3.y = stPt2.y + height; pPolyline->addVertexAt(2, stPt3, 0, 0, 0); stPt4.x = stPt3.x - length; stPt4.y = stPt3.y; pPolyline->addVertexAt(3, stPt4, 0, 0, 0); pPolyline->setClosed(Adesk::kTrue); AcDbBlockTable *pBlockTable = NULL; acdbHostApplicationServices()->workingDatabase()->getBlockTable(pBlockTable, AcDb::kForRead); //this->Open_BlockTable(pBlockTable, NREADMODE); AcDbBlockTableRecord *pBlockTableRecord = NULL; pBlockTable->getAt(ACDB_MODEL_SPACE, pBlockTableRecord, AcDb::kForWrite); //acdbHostApplicationServices()->workingDatabase()->getBlockTable(pBlockTable, AcDb::kForRead); //this->Open_ModelTableRecord(pBlockTableRecord, pBlockTable, NWRITEMODE); AcDbObjectId TempLineID; pBlockTableRecord->appendAcDbEntity(TempLineID, pPolyline); pPolyline->close(); pBlockTable->close(); pBlockTableRecord->close(); return TempLineID; }