|
The only way I have found is obtainig the loops and intersecting them (Thanks Ing. B.C.). This is my code snippet. It only works when the number of Loops are equal and loops are built from lines. This is enough for me. I dont know if there is a simply way to do the same. Any suggestions? bool IntersectionOf2Hatch(AcDbHatch *pHatch1, AcDbHatch *pHatch2) { /* Return: true: Found an intersection false: no intersections */ int loops1 = pHatch1->numLoops(); int loops2 = pHatch2->numLoops(); AcDbObjectIdArray loopIds1; AcDbObjectIdArray loopIds2; for (int i = 0; i < loops1; ++i) { long loopType1; AcGeVoidPointerArray edgePtrs1; AcGeIntArray edgeTypes1; long loopType2; AcGeVoidPointerArray edgePtrs2; AcGeIntArray edgeTypes2; AcDb3dPolyline *pPol1 = NULL; AcDb3dPolyline *pPol2 = NULL; if (pHatch1->getLoopAt(i, loopType1, edgePtrs1, edgeTypes1) == Acad::eOk) { for (int j = 0; j < edgePtrs1.length(); j++) { AcGePoint3d point1; switch (edgeTypes1){ case AcDbHatch::kLine: { AcGeLineSeg3d *pGeLine3d = (AcGeLineSeg3d*)edgePtrs1; point1 = pGeLine3d->startPoint(); AcDb3dPolylineVertex *pVertex = new AcDb3dPolylineVertex(point1); if (pPol1 == NULL) pPol1 = new AcDb3dPolyline(); pPol1->appendVertex(pVertex); } break; case AcDbHatch::kCirArc: case AcDbHatch::kEllArc: case AcDbHatch::kSpline: default: break; } } if (pPol1 != NULL) pPol1->makeClosed(); } if (pHatch2->getLoopAt(i, loopType2, edgePtrs2, edgeTypes2) == Acad::eOk) { for (int k = 0; k < edgePtrs2.length(); k++) { AcGePoint3d point2; switch (edgeTypes2){ case AcDbHatch::kLine: { AcGeLineSeg3d *pGeLine3d = (AcGeLineSeg3d*)edgePtrs2; point2 = pGeLine3d->startPoint(); AcDb3dPolylineVertex *pVertex = new AcDb3dPolylineVertex(point2); if (pPol2 == NULL) pPol2 = new AcDb3dPolyline(); pPol2->appendVertex(pVertex); } break; case AcDbHatch::kCirArc: case AcDbHatch::kEllArc: case AcDbHatch::kSpline: default: break; } } if (pPol2 != NULL) pPol2->makeClosed(); } if (pPol1 != NULL && pPol2 != NULL) { AcGePoint3dArray points; if (pPol1->intersectWith(pPol2, AcDb::kOnBothOperands, points) == Acad::eOk) { if (points.length() > 0) { delete pPol1; delete pPol2; return true; } } } if (pPol1 != NULL) delete pPol1; if (pPol2 != NULL) delete pPol2; } return false; } "developer" escribió en el mensaje news:41ff7ef0$1_1@newsprd01... > Hello, > Is there a way to know if one hatch intersects with another hatch? > Thanks in advance, > Helio. > > |
|