void dumpBblock() { AcBr::ErrorStatus returnValue = AcBr::eOk; // Select the entity by type AcBrEntity* pEnt = NULL; AcDb::SubentType subType = AcDb::kNullSubentType; returnValue = selectEntityByType(pEnt, subType); if (returnValue != AcBr::eOk) { acutPrintf("\n Error in selectEntityByType:"); errorReport(returnValue); delete pEnt; return; } AcGeBoundBlock3d bblock; returnValue = pEnt->getBoundBlock(bblock); if (returnValue != AcBr::eOk) { acutPrintf("\n Error in AcBrEntity::getBoundBlock:"); errorReport(returnValue); delete pEnt; return; } delete pEnt; AcGePoint3d min, max; bblock.getMinMaxPoints(min, max); bblockReport(min, max); return; }
void dumpModel() { AcBr::ErrorStatus returnValue = AcBr::eOk; // Select the entity by type AcBrEntity* pEnt = NULL; AcDb::SubentType subType = AcDb::kNullSubentType; returnValue = selectEntityByType(pEnt, subType); if (returnValue != AcBr::eOk) { acutPrintf(ACRX_T("\n Error in selectEntityByType:")); errorReport(returnValue); delete pEnt; return; } switch (subType) { case AcDb::kNullSubentType: // brep returnValue = brepDump((const AcBrBrep&)(*pEnt)); if (returnValue != AcBr::eOk) { acutPrintf(ACRX_T("\n Error in brepDump:")); errorReport(returnValue); return; } break; case AcDb::kFaceSubentType: // face returnValue = faceDump((const AcBrFace&)(*pEnt)); if (returnValue != AcBr::eOk) { acutPrintf(ACRX_T("\n Error in faceDump:")); errorReport(returnValue); return; } break; case AcDb::kEdgeSubentType: // edge returnValue = edgeDump((const AcBrEdge&)(*pEnt)); if (returnValue != AcBr::eOk) { acutPrintf(ACRX_T("\n Error in edgeDump:")); errorReport(returnValue); return; } break; default: acutPrintf(ACRX_T("\n dumpModel: unsupported subentity type: %d\n"), subType); return; } delete pEnt; return; }
void pointContainment() { AcBr::ErrorStatus returnValue = AcBr::eOk; // Select the entity by type AcBrEntity* pEnt = NULL; AcDb::SubentType subType = AcDb::kNullSubentType; returnValue = selectEntityByType(pEnt, subType); if (returnValue != AcBr::eOk) { acutPrintf(ACRX_T("\n Error in selectEntityByType:")); errorReport(returnValue); delete pEnt; return; } // Query the point by AutoCAD pick AcGePoint3d testPt; acedGetPoint(NULL, ACRX_T("\n Pick point for containment test: \n"), asDblArray(testPt)); AcGe::PointContainment containment = AcGe::kOutside; AcBrEntity* container = NULL; returnValue = pEnt->getPointContainment(testPt, containment, container); if (returnValue != AcBr::eOk) { acutPrintf(ACRX_T("\n Error in AcBrEntity::getPointContainment:")); errorReport(returnValue); delete pEnt; return; } ptContainmentReport(containment, container); delete container; delete pEnt; return; }
void lineContainment() { AcBr::ErrorStatus returnValue = AcBr::eOk; // Select the entity by type AcBrEntity* pEnt = NULL; AcDb::SubentType subType = AcDb::kNullSubentType; returnValue = selectEntityByType(pEnt, subType); if (returnValue != AcBr::eOk) { acutPrintf("\n Error in selectEntityByType:"); errorReport(returnValue); delete pEnt; return; } // Query the line by AutoCAD pick AcGePoint3d startPt, endPt; int hitCount = 0; acutPrintf("\n Pick line for containment test, by selecting two points: \n"); acedGetPoint(NULL, "\n Pick origin of line: \n", asDblArray(startPt)); acedGetPoint(NULL, "\n Pick another point on line: \n", asDblArray(endPt)); acedGetInt("\n Number of hits wanted: ", &hitCount); // Query the line type const AcGeLinearEnt3d* line = NULL; char opt[128]; while (Adesk::kTrue) { acutPrintf("\nEnter Line Type: "); acedInitGet(NULL, "Infinite Ray Segment"); if (acedGetKword("Infinite/Ray/<Segment>: ", opt) == RTCAN) return; // Map the user input to a valid line type if ((strcmp(opt, "Segment") == 0) || (strcmp(opt, "") == 0)) { line = new AcGeLineSeg3d(startPt, endPt); break; } else if (strcmp(opt, "Ray") == 0) { line = new AcGeRay3d(startPt,endPt); break; } else if (strcmp(opt, "Infinite") == 0) { line = new AcGeLine3d(startPt, endPt); break; } } if (line == NULL) { acutPrintf("\n lineContainment: unable to allocate memory for line\n"); delete pEnt; return; } Adesk::UInt32 numHitsWanted = (Adesk::UInt32)hitCount; Adesk::UInt32 numHitsFound = 0; AcBrHit* hits = NULL; returnValue = pEnt->getLineContainment(*line, numHitsWanted, numHitsFound, hits); if (returnValue != AcBr::eOk) { acutPrintf("\n Error in AcBrEntity::getLineContainment:"); errorReport(returnValue); delete pEnt; return; } acutPrintf("\n Number of hits found: %d", numHitsFound); for (Adesk::UInt32 i = 0; i < numHitsFound; i++) { AcBrEntity* entityAssociated = NULL; returnValue = hits[i].getEntityAssociated(entityAssociated); if (returnValue != AcBr::eOk) { acutPrintf("\n Error in AcBrHit::getEntityAssociated:"); errorReport(returnValue); delete entityAssociated; break; } if (!pEnt->isEqualTo(entityAssociated)) { acutPrintf("\n lineContainment: Hit owner is not the entity we checked line containment against!"); delete entityAssociated; break; } AcGePoint3d pt; returnValue = hits[i].getPoint(pt); if (returnValue != AcBr::eOk) { acutPrintf("\n Error in AcBrHit::getPoint:"); errorReport(returnValue); break; } AcBrEntity* entityHit = NULL; returnValue = hits[i].getEntityHit(entityHit); if (returnValue != AcBr::eOk) { acutPrintf("\n Error in AcBrHit::getEntityHit:"); errorReport(returnValue); delete entityHit; break; } AcBrEntity* entityEntered = NULL; returnValue = hits[i].getEntityEntered(entityEntered); if (returnValue != AcBr::eOk) { acutPrintf("\n Error in AcBrHit::getEntityEntered:"); errorReport(returnValue); delete entityHit; delete entityEntered; break; } lnContainmentReport(i, pt, entityHit, entityEntered); delete entityHit; delete entityEntered; } delete pEnt; delete[] hits; return; }
void meshModel() { AcBr::ErrorStatus returnValue = AcBr::eOk; // Query the mesh dump style Adesk::Boolean displayElements = Adesk::kTrue; ACHAR opt[128]; while (Adesk::kTrue) { acutPrintf(ACRX_T("\nSelect Style for Mesh Dump: ")); acedInitGet(NULL, ACRX_T("Coordinates Polylines")); if (acedGetKword(ACRX_T("Coordinates/<Polylines>: "), opt) == RTCAN) return; // Map the user input to a valid dump style if ((_tcscmp(opt, ACRX_T("Polylines")) == 0) || (_tcscmp(opt, ACRX_T("")) == 0)) { displayElements = Adesk::kTrue; break; } else if ((_tcscmp(opt, ACRX_T("Coordinates")) == 0)) { displayElements = Adesk::kFalse; break; } } // Select the entity by type AcBrEntity* pEnt = NULL; AcDb::SubentType subType = AcDb::kNullSubentType; returnValue = selectEntityByType(pEnt, subType); if (returnValue != AcBr::eOk) { acutPrintf(ACRX_T("\n Error in selectEntityByType:")); errorReport(returnValue); delete pEnt; return; } // Call the appropriate subentity mesh routine switch (subType) { case AcDb::kNullSubentType: // brep returnValue = brepMesh((const AcBrBrep&)(*pEnt), displayElements); if (returnValue != AcBr::eOk) { acutPrintf(ACRX_T("\n Error in brepMesh:")); errorReport(returnValue); } break; case AcDb::kFaceSubentType: // face returnValue = faceMesh((const AcBrFace&)(*pEnt), displayElements); if (returnValue != AcBr::eOk) { acutPrintf(ACRX_T("\n Error in faceMesh:")); errorReport(returnValue); } break; default: acutPrintf(ACRX_T("\n meshModel: unsupported subentity type: %d\n"), subType); break; } delete pEnt; return; }