예제 #1
0
static AcBr::ErrorStatus 
countShells(const AcBrBrep& brepEntity)
{
	AcBr::ErrorStatus returnValue = AcBr::eOk;

	// make a global shell traverser
	AcBrBrepShellTraverser brepShellTrav;
	returnValue = brepShellTrav.setBrep(brepEntity);
	if (returnValue != AcBr::eOk) {
		acutPrintf(ACRX_T("\n Error in AcBrBrepShellTraverser::setBrep:"));
		errorReport(returnValue);
		return returnValue;
	}

	// count the shells
	int shellCount = 0;
	while (!brepShellTrav.done() && (returnValue == AcBr::eOk)) {
	    shellCount++;
		returnValue = brepShellTrav.next();
		if (returnValue != AcBr::eOk) {
			acutPrintf(ACRX_T("\n Error in AcBrBrepShellTraverser::next:"));  
			errorReport(returnValue);
			return returnValue;
		}
	}
	acutPrintf(ACRX_T("\n ***Brep has %d shells\n"), shellCount);	  

	return returnValue;
}
예제 #2
0
// Utility function to extract a useful, bounded curve with native
// curve definition data, from the external (bounded) curve
AcBr::ErrorStatus
getNativeCurve(const AcBrEdge& edgeEntity,
               AcGeCurve3d*&   curveGeometry,
               AcGeCurve3d*&   nativeGeometry)
{
    AcBr::ErrorStatus returnValue = edgeEntity.getCurve(curveGeometry);  
	if (returnValue != AcBr::eOk) {
		acutPrintf(ACRX_T("\n Error in AcBrEdge::getCurve:"));
        errorReport(returnValue);
        return returnValue;
	}
	if (curveGeometry == NULL) {
		acutPrintf(ACRX_T("\n getNativeCurve: external 3d curve is undefined\n"));
        returnValue = AcBr::eMissingGeometry;
        return returnValue;
	}
	if (curveGeometry->type() != kExternalCurve3d) {
		acutPrintf(ACRX_T("\n getNativeCurve: curve is not an external 3d curve\n"));
        returnValue = AcBr::eMissingGeometry;
        return returnValue;
	}
	if (!((AcGeExternalCurve3d*)curveGeometry)->isDefined()) {
		acutPrintf(ACRX_T("\n getNativeCurve: external 3d curve is undefined\n"));
        returnValue = AcBr::eMissingGeometry;
        return returnValue;
	}
	if (!((AcGeExternalCurve3d*)curveGeometry)->isNativeCurve(nativeGeometry)
	    || (nativeGeometry == NULL)) {
		acutPrintf(ACRX_T("\n getNativeCurve: native 3d curve is undefined\n"));
        returnValue = AcBr::eMissingGeometry;
        return returnValue;
	}
    return returnValue;
}
예제 #3
0
static AcBr::ErrorStatus 
countComplexes(const AcBrBrep& brepEntity)
{
	AcBr::ErrorStatus returnValue = AcBr::eOk;

	// make a global complex traverser
	AcBrBrepComplexTraverser brepComplexTrav;
	returnValue = brepComplexTrav.setBrep(brepEntity);
	if (returnValue != AcBr::eOk) {
		acutPrintf(ACRX_T("\n Error in AcBrBrepComplexTraverser::setBrep:"));
		errorReport(returnValue);
		return returnValue;
	}

	// count the faces
	int complexCount = 0;
	while (!brepComplexTrav.done() && (returnValue == AcBr::eOk)) {
	    complexCount++;
		returnValue = brepComplexTrav.next();
		if (returnValue != AcBr::eOk) {
			acutPrintf(ACRX_T("\n Error in AcBrBrepComplexTraverser::next:"));  
			errorReport(returnValue);
			return returnValue;
		}
	}
	acutPrintf(ACRX_T("\n ***Brep has %d complexes\n"), complexCount);	  

	return returnValue;
}
예제 #4
0
// Utility function to extract a useful 2d nurb curve with native
// definition data, from the external paramcurve
AcBr::ErrorStatus
getNativeParamCurve(const AcBrLoopEdgeTraverser& loopEdge,
                    AcGeCurve2d*&                pcurveGeometry,
                    AcGeNurbCurve2d&             nurbGeometry)
{
    AcBr::ErrorStatus returnValue = loopEdge.getParamCurve(pcurveGeometry);  
	if (returnValue != AcBr::eOk) {
		acutPrintf(ACRX_T("\n Error in AcBrLoopEdgeTraverser::getParamCurve:"));
        errorReport(returnValue);
        return returnValue;
	}
	if (pcurveGeometry == NULL) {
		acutPrintf(ACRX_T("\n getNativeParamCurve: external param curve is undefined\n"));
        returnValue = AcBr::eMissingGeometry;
        return returnValue;
	}
	if (pcurveGeometry->type() != kExternalCurve2d) {
		acutPrintf(ACRX_T("\n getNativeParamCurve: parameter curve is not an external 2d curve\n"));
        returnValue = AcBr::eMissingGeometry;
        return returnValue;
	}
	if (!((AcGeExternalCurve2d*)pcurveGeometry)->isDefined()) {
		acutPrintf(ACRX_T("\n getNativeParamCurve: external param curve is undefined\n"));
        returnValue = AcBr::eMissingGeometry;
        return returnValue;
	}
	if (!((AcGeExternalCurve2d*)pcurveGeometry)->isNurbCurve(nurbGeometry)) {
		acutPrintf(ACRX_T("\n getNativeParamCurve: native 2d nurb curve is undefined\n"));
        returnValue = AcBr::eMissingGeometry;
        return returnValue;
	}
    return returnValue;
}
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;
}
Adesk::Boolean pickViewport (AcDbViewport *&pVp) {
    ads_point p1, p2 ;
    
    if ( acedGetPoint (NULL, ACRX_T("\nPlease enter point 1: "), p1) != RTNORM )
        return (Adesk::kFalse) ;
    if ( acedGetPoint (p1, ACRX_T("\nPlease enter point 2: "), p2) != RTNORM )
        return (Adesk::kFalse) ;
    acdbUcs2Wcs (p1, p1, Adesk::kFalse ) ;
    acdbUcs2Wcs (p2, p2, Adesk::kFalse ) ;

    int frontClip =AfxMessageBox (ACRX_T("Would you like to clip at the front?"), MB_YESNO) ;
    int backClip =AfxMessageBox (ACRX_T("Would you like to clip at the back?"), MB_YESNO) ;
    
    pVp =new AcDbViewport ;
    pVp->setViewTarget (asPnt3d (p2)) ;
    pVp->setViewDirection (asPnt3d (p1) - asPnt3d (p2)) ;

    pVp->setFrontClipDistance (asPnt3d (p1).distanceTo (asPnt3d (p2))) ;
    pVp->setBackClipDistance (0) ;
    
    acutPrintf (ACRX_T("\nFront Clipping is %d"), pVp->isFrontClipOn ()) ;
    if ( frontClip == IDYES )
        pVp->setFrontClipOn () ;
    acutPrintf (ACRX_T("\nFront Clipping is %d"), pVp->isFrontClipOn ()) ;
    
    acutPrintf (ACRX_T("\nBack Clipping is %d"), pVp->isBackClipOn ()) ;
    if ( backClip == IDYES )
        pVp->setBackClipOn () ;
    acutPrintf(ACRX_T("\nBack Clipping is %d"), pVp->isBackClipOn ()) ;
    
    return (Adesk::kTrue) ;
}
void
entityAssociatedReport(AcBrEntity* entityAssociated)
{
	if (entityAssociated != NULL) {
		if (entityAssociated->isKindOf(AcBrBrep::desc())) {
		    acutPrintf(ACRX_T("\n Mesh subobject is inside the brep\n"));
		} else if (entityAssociated->isKindOf(AcBrFace::desc())) {
			acutPrintf(ACRX_T("\n Mesh subobject is on a face\n"));
		} else if (entityAssociated->isKindOf(AcBrEdge::desc())) {
			acutPrintf(ACRX_T("\n Mesh subobject is on an edge\n"));
		} else if (entityAssociated->isKindOf(AcBrVertex::desc())) {
			acutPrintf(ACRX_T("\n Mesh subobject is on a vertex\n"));
        } else acutPrintf(ACRX_T("\n Unsupported entity type encountered\n"));
	}
}
void
bblockReport(AcGePoint3d& min, AcGePoint3d& max)
{
    acutPrintf(ACRX_T("\n Bounding Block lower corner is ("));
	acutPrintf (ACRX_T("%lf, "), min.x);	
	acutPrintf (ACRX_T("%lf, "), min.y);
	acutPrintf (ACRX_T("%lf"), min.z);
	acutPrintf(ACRX_T(")\n"));	
    acutPrintf(ACRX_T("\n Bounding Block upper corner is ("));
	acutPrintf (ACRX_T("%lf, "), max.x);	
	acutPrintf (ACRX_T("%lf, "), max.y);
	acutPrintf (ACRX_T("%lf"), max.z);
	acutPrintf(ACRX_T(")\n"));	

	return;
}
예제 #9
0
//------------
// Get project's files names by using mask option.
bool listFiles()
{
    CLogger::Print(_T("*Call: listFiles()"));

    // Check whether or not a DENKI project is opening?
    if (!DenkiIsOpenProject()) {
        CLogger::Print(_T("*Exit: listFiles() - Denki project is not being opened!"));
        return false;
    }

    DenkiDwgProject* pProject = DenkiDwgProject::getCurrent();

    // Create a DenkiGetProjectFileMask object (mask option).
    DenkiGetProjectFileMask mask = (DenkiGetProjectFileMask)(MASK_DENKIZUMEN | MASK_SONOTAZUMEN);
    int nCount = 0;

    // Get project's files into an array.
    const LPCTSTR* pAryDwg = DenkiGetProjectFiles(mask, &nCount);
    if (!pAryDwg) {
        CLogger::Print(_T("*Exit: listFiles() - Fail to get the project's files names!"));
        return false;
    }

    // Steps through the array's items to print out its value.
    for (int nIdx=0; nIdx<nCount; nIdx++) {
        acutPrintf(ACRX_T("\n%02d:%s"), nIdx, pAryDwg[nIdx]);
        CLogger::Print(_T("Inform: %02d : %s"), nIdx, pAryDwg[nIdx]);
    }

    DenkiFreeCharPtrArray(pAryDwg); // Remember to free returned memory after using DenkiGetProjectFiles function
    CLogger::Print(_T("*Exit: listFiles()"));
    return true;
}
AcBr::ErrorStatus
nodeDump(const AcBrNode& node)
{
	AcBr::ErrorStatus returnValue = AcBr::eOk;

	// Determine the entity which contains this node
	AcBrEntity* entityAssociated = NULL;
	returnValue = node.getEntityAssociated(entityAssociated);
	if (returnValue != AcBr::eOk) {
		acutPrintf(ACRX_T("\n Error in AcBrNode::getEntityAssociated:"));
		errorReport(returnValue);
		delete entityAssociated;
		return returnValue;
	}
	entityAssociatedReport(entityAssociated);
	delete entityAssociated;

	AcGePoint3d nodePoint;
	returnValue = node.getPoint(nodePoint);
	if (returnValue != AcBr::eOk) {
		acutPrintf(ACRX_T("\n Error in AcBrNode::getPoint:"));
        errorReport(returnValue);
		return returnValue;
	}
	acutPrintf(ACRX_T("\n Node Point is ("));
	acutPrintf (ACRX_T("%lf, "), nodePoint.x);	
	acutPrintf (ACRX_T("%lf, "), nodePoint.y);
	acutPrintf (ACRX_T("%lf"), nodePoint.z);
	acutPrintf(ACRX_T(")\n"));	
	
	return returnValue;
}
void
ptContainmentReport(AcGe::PointContainment containment,
				    AcBrEntity*			   container)
{
    switch (containment) {
	case(AcGe::kOutside):
		acutPrintf(ACRX_T("\n Point is outside entity boundary\n"));
		break;
	case(AcGe::kInside):
		acutPrintf(ACRX_T("\n Point is inside entity boundary\n"));
		break;     
	case(AcGe::kOnBoundary):
		if (container != NULL) {
			if (container->isKindOf(AcBrFace::desc())) {
				acutPrintf(ACRX_T("\n Point is on a face boundary of entity\n"));
			} else if (container->isKindOf(AcBrEdge::desc())) {
				acutPrintf(ACRX_T("\n Point is on an edge boundary of entity\n"));
			} else if (container->isKindOf(AcBrVertex::desc())) {
				acutPrintf(ACRX_T("\n Point is on a vertex boundary of entity\n"));
			} else acutPrintf(ACRX_T("\n Indeterminate point containment\n"));
		}
		break;        
	default: 
		acutPrintf(ACRX_T("\n Indeterminate point containment\n"));
		break;    
	}

	return;
}
static AcDb::SubentType
subtype()
{
	// Query the subentity type
	AcDb::SubentType subType = AcDb::kNullSubentType;
    ACHAR opt[128];
   	while (Adesk::kTrue) {
		acutPrintf(ACRX_T("\nEnter Subent Type: "));
		acedInitGet(NULL, ACRX_T("Edge Face Brep"));
		if (acedGetKword(ACRX_T("Edge/Face/<Brep>: "), opt) == RTCAN) {
			subType = AcDb::kNullSubentType;
			break;
		}

        // Map the user input to a valid subentity type
		if ((_tcscmp(opt, ACRX_T("Brep")) == 0) || (_tcscmp(opt, ACRX_T("")) == 0)) {
			subType = AcDb::kNullSubentType;
			break;
        } else if (_tcscmp(opt, ACRX_T("Face")) == 0) {
			subType = AcDb::kFaceSubentType;
			break;
        } else if (_tcscmp(opt, ACRX_T("Edge")) == 0) {
			subType = AcDb::kEdgeSubentType;
			break;
		}
    }

	return subType;
}
예제 #13
0
// Add the given entity to the current Database
Acad::ErrorStatus
addToDatabase(AcDbEntity* pEnt, AcDbObjectId& objId)
{
    Acad::ErrorStatus acadReturnValue = Acad::eOk;
    AcDbBlockTable* pBlockTable;
    AcDbBlockTableRecord* pSpaceRecord;

	AcDbDatabase *pCurDwg = acdbHostApplicationServices()->workingDatabase();
    if (pCurDwg==NULL)
        return Acad::eNoDatabase;

    if ((acadReturnValue = pCurDwg->getBlockTable(pBlockTable,
        AcDb::kForRead)) != Acad::eOk) {
        acutPrintf(ACRX_T("\n acdbCurDwg()->getBlockTable() failed"));
        return acadReturnValue;
    }

    if ((acadReturnValue = pBlockTable->getAt(ACDB_MODEL_SPACE, 
        pSpaceRecord, AcDb::kForWrite)) != Acad::eOk) {
        acutPrintf(ACRX_T("\n AcDbBlockTable::getAt() failed"));
        return acadReturnValue;
    }
 
    // close the block table object
    if ((acadReturnValue = pBlockTable->close()) != Acad::eOk) {
        acutPrintf(ACRX_T("\n AcDbBlockTable::close() failed"));
        return acadReturnValue;
    }

    // append the entity to the display list
    if ((acadReturnValue = pSpaceRecord->appendAcDbEntity(objId, pEnt))
        != Acad::eOk) {
        acutPrintf(ACRX_T("\n AcDbBlockTableRecord::appendAcDbEntity() failed"));
        return acadReturnValue;
    }

    // close the block table record object
    if ((acadReturnValue = pSpaceRecord->close()) != Acad::eOk) {
        acutPrintf(ACRX_T("\n AcDbBlockTableRecord::close() failed"));
        return acadReturnValue;
    }

    return acadReturnValue;
}
예제 #14
0
void LSS10()
{
	CLogger::Print(_T("-------------| START LOGGING LESSONS 10 |--------------"));
	AcDbObjectId idCircle;
	Acad::ErrorStatus es;
	if (Acad::eOk != (es = createCircle(idCircle))) {
		acutPrintf(ACRX_T("Fail to call createCircle() function - Error: %s")
									, acadErrorStatusText(es));
	}
}
void
shellTypeReport(AcBr::ShellType shellType)
{
    switch (shellType) {
	case(AcBr::kShellUnclassified):
		acutPrintf(ACRX_T(" Shell type cannot be determined at this time\n"));
		break;        
    case(AcBr::kShellExterior):
		acutPrintf(ACRX_T(" This is the exterior shell\n"));
		break;
    case(AcBr::kShellInterior):
		acutPrintf(ACRX_T(" This is an interior shell\n"));
		break;
	default:
		acutPrintf(ACRX_T(" Unexpected shell type encountered\n"));
		break;
	}

	return;
}
예제 #16
0
bool printXData()
{
	CLogger::Print(_T("*Call: printxData()"));
	AcDbObject* pObj;
	
	//------------
	// Require to select an entity
	if (!(pObj = selectObject(AcDb::kForRead))) {
		CLogger::Print(_T("*Exit: printxData() - Object have not selected."));
		return false;
	}

	//------------
	// Require to enter xData application name
	ACHAR appname[133];
	if (RTNORM != acedGetString(NULL, ACRX_T("\nEnter the desired Xdata application name: "), appname)) 
	{
		CLogger::Print(_T("*Exit: printxData() - Fail to enter the application name!"));
		return false;
	}

	//------------
	// Read the xData that contained in object.
	// If application name is existing then print out its values.
	struct resbuf* pRb;
	pRb = pObj->xData(appname);
	pObj->close();
	if (pRb) {
		acutPrintf(ACRX_T("Inform: Application name '%s' is existing - The values are: "), appname);
		printList(pRb);
		acutRelRb(pRb); // release xData after using!
	} else {
		acutPrintf(ACRX_T("\n*Exit: printxData() - Application name '%s' is not existing."), appname);
		pObj->close();
		return false;
	}

	pObj->close();
	CLogger::Print(_T("*Exit: printxData()"));
	return true;
}
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
loopTypeReport(AcBr::LoopType loopType)
{
    switch (loopType) {
	case(AcBr::kLoopUnclassified):
		acutPrintf(ACRX_T(" Loop type cannot be determined at this time, or is ambiguous\n"));
		break;        
    case(AcBr::kLoopExterior):
		acutPrintf(ACRX_T(" This is the exterior loop\n"));
		break;
    case(AcBr::kLoopInterior):
		acutPrintf(ACRX_T(" This is an interior loop\n"));
		break;
    case(AcBr::kLoopWinding):
		acutPrintf(ACRX_T(" This is a winding loop on an analytic surface\n"));
		break;
	default:
		acutPrintf(ACRX_T(" Unexpected loop type encountered\n"));
		break;
	}

	return;
}
예제 #19
0
// Utility function to extract a useful, unbounded surface with native
// surface definition data, from the external bounded surface
AcBr::ErrorStatus
getNativeSurface(const AcBrFace& faceEntity,
                 AcGeSurface*&   surfaceGeometry,
                 AcGeSurface*&   nativeGeometry)
{
    AcBr::ErrorStatus returnValue = faceEntity.getSurface(surfaceGeometry);  
	if (returnValue != AcBr::eOk) {
		acutPrintf(ACRX_T("\n Error in AcBrFace::getSurface:"));
    	errorReport(returnValue);
        return returnValue;
	}
	if (surfaceGeometry == NULL) {
		acutPrintf(ACRX_T("\n getNativeSurface: external bounded surface is undefined\n"));
        returnValue = AcBr::eMissingGeometry;
        return returnValue;
	}
	if (surfaceGeometry->type() != kExternalBoundedSurface) {
		acutPrintf(ACRX_T("\n getNativeSurface: surface is not an external bounded surface\n"));
        returnValue = AcBr::eMissingGeometry;
        return returnValue;
	}
	AcGeExternalSurface baseGeometry;
	((AcGeExternalBoundedSurface*)surfaceGeometry)->getBaseSurface(baseGeometry);
	if (!baseGeometry.isDefined()) {
		acutPrintf(ACRX_T("\n getNativeSurface: external surface is undefined\n"));
        returnValue = AcBr::eMissingGeometry;
        return returnValue;
	}
	if (!baseGeometry.isNativeSurface(nativeGeometry)
	    || (nativeGeometry == NULL)) {
		acutPrintf(ACRX_T("\n getNativeSurface: native surface is undefined\n"));
        returnValue = AcBr::eMissingGeometry;
        return returnValue;
	}
    return returnValue;
}
void
errorReport(AcBr::ErrorStatus errorCode)
{
    switch (errorCode) {
	case(AcBr::eBrepChanged):
		acutPrintf(ACRX_T(" Brep Changed\n"));
		break;        
    case(AcBr::eUnsuitableTopology):
		acutPrintf(ACRX_T(" Unsuitable Topology\n"));
		break;        
    case(AcBr::eDegenerateTopology):
		acutPrintf(ACRX_T(" Degenerate Topology\n"));
		break;        
    case(AcBr::eUninitialisedObject):
		acutPrintf(ACRX_T(" Uninitialised Object\n"));
		break;        
	default: 
		acutPrintf(ACRX_T(" AutoCAD Error Code: %d\n"), errorCode);
		acadErrorStatusText((Acad::ErrorStatus)errorCode);
		break;    
	}

	return;
}
AcBr::ErrorStatus
nodeDisplay(const AcBrNode& node, AcGePoint3dArray& pts)
{
	AcBr::ErrorStatus returnValue = AcBr::eOk;

	AcGePoint3d nodePoint;	
	returnValue = node.getPoint(nodePoint);
	if (returnValue != AcBr::eOk) {
		acutPrintf(ACRX_T("\n Error in AcBrNode::getPoint:"));
        errorReport(returnValue);
		return returnValue;
	}
    pts.append((const AcGePoint3d&)nodePoint);
    
	return returnValue;
}
void
trimSurface()
{								  
    AcBr::ErrorStatus returnValue = AcBr::eOk;
    Acad::ErrorStatus acadReturnValue = eOk;

    // Get the subentity path for a face
	AcDbFullSubentPath subPath(kNullSubent);
	acadReturnValue = selectEntity(AcDb::kFaceSubentType, subPath);
	if (acadReturnValue != eOk) {
		acutPrintf(ACRX_T("\n Error in getPath: %d"), acadReturnValue);
		return;
	}

	// Make a face entity to access the surface
	AcBrFace faceEntity;
	returnValue = faceEntity.set(subPath);
	if (returnValue != AcBr::eOk) {
		acutPrintf(ACRX_T("\n Error in AcBrFace::set:"));
		errorReport(returnValue);
		return;
	}

	// Query the style for trimmed surface dump
	Adesk::Boolean trimmed = Adesk::kTrue;
    ACHAR opt[128];
   	while (Adesk::kTrue) {
		acutPrintf(ACRX_T("\nSelect Style for Trimmed Surface Dump: "));
		acedInitGet(NULL, ACRX_T("Nurb Trimmed"));
		if (acedGetKword(ACRX_T("Nurb/<Trimmed>: "), opt) == RTCAN) return;

        // Map the user input to a valid dump style
		if ((_tcscmp(opt, ACRX_T("Trimmed")) == 0) || (_tcscmp(opt, ACRX_T("")) == 0)) {
            trimmed = Adesk::kTrue;
            break;
        } else if ((_tcscmp(opt, ACRX_T("Nurb")) == 0)) {
            trimmed = Adesk::kFalse;
            break;
	    }
    }

	(trimmed) ? faceToTrimmedSurface(faceEntity) : faceToNurbSurface(faceEntity);

	return;
}
static Adesk::Boolean
localContext()
{
	// Query local vs. database context for model
	Adesk::Boolean context = Adesk::kFalse;
    ACHAR opt[128];
   	while (Adesk::kTrue) {
		acutPrintf(ACRX_T("\nSelect Local Entity vs. Database Entity: "));
		acedInitGet(NULL, ACRX_T("Local Database"));
		if (acedGetKword(ACRX_T("Local/<Database>: "), opt) == RTCAN) break;
		if ((_tcscmp(opt, ACRX_T("Database")) == 0) || (_tcscmp(opt, ACRX_T("")) == 0)) {
            context = Adesk::kFalse;
            break;
        } else if ((_tcscmp(opt, ACRX_T("Local")) == 0)) {
            context = Adesk::kTrue;
            break;
	    }
    }

	return context;
}
static AcBr::ValidationLevel
validationLevel()
{
	// Query validation level for model
	AcBr::ValidationLevel vlevel = AcBr::kFullValidation;
    ACHAR opt[128];
   	while (Adesk::kTrue) {
		acutPrintf(ACRX_T("\nSelect No Validation vs. Full Validation: "));
		acedInitGet(NULL, ACRX_T("None Full"));
		if (acedGetKword(ACRX_T("None/<Full>: "), opt) == RTCAN) break;
		if ((_tcscmp(opt, ACRX_T("Full")) == 0) || (_tcscmp(opt, ACRX_T("")) == 0)) {
            vlevel = AcBr::kFullValidation;
            break;
        } else if ((_tcscmp(opt, ACRX_T("None")) == 0)) {
            vlevel = AcBr::kNoValidation;
            break;
	    }
    }

	return vlevel;
}
예제 #25
0
AcBr::ErrorStatus
faceDump(const AcBrFace& faceEntity)
{ 
    AcBr::ErrorStatus returnValue = AcBr::eOk;

	// Verify that AcBr was explicitly and not implicitly loaded,
	// by testing ObjectARX functions (which are unavailable unless
	// explicitly loaded)
    if (faceEntity.isA() == NULL) {
        acutPrintf(ACRX_T("\n faceDump: AcBrEntity::isA() failed\n"));
        return returnValue;
    }
    if (!faceEntity.isKindOf(AcBrFace::desc())) {
        acutPrintf(ACRX_T("\n faceDump: AcBrEntity::isKindOf() failed\n"));
        return returnValue;
    }
	AcBrEntity* entClass = (AcBrEntity*)&faceEntity;
	AcBrEdge* pEdge = AcBrEdge::cast(entClass);  
	if (pEdge != NULL) {
		acutPrintf(ACRX_T("\n faceDump: AcBrEntity::cast() failed\n"));
        return (AcBrErrorStatus)Acad::eNotThatKindOfClass;
	} 

	AcGe::EntityId entId;
	returnValue = faceEntity.getSurfaceType(entId);  
	if (returnValue != AcBr::eOk) {
		acutPrintf(ACRX_T("\n Error in AcBrFace::getSurfaceType:"));
		errorReport(returnValue);
        return returnValue;
	}

	AcGeSurface* surfaceGeometry = NULL;
    AcGeSurface* nativeGeometry = NULL;

	// NOTE: ignore unsupported geometry types for now, since we already know
	// that elliptic cylinders and elliptic cones are rejected by AcGe, but we
	// can still perform useful evaluations on the external bounded surface.
	returnValue = getNativeSurface(faceEntity, surfaceGeometry, nativeGeometry);  
	if ((returnValue != AcBr::eOk) && (returnValue
		!= (AcBrErrorStatus)Acad::eInvalidInput)) {
		acutPrintf(ACRX_T("\n Error in getNativeSurface:"));
		errorReport(returnValue);
        delete surfaceGeometry;
        delete nativeGeometry;
        return returnValue;
	}

	switch (entId) {
	case(kPlane):
	{ 
		acutPrintf(ACRX_T("\nSurface Type: Plane\n"));
        AcGePlane* planeGeometry = (AcGePlane*)nativeGeometry;
        AcGePoint3d pt = planeGeometry->pointOnPlane();
        AcGeVector3d normal = planeGeometry->normal();
		acutPrintf(ACRX_T("\nSurface Definition Data Begin:\n"));
		acutPrintf(ACRX_T(" Point on Plane is ("));
		acutPrintf (ACRX_T("%lf , "), pt.x);	
		acutPrintf (ACRX_T("%lf , "), pt.y);
		acutPrintf (ACRX_T("%lf "), pt.z);
		acutPrintf(ACRX_T(")\n"));	
		acutPrintf(ACRX_T(" Plane normal direction is ("));
		acutPrintf (ACRX_T("%lf , "), normal.x);	
		acutPrintf (ACRX_T("%lf , "), normal.y);
		acutPrintf (ACRX_T("%lf "), normal.z);
		acutPrintf(ACRX_T(")\n"));	
		acutPrintf(ACRX_T("Surface Definition Data End\n"));
		break;
    } 
	
	case(kSphere):
    {
		acutPrintf(ACRX_T("\nSurface Type: Sphere\n"));
        AcGeSphere* sphereGeometry = (AcGeSphere*)nativeGeometry;
        AcGePoint3d centre = sphereGeometry->center();
		double ang1, ang2, ang3, ang4;
        sphereGeometry->getAnglesInU(ang1, ang2);
        sphereGeometry->getAnglesInV(ang3, ang4);
        AcGePoint3d north = sphereGeometry->northPole();
        AcGePoint3d south = sphereGeometry->southPole();
		acutPrintf(ACRX_T("\nSurface Definition Data Begin:\n"));
		acutPrintf(ACRX_T(" Sphere centre is ("));
		acutPrintf (ACRX_T("%lf , "), centre.x);	
		acutPrintf (ACRX_T("%lf , "), centre.y);
		acutPrintf (ACRX_T("%lf "), centre.z);
		acutPrintf(ACRX_T(")\n"));	
		acutPrintf(ACRX_T(" Sphere radius is %lf\n"), sphereGeometry->radius());
		acutPrintf(ACRX_T(" Sphere start angle in U is %lf\n"), ang1);
		acutPrintf(ACRX_T(" Sphere end angle in U is %lf\n"), ang2);
		acutPrintf(ACRX_T(" Sphere start angle in V is %lf\n"), ang3);
		acutPrintf(ACRX_T(" Sphere end angle in V is %lf\n"), ang4);
		acutPrintf(ACRX_T(" Sphere north pole is ("));
		acutPrintf (ACRX_T("%lf , "), north.x);	
		acutPrintf (ACRX_T("%lf , "), north.y);
		acutPrintf (ACRX_T("%lf "), north.z);
		acutPrintf(ACRX_T(")\n"));	
		acutPrintf(ACRX_T(" Sphere south pole is ("));
		acutPrintf (ACRX_T("%lf , "), south.x);	
		acutPrintf (ACRX_T("%lf , "), south.y);
		acutPrintf (ACRX_T("%lf "), south.z);
		acutPrintf(ACRX_T(")\n"));	
		acutPrintf(ACRX_T("Surface Definition Data End\n"));
		break;
    }
	
	case(kTorus):
    {
		acutPrintf(ACRX_T("\nSurface Type: Torus\n"));
        AcGeTorus* torusGeometry = (AcGeTorus*)nativeGeometry;
        AcGePoint3d centre = torusGeometry->center();
		double ang1, ang2, ang3, ang4;
        torusGeometry->getAnglesInU(ang1, ang2);
        torusGeometry->getAnglesInV(ang3, ang4);
		acutPrintf(ACRX_T("\nSurface Definition Data Begin:\n"));
		acutPrintf(ACRX_T(" Torus centre is ("));
		acutPrintf (ACRX_T("%lf , "), centre.x);	
		acutPrintf (ACRX_T("%lf , "), centre.y);
		acutPrintf (ACRX_T("%lf "), centre.z);
		acutPrintf(ACRX_T(")\n"));	
		acutPrintf(ACRX_T(" Torus major radius is %lf\n"), torusGeometry->majorRadius());
		acutPrintf(ACRX_T(" Torus minor radius is %lf\n"), torusGeometry->minorRadius());
		acutPrintf(ACRX_T(" Torus start angle in U is %lf\n"), ang1);
		acutPrintf(ACRX_T(" Torus end angle in U is %lf\n"), ang2);
		acutPrintf(ACRX_T(" Torus start angle in V is %lf\n"), ang3);
		acutPrintf(ACRX_T(" Torus end angle in V is %lf\n"), ang4);
		acutPrintf(ACRX_T("Surface Definition Data End\n"));
		break;	
	}	
	
	case(kCylinder):
    {
		acutPrintf(ACRX_T("\nSurface Type: Circular Cylinder\n"));
        AcGeCylinder* cylinderGeometry = (AcGeCylinder*)nativeGeometry;
        AcGePoint3d origin = cylinderGeometry->origin();
		double ang1, ang2;
        cylinderGeometry->getAngles(ang1, ang2);
        AcGeInterval ht;
        cylinderGeometry->getHeight(ht);
        double height = ht.upperBound() - ht.lowerBound();
        AcGeVector3d refAxis = cylinderGeometry->refAxis();
        AcGeVector3d symAxis = cylinderGeometry->axisOfSymmetry();
		acutPrintf(ACRX_T("\nSurface Definition Data Begin:\n"));
		acutPrintf(ACRX_T(" Circular Cylinder origin is ("));
		acutPrintf (ACRX_T("%lf , "), origin.x);	
		acutPrintf (ACRX_T("%lf , "), origin.y);
		acutPrintf (ACRX_T("%lf "), origin.z);
		acutPrintf(ACRX_T(")\n"));	
		acutPrintf(ACRX_T(" Circular Cylinder radius is %lf\n"), cylinderGeometry->radius());
		acutPrintf(ACRX_T(" Circular Cylinder start angle is %lf\n"), ang1);
		acutPrintf(ACRX_T(" Circular Cylinder end angle is %lf\n"), ang2);
		if (cylinderGeometry->isClosedInU())
			acutPrintf(ACRX_T(" Circular Cylinder height is %lf\n"), height);
        else acutPrintf(ACRX_T(" Circular Cylinder is not closed in U\n"));
		acutPrintf(ACRX_T(" Circular Cylinder reference axis is ("));
		acutPrintf (ACRX_T("%lf , "), refAxis.x);	
		acutPrintf (ACRX_T("%lf , "), refAxis.y);
		acutPrintf (ACRX_T("%lf "), refAxis.z);
		acutPrintf(ACRX_T(")\n"));	
		acutPrintf(ACRX_T(" Circular Cylinder axis of symmetry is ("));
		acutPrintf (ACRX_T("%lf , "), symAxis.x);	
		acutPrintf (ACRX_T("%lf , "), symAxis.y);
		acutPrintf (ACRX_T("%lf "), symAxis.z);
		acutPrintf(ACRX_T(")\n"));	
		acutPrintf(ACRX_T("Surface Definition Data End\n"));
		break;
    }

	case(kCone):
    {
		acutPrintf(ACRX_T("\nSurface Type: Circular Cone\n"));
        AcGeCone* coneGeometry = (AcGeCone*)nativeGeometry;
        AcGePoint3d centre = coneGeometry->baseCenter();
		double ang1, ang2;
        coneGeometry->getAngles(ang1, ang2);
        AcGeVector3d axis1 = coneGeometry->axisOfSymmetry();
        AcGeVector3d axis2 = coneGeometry->refAxis();
        AcGePoint3d apex = coneGeometry->apex();
		double cosAng, sinAng;
        coneGeometry->getHalfAngle(cosAng, sinAng);
        AcGeInterval ht;
        coneGeometry->getHeight(ht);
        double height = ht.upperBound() - ht.lowerBound();
		acutPrintf(ACRX_T("\nSurface Definition Data Begin:\n"));
		acutPrintf(ACRX_T(" Circular Cone base centre is ("));
		acutPrintf (ACRX_T("%lf , "), centre.x);	
		acutPrintf (ACRX_T("%lf , "), centre.y);
		acutPrintf (ACRX_T("%lf "), centre.z);
		acutPrintf(ACRX_T(")\n"));	
		acutPrintf(ACRX_T(" Circular Cone base radius is %lf\n"), coneGeometry->baseRadius());
		acutPrintf(ACRX_T(" Circular Cone start angle is %lf\n"), ang1);
		acutPrintf(ACRX_T(" Circular Cone end angle is %lf\n"), ang2);
		acutPrintf(ACRX_T(" Circular Cone axis of symmetry is ("));
		acutPrintf (ACRX_T("%lf , "), axis1.x);	
		acutPrintf (ACRX_T("%lf , "), axis1.y);
		acutPrintf (ACRX_T("%lf "), axis1.z);
		acutPrintf(ACRX_T(")\n"));	
		acutPrintf(ACRX_T(" Circular Cone reference axis is ("));
		acutPrintf (ACRX_T("%lf , "), axis2.x);	
		acutPrintf (ACRX_T("%lf , "), axis2.y);
		acutPrintf (ACRX_T("%lf "), axis2.z);
		acutPrintf(ACRX_T(")\n"));	
		acutPrintf(ACRX_T(" Circular Cone apex is ("));
		acutPrintf (ACRX_T("%lf , "), apex.x);	
		acutPrintf (ACRX_T("%lf , "), apex.y);
		acutPrintf (ACRX_T("%lf "), apex.z);
		acutPrintf(ACRX_T(")\n"));	
		acutPrintf(ACRX_T(" Circular Cone cosine of major half-angle is %lf\n"), cosAng);
		acutPrintf(ACRX_T(" Circular Cone sine of major half-angle is %lf\n"), sinAng);
		if (coneGeometry->isClosedInU())
			acutPrintf(ACRX_T(" Circular Cone height is %lf\n"), height);
        else acutPrintf(ACRX_T(" Circular Cone is not closed in U\n"));
		acutPrintf(ACRX_T("Surface Definition Data End\n"));
		break;
    }
	
	case(kNurbSurface):
    {
		acutPrintf(ACRX_T("\nSurface Type: NURB Surface\n"));
        AcGeNurbSurface* nurbGeometry = (AcGeNurbSurface*)nativeGeometry;
		int nCtrlPtsU = nurbGeometry->numControlPointsInU();
		int nCtrlPtsV = nurbGeometry->numControlPointsInV();
		int nKnotsU = nurbGeometry->numKnotsInU();
		int nKnotsV = nurbGeometry->numKnotsInV();
		acutPrintf(ACRX_T("\nSurface Definition Data Begin:\n"));
		acutPrintf(ACRX_T(" NURB Surface degree in U is %d\n"), nurbGeometry->degreeInU());
		acutPrintf(ACRX_T(" NURB Surface degree in V is %d\n"), nurbGeometry->degreeInV());
		acutPrintf(ACRX_T(" NURB Surface number of control points in U is %d\n"), nCtrlPtsU);
		acutPrintf(ACRX_T(" NURB Surface number of control points in V is %d\n"), nCtrlPtsV);
		acutPrintf(ACRX_T(" NURB Surface number of knots in U is %d\n"), nKnotsU);
		acutPrintf(ACRX_T(" NURB Surface number of knots in V is %d\n"), nKnotsV);
		acutPrintf(ACRX_T("Surface Definition Data End\n"));
		break;
    }
	
	// NOTE: This surface is not yet supported in AcGe, so we infer the definition
	// data by analysing evaluated data on the external bounded surface.
	case(kEllipCylinder):
	{
		acutPrintf(ACRX_T("\nSurface Type: Elliptic Cylinder\n"));
        AcGePoint3d p0 = surfaceGeometry->evalPoint(AcGePoint2d(0.0, 0.0));
        AcGePoint3d p1 = surfaceGeometry->evalPoint(AcGePoint2d(0.0, kPi));
        AcGePoint3d p2 = surfaceGeometry->evalPoint(AcGePoint2d(0.0, kHalfPi));
        AcGePoint3d origin(((p0.x + p1.x) / 2.0),
			               ((p0.y + p1.y) / 2.0),
						   ((p0.z + p1.z) / 2.0));
        AcGeVector3d majAxis = p0 - origin;
        AcGeVector3d minAxis = p2 - origin;
        AcGeVector3d symAxis = (majAxis.crossProduct(minAxis)).normalize();
		acutPrintf(ACRX_T("\nSurface Definition Data Begin:\n"));
		acutPrintf(ACRX_T(" Elliptic Cylinder origin is ("));
		acutPrintf (ACRX_T("%lf , "), origin.x);	
		acutPrintf (ACRX_T("%lf , "), origin.y);
		acutPrintf (ACRX_T("%lf "), origin.z);
		acutPrintf(ACRX_T(")\n"));	
		acutPrintf(ACRX_T(" Elliptic Cylinder major radius is %lf\n"), majAxis.length());
		acutPrintf(ACRX_T(" Elliptic Cylinder minor radius is %lf\n"), minAxis.length());
		acutPrintf(ACRX_T(" Elliptic Cylinder major axis is ("));
		acutPrintf (ACRX_T("%lf , "), majAxis.x);	
		acutPrintf (ACRX_T("%lf , "), majAxis.y);
		acutPrintf (ACRX_T("%lf "), majAxis.z);
		acutPrintf(ACRX_T(")\n"));	
		acutPrintf(ACRX_T(" Elliptic Cylinder minor axis is ("));
		acutPrintf (ACRX_T("%lf , "), minAxis.x);	
		acutPrintf (ACRX_T("%lf , "), minAxis.y);
		acutPrintf (ACRX_T("%lf "), minAxis.z);
		acutPrintf(ACRX_T(")\n"));	
		acutPrintf(ACRX_T(" Elliptic Cylinder axis of symmetry is ("));
		acutPrintf (ACRX_T("%lf , "), symAxis.x);	
		acutPrintf (ACRX_T("%lf , "), symAxis.y);
		acutPrintf (ACRX_T("%lf "), symAxis.z);
		acutPrintf(ACRX_T(")\n"));	
		acutPrintf(ACRX_T("Surface Definition Data End\n"));
		break;
	}

	// NOTE: This surface is not yet supported in AcGe, so we infer the definition
	// data by analysing evaluated data on the external bounded surface.
	case(kEllipCone):
	{
		acutPrintf(ACRX_T("\nSurface Type: Elliptic Cone\n"));
        AcGePoint3d p0 = surfaceGeometry->evalPoint(AcGePoint2d(0.0, 0.0));
        AcGePoint3d p1 = surfaceGeometry->evalPoint(AcGePoint2d(0.0, kPi));
        AcGePoint3d p2 = surfaceGeometry->evalPoint(AcGePoint2d(0.0, kHalfPi));
        AcGePoint3d p3 = surfaceGeometry->evalPoint(AcGePoint2d(1.0, 0.0));
        AcGePoint3d centre(((p0.x + p1.x) / 2.0),
			               ((p0.y + p1.y) / 2.0),
						   ((p0.z + p1.z) / 2.0));
        AcGeVector3d majAxis = p0 - centre;
        AcGeVector3d minAxis = p2 - centre;
        AcGeVector3d symAxis = (majAxis.crossProduct(minAxis)).normalize();
		double halfAng = kHalfPi - majAxis.angleTo(p3 - p0);
		acutPrintf(ACRX_T("\nSurface Definition Data Begin:\n"));
		acutPrintf(ACRX_T(" Elliptic Cone base centre is ("));
		acutPrintf (ACRX_T("%lf , "), centre.x);	
		acutPrintf (ACRX_T("%lf , "), centre.y);
		acutPrintf (ACRX_T("%lf "), centre.z);
		acutPrintf(ACRX_T(")\n"));	
		acutPrintf(ACRX_T(" Elliptic Cone base major radius is %lf\n"), majAxis.length());
		acutPrintf(ACRX_T(" Elliptic Cone base minor radius is %lf\n"), minAxis.length());
		acutPrintf(ACRX_T(" Elliptic Cone major axis is ("));
		acutPrintf (ACRX_T("%lf , "), majAxis.x);	
		acutPrintf (ACRX_T("%lf , "), majAxis.y);
		acutPrintf (ACRX_T("%lf "), majAxis.z);
		acutPrintf(ACRX_T(")\n"));	
		acutPrintf(ACRX_T(" Elliptic Cone minor axis is ("));
		acutPrintf (ACRX_T("%lf , "), minAxis.x);	
		acutPrintf (ACRX_T("%lf , "), minAxis.y);
		acutPrintf (ACRX_T("%lf "), minAxis.z);
		acutPrintf(ACRX_T(")\n"));	
		acutPrintf(ACRX_T(" Elliptic Cone axis of symmetry is ("));
		acutPrintf (ACRX_T("%lf , "), symAxis.x);	
		acutPrintf (ACRX_T("%lf , "), symAxis.y);
		acutPrintf (ACRX_T("%lf "), symAxis.z);
		acutPrintf(ACRX_T(")\n"));	
		acutPrintf(ACRX_T(" Elliptic Cone cosine of major half-angle is %lf\n"), cos(halfAng));
		acutPrintf(ACRX_T(" Elliptic Cone sine of major half-angle is %lf\n"), sin(halfAng));
		acutPrintf(ACRX_T("Surface Definition Data End\n"));
		break;
	}

	default:
		acutPrintf(ACRX_T("\nSurface Type: Unexpected Non Surface\n"));
		return (AcBrErrorStatus)Acad::eInvalidInput;
	} // end switch(entId)	
    
	delete nativeGeometry;

	// Evaluate the surface - note that the u,v bounds will not consider any
	// holes in the surface. To compute a u,v zone of exclusion for evaluation,
	// check for additional (i.e., inner) loops and get the bounding boxes for
	// the loops, then convert those to parameter space boxes. There is no
	// particular guarantee that outer loop(s) are the first in the face-loop
	// list, however, and we currently have no way to query a loop to find out
	// which type it is. Still, the maximal u,v parameter range will be useful
	// for most surfaces and most evaluation purposes.
	AcGeInterval uParam;
	AcGeInterval vParam;
	((AcGeExternalBoundedSurface*)surfaceGeometry)->getEnvelope(uParam, vParam);
    // Make sure the u,v values are legal and the envelope is bounded
    if ((uParam.isBounded()) && (vParam.isBounded())) {
		AcGePoint2d midRange;
		midRange.x = uParam.lowerBound() + (uParam.length() / 2.0);
		midRange.y = vParam.lowerBound() + (vParam.length() / 2.0);
		AcGePoint3d pointOnSurface =
			((AcGeExternalBoundedSurface*)surfaceGeometry)->evalPoint(midRange);
		acutPrintf(ACRX_T("\nSurface Evaluation Begin:\n"));
		acutPrintf(ACRX_T(" Parameter space bounds are (("));
        acutPrintf(ACRX_T("%lf, "), uParam.lowerBound());
        acutPrintf(ACRX_T("%lf "), uParam.upperBound());
        acutPrintf(ACRX_T("), (\n"));
        acutPrintf(ACRX_T("%lf, "), vParam.lowerBound());
        acutPrintf(ACRX_T("%lf "), vParam.upperBound());
        acutPrintf(ACRX_T("))\n"));
		acutPrintf(ACRX_T(" Parameter space mid-range is ("));
        acutPrintf(ACRX_T(" %lf, "), midRange.x);
        acutPrintf(ACRX_T("%lf "), midRange.y);
        acutPrintf(ACRX_T(")\n"));
		acutPrintf(ACRX_T(" Point on surface is ("));
		acutPrintf (ACRX_T("%lf , "), pointOnSurface.x);	
		acutPrintf (ACRX_T("%lf , "), pointOnSurface.y);
		acutPrintf (ACRX_T("%lf "), pointOnSurface.z);
		acutPrintf(ACRX_T(")\n"));	
		acutPrintf(ACRX_T("Surface Evaluation End\n"));
    }
	delete surfaceGeometry;

	Adesk::Boolean oriented;
	returnValue = faceEntity.getOrientToSurface(oriented);
	if (returnValue != AcBr::eOk) {
		acutPrintf(ACRX_T("\n Error in AcBrFace::getOrientToSurface:"));
        errorReport(returnValue);
		return returnValue;
	} 
	oriented ? acutPrintf(ACRX_T("\nSurface Orientation is Positive\n"))
	    : acutPrintf(ACRX_T("\nSurface Orientation is Negative\n"));

	return returnValue;
}
AcBr::ErrorStatus
selectEntityByType(AcBrEntity*& pEnt, AcDb::SubentType& subType)
{
	Acad::ErrorStatus acadReturnValue = Acad::eOk;
	AcBr::ErrorStatus returnValue = AcBr::eOk;

	// Query validation level
	AcBr::ValidationLevel vlevel = validationLevel();

	// Query the subentity type
	subType = subtype();

	// Query whether to select a database entity or create a new one
	Adesk::Boolean context = (subType != AcDb::kNullSubentType)
		? Adesk::kFalse : localContext();

	if (!context) {
		// Query the subentity by AutoCAD pick and get the subentity path
		AcDbFullSubentPath subPath(kNullSubent);
		acadReturnValue = selectEntity(subType, subPath);
		if (acadReturnValue != Acad::eOk) {
			acutPrintf(ACRX_T("\n Error in selectEntity: %d"), acadReturnValue);
			return (AcBr::ErrorStatus)acadReturnValue;
		}

		// Call the appropriate subentity constructor
		switch (subType) {
		case AcDb::kNullSubentType:
    		pEnt = new AcBrBrep();
			break;
		case AcDb::kFaceSubentType:
    		pEnt = new AcBrFace();
			break;
		case AcDb::kEdgeSubentType:
    		pEnt = new AcBrEdge();
			break;  
		default:
			acutPrintf(ACRX_T("\n selectEntityByType: unsupported subentity type: %d\n"), subType);
			returnValue = (AcBr::ErrorStatus)Acad::eWrongSubentityType;
			return returnValue;
		}
		if (pEnt == NULL) {
			acutPrintf(ACRX_T("\n selectEntityByType: unable to allocate memory\n"));
			returnValue = (AcBr::ErrorStatus)Acad::eOutOfMemory;
			return returnValue;
		}

		returnValue = pEnt->set(subPath);
		if (returnValue != AcBr::eOk) {
    		acutPrintf(ACRX_T("\n Error in AcBrEntity::set:"));
    		errorReport(returnValue);
    		return returnValue;
		}
	} else {
		// Create the entity as a local object
		AcDbEntity* pEntity;
		acadReturnValue = createEntity(pEntity);
		if (acadReturnValue != Acad::eOk) {
			acutPrintf(ACRX_T("\n Error in createEntity: %d"), acadReturnValue);
			return (AcBr::ErrorStatus)acadReturnValue;
		}
		if (pEntity == NULL) {
			acutPrintf(ACRX_T("\n selectEntityByType: unable to allocate memory\n"));
			returnValue = (AcBr::ErrorStatus)Acad::eOutOfMemory;
			return returnValue;
		}

    	pEnt = new AcBrBrep();
		if (pEnt == NULL) {
			acutPrintf(ACRX_T("\n selectEntityByType: unable to allocate memory\n"));
			returnValue = (AcBr::ErrorStatus)Acad::eOutOfMemory;
			return returnValue;
		}

		returnValue = ((AcBrBrep*)pEnt)->set((const AcDbEntity&)*pEntity);
		if (returnValue != AcBr::eOk) {
    		acutPrintf(ACRX_T("\n Error in AcBrEntity::set:"));
    		errorReport(returnValue);
    		return returnValue;
		}
	}

	returnValue = pEnt->setValidationLevel(vlevel);
	if (returnValue != AcBr::eOk) {
    	acutPrintf(ACRX_T("\n Error in AcBrEntity::setValidationLevel:"));
    	errorReport(returnValue);
    	return returnValue;
	}

	return returnValue;
}
예제 #27
0
void CControlsDlg::OnMeshsilhouettes () {
    mEdit.SetWindowText (ACRX_T("Should we calculate silhouette curves on polyface meshes\r\n")) ;
}
예제 #28
0
void CControlsDlg::OnHonorinternals () {
    mEdit.SetWindowText (ACRX_T("Should we process internal edges' visibility?\r\n(i.e. AcDbPolyFaceMesh / ACIS internal common edge)")) ;
}
예제 #29
0
void CControlsDlg::OnSubentity () {
    mEdit.SetWindowText (ACRX_T("Should the subenty information be returned\r\nfor solids?")) ;
}
void asdktest3 () {
    //----- Create a line and a circle (memory only)
    AcDbLine *pLine =new AcDbLine (AcGePoint3d (), AcGePoint3d (100, 100, -100)) ;
    AcDbCircle *pCircle =new AcDbCircle (AcGePoint3d (50, 50, 0), AcGeVector3d (0, 0, 1) , 25.0) ;

    //----- Create a region from the circle
    AcDbVoidPtrArray arr1, arr2 ;
    arr1.append (pCircle) ;
    AcDbRegion::createFromCurves (arr1, arr2) ;
    AcDbRegion *pRegion =(AcDbRegion *)arr2.at (0) ;
    delete pCircle ;

    //----- Add the line and the region objects to the collector
    //----- NB: Remember those object are memory objects only
    AsdkHlrCollector collector ;
    collector.setDeleteState (true) ;
    collector.addEntity (pLine) ;
    collector.addEntity (pRegion) ;

    //----- Process hidden line removal
    AsdkHlrEngine hlr (AcGePoint3d (50, 50,0), AcGeVector3d (0, 0, 1), kEntity | kBlock | kShowAll | kProject | kHonorInternals) ;
    hlr.run (collector) ;

    //----- To easily see the result, we do append resulting entities to the current database
    //----- and use the color convention used in command 'TEST1'
    int n =collector.mOutputData.logicalLength () ;
    for ( int i =0 ; i < n ; i++ ) {
        AsdkHlrData *p =collector.mOutputData [i] ;

        AcDbEntity *pEnt =p->getResultEntity () ;
        AsdkHlrData::Visibility vis =p->getVisibility () ;
        if ( vis == AsdkHlrData::kVisible )
            pEnt->setColorIndex (1) ;
        else
            pEnt->setColorIndex (5) ;
        AcDbObjectId id ;
        if ( postToDatabase (NULL, pEnt, id) != Acad::eOk ) {
            acutPrintf (_T("Failed to add entity to current space.\n")) ;
            break ;
        }

        //----- Entity originator path
        AcDbObjectIdArray ids =p->getObjectIds () ;
        if ( ids.logicalLength () > 0 ) {
            acutPrintf (ACRX_T("\n%ld, "), pEnt->objectId ().asOldId ()) ;
            for ( int j =0 ; j < ids.logicalLength () ; j++ ) {
                acutPrintf (ACRX_T("%ld, "), ids.at (j).asOldId ()) ;
            }
        }

        pEnt->close () ;
    }
}