예제 #1
0
void 
hilitSolid()
{
	Adesk::Boolean interrupted = Adesk::kFalse;
    ads_printf("\nSelect a solid");

    Acad::ErrorStatus es = Acad::eOk;

    AcDb3dSolid *solid = NULL;
    AcDbEntity  *ent = NULL;
    AcDbObjectId solidId;
    ads_name     ename, sset;

    for (;;) {

        switch (ads_ssget(NULL, NULL, NULL, NULL, sset)) {

        case RTNORM:
        {
            struct resbuf *rb;
            if (ads_ssnamex(&rb, sset, 0) != RTNORM) {
                ads_ssfree(sset);
                return;
            }
            int            sel_method;
            ads_name       subname;
            short          marker;
            AcGePoint3d    pickpnt;
            AcGeVector3d   pickvec;

            if (!extractEntityInfo(rb,
                              sel_method,
                              ename,
                              subname,
                              marker,
                              pickpnt,
                              pickvec)) {
                ads_ssfree(sset);
                return;
            }

            AOK(acdbGetObjectId(solidId, ename));

            AOK(acdbOpenAcDbEntity(ent, solidId, AcDb::kForRead));
            assert(ent != NULL);

            solid = AcDb3dSolid::cast(ent);
            if (solid == NULL) {
                ads_printf("\nNot a solid.");
                AOK(ent->close());
                ads_ssfree(sset);
                continue;
            }

            int                  numPaths;
            AcDbFullSubentPath*  subentPaths;
            AcGeMatrix3d         xform;
            es = solid->getSubentPathsAtGsMarker( AcDb::kEdgeSubentType,
                                            marker,
                                            pickpnt,
                                            xform,
                                            numPaths,
                                            subentPaths);
            // For objects with no edges (such as a sphere) the code to
            // highlight an edge is meaningless and must be skipped.
            //
            if (numPaths > 0) {

                // Highlight and unhighlight the selected edge of the solid.
                //
                ads_printf("\nHighlighting the selected edge.");
                es = solid->highlight(subentPaths[0]);
                pressEnterToContinue();
                es = solid->unhighlight(subentPaths[0]);
            } else
                ads_printf("\nNo edges to highlight.");
            delete []subentPaths;

            // Highlight and unhighlight the faces corresponding to the
            // first edge of the solid.
            //
            es = solid->getSubentPathsAtGsMarker( AcDb::kFaceSubentType,
                                            marker,
                                            pickpnt,
                                            xform,
                                            numPaths,
                                            subentPaths);
            for (int i = 0; i < numPaths; i++) {
                ads_printf("\nHighlighting face %d of %d", i + 1, numPaths);
                es = solid->highlight(subentPaths[i]);
                pressEnterToContinue();
                es = solid->unhighlight(subentPaths[i]);
            }
            delete []subentPaths;
            ads_ssfree(sset);

            // Highlight the entire solid, then unhighlight it.
            //
            ads_printf("\nHighlighting the entire solid");
            es = solid->highlight();
            pressEnterToContinue();
            es = solid->unhighlight();
        }
        break;
        case RTNONE:
        case RTCAN:
            return;
        default:
            continue;
        }
        ads_ssfree(sset);
        break;
    }

    AOK(ent->close());
    return;
}
예제 #2
0
static Acad::ErrorStatus
makeSubentPath(const AcDbObject*        pObj,
			   const AcDbObjectIdArray& objIdList,
			   const AcDb::SubentType&  subType,
			   const short&             marker,
			   const AcGePoint3d&       pickpnt,                                           
			   AcDbFullSubentPath&      subPath)
{
	Acad::ErrorStatus acadReturnValue = Acad::eOk;

	AcGeMatrix3d xform(AcGeMatrix3d::kIdentity);
	int numIds = 0L;
	AcDbFullSubentPath* subentIds = NULL;

	// Check to see if entity is a supported solid, surface, region or body
	AcDb3dSolid* pSolid = NULL;
    AcDbSurface* pSurface = NULL;
	AcDbRegion* pRegion = NULL;
	AcDbBody* pBody = NULL;
	if ((pSolid = AcDb3dSolid::cast(pObj)) != NULL) {
		if (subType != AcDb::kNullSubentType) {
			acadReturnValue = pSolid->getSubentPathsAtGsMarker(
    			subType, marker, pickpnt, xform, numIds, subentIds);
			if (subentIds == NULL) acadReturnValue = Acad::ePointNotOnEntity;
			if (acadReturnValue != Acad::eOk) {
				acutPrintf(ACRX_T("\n getSubentPathsAtGsMarker failed\n"));
				errorReport((AcBr::ErrorStatus)acadReturnValue);
				return acadReturnValue;
			}
		}
		objIds2SubPath(objIdList, subType, subentIds, subPath);
    } else if ((pSurface = AcDbSurface::cast(pObj)) != NULL) {
		if (subType != AcDb::kNullSubentType) {
			acadReturnValue = pSurface->getSubentPathsAtGsMarker(
    			subType, marker, pickpnt, xform, numIds, subentIds);
			if (subentIds == NULL) acadReturnValue = Acad::ePointNotOnEntity;
			if (acadReturnValue != Acad::eOk) {
				acutPrintf(ACRX_T("\n getSubentPathsAtGsMarker failed\n"));
				errorReport((AcBr::ErrorStatus)acadReturnValue);
				return acadReturnValue;
			}
		}
		objIds2SubPath(objIdList, subType, subentIds, subPath);
    } else if ((pRegion = AcDbRegion::cast(pObj)) != NULL) {
		if (subType != AcDb::kNullSubentType) {
			acadReturnValue = pRegion->getSubentPathsAtGsMarker(
    			subType, marker, pickpnt, xform, numIds, subentIds);
			if (subentIds == NULL) acadReturnValue = Acad::ePointNotOnEntity;
			if (acadReturnValue != Acad::eOk) {
				acutPrintf(ACRX_T("\n getSubentPathsAtGsMarker failed\n"));
				errorReport((AcBr::ErrorStatus)acadReturnValue);
				return acadReturnValue;
			}
		}
		objIds2SubPath(objIdList, subType, subentIds, subPath);
    } else if ((pBody = AcDbBody::cast(pObj)) != NULL) {
		if (subType != AcDb::kNullSubentType) {
			acadReturnValue = pBody->getSubentPathsAtGsMarker(
    			subType, marker, pickpnt, xform, numIds, subentIds);
			if (subentIds == NULL) acadReturnValue = Acad::ePointNotOnEntity;
			if (acadReturnValue != Acad::eOk) {
				acutPrintf(ACRX_T("\n getSubentPathsAtGsMarker failed\n"));
				errorReport((AcBr::ErrorStatus)acadReturnValue);
				return acadReturnValue;
			}
		}
		objIds2SubPath(objIdList, subType, subentIds, subPath);
	} else {
		acutPrintf(ACRX_T("\n Selected object not a brep object\n"));
		return Acad::eWrongObjectType;
	}

	return acadReturnValue;
}