2015/utils/amodeler/samples/asdkbodyapp/asdkbodyui/AsdkBodyUi.cpp
//
// createExtrusionPath()
//
// Creates a CBody object from one or two profile faces
// (single-face AsdkBody objects) and an extrusion path.
//

createExtrusionPath()
Creates a CBody object from one or two profile faces
(single-face AsdkBody objects) and an extrusion path.
createExtrusionPath () Creates a CBody object from one or two profile faces ( single - face AsdkBody objects ) and an extrusion path .
void 
createExtrusionAlongPath()
{
    AsdkBody *pBody = NULL;
	AsdkBody *pStartFace, *pEndFace = NULL;
	MorphingMap *pMorphMap = NULL;
    AcGePoint3d *vertices = NULL;
	PolygonVertexData** vertexData = NULL;
	int iVertices;
    bool bClosePath;
    bool bCheckValidity;
    double scaleFactor, twistAngle;
    Point3d fixedPt = Point3d::kNull;
    try
    {
        ads_printf( ACRX_T("\nStart profile: ") );
        pStartFace = getFace();
        ads_printf( ACRX_T("\nEnd profile: ") );
	    pEndFace = getFace();
	    if( pEndFace == NULL ) {
		    pEndFace = new AsdkBody;  
            ads_printf(ACRX_T("\nNull end profile will be used."));
	    }
	    if (! pEndFace->body().isNull())
            pMorphMap = queryMorphingMap(pStartFace, pEndFace);
        if (pMorphMap == NULL)
            pMorphMap = new MorphingMap(MorphingMap::kNull);
        ads_printf(ACRX_T("\nExtrusion path: "));
        getPath(vertices, vertexData, iVertices);
        if (vertices == NULL)
        {
            ads_printf(ACRX_T("\nBad extrusion path.  *Bailing out*\n"));
            goto cleanup;
        }
	    ads_printf(ACRX_T("\nClose Path? "));
	    bClosePath = getYesNo(FALSE);
        scaleFactor = getReal(ACRX_T("\nScale factor <1.0>: "), 1.0);
        twistAngle = getReal(ACRX_T("\nTwist angle <0.0>: "), 0.0);
        if (scaleFactor != 1.0 || twistAngle != 0.0)
        {
            try {
                fixedPt = getPoint(ACRX_T("Select fixed point for scale/twist <0,0,0>: "));
            }
            catch (int caught_adsrc)
            {
                if (caught_adsrc)
                    fixedPt = Point3d::kNull;
                else
                    throw caught_adsrc;
            }
        }
        ads_printf(ACRX_T("\nCheck validity of result? "));
	    bCheckValidity = getYesNo();
        pBody = new AsdkBody;
		pBody->createExtrusionAlongPath(
            pStartFace->body(),
            pEndFace->body(), 
			vertices, 
            vertexData, 
            iVertices, 
            bClosePath,
            bCheckValidity,
            fixedPt,
			(double)scaleFactor, 
            (double)twistAngle, 
            *pMorphMap);
	}
    catch (int caught_adsrc)
    {
        handleADSError(caught_adsrc);
        goto cleanup;
    }
	catch (ErrorCode err) 
    {
        if (err == eFail)
        {
            ads_printf( ACRX_T("\nBody is not valid.  Continue?"));
            if(! getYesNo())
            {
                delete pBody;
                goto cleanup;
            }
        }
        else
        {
            ads_printf( ACRX_T("\nERROR: %s\n"), getErrorMsg(err));
            delete pBody;
            goto cleanup;
        }
    }
	if (append(pBody))
	{
        pBody->close();
	}
    else {
        delete pBody;
        ads_printf(ACRX_T("\nCould not add AsdkBody to ACAD Database.  *Bailing out*\n"));
    }
cleanup:
	cleanupEntity(pStartFace);
    cleanupEntity(pEndFace);
    delete [] vertices;
	delete [] vertexData;
}
void createExtrusionAlongPath ( ) { AsdkBody * pBody = NULL ; AsdkBody * pStartFace , * pEndFace = NULL ; MorphingMap * pMorphMap = NULL ; AcGePoint3d * vertices = NULL ; PolygonVertexData * * vertexData = NULL ; int iVertices ; bool bClosePath ; bool bCheckValidity ; double scaleFactor , twistAngle ; Point3d fixedPt = Point3d :: kNull ; try { ads_printf ( ACRX_T ( " \n " ) ) ; pStartFace = getFace ( ) ; ads_printf ( ACRX_T ( " \n " ) ) ; pEndFace = getFace ( ) ; if ( pEndFace == NULL ) { pEndFace = new AsdkBody ; ads_printf ( ACRX_T ( " \n " ) ) ; } if ( ! pEndFace -> body ( ) . isNull ( ) ) pMorphMap = queryMorphingMap ( pStartFace , pEndFace ) ; if ( pMorphMap == NULL ) pMorphMap = new MorphingMap ( MorphingMap :: kNull ) ; ads_printf ( ACRX_T ( " \n " ) ) ; getPath ( vertices , vertexData , iVertices ) ; if ( vertices == NULL ) { ads_printf ( ACRX_T ( " \n \n " ) ) ; goto cleanup ; } ads_printf ( ACRX_T ( " \n " ) ) ; bClosePath = getYesNo ( FALSE ) ; scaleFactor = getReal ( ACRX_T ( " \n " ) , 1.0 ) ; twistAngle = getReal ( ACRX_T ( " \n " ) , 0.0 ) ; if ( scaleFactor != 1.0 || twistAngle != 0.0 ) { try { fixedPt = getPoint ( ACRX_T ( " " ) ) ; } catch ( int caught_adsrc ) { if ( caught_adsrc ) fixedPt = Point3d :: kNull ; else throw caught_adsrc ; } } ads_printf ( ACRX_T ( " \n " ) ) ; bCheckValidity = getYesNo ( ) ; pBody = new AsdkBody ; pBody -> createExtrusionAlongPath ( pStartFace -> body ( ) , pEndFace -> body ( ) , vertices , vertexData , iVertices , bClosePath , bCheckValidity , fixedPt , ( double ) scaleFactor , ( double ) twistAngle , * pMorphMap ) ; } catch ( int caught_adsrc ) { handleADSError ( caught_adsrc ) ; goto cleanup ; } catch ( ErrorCode err ) { if ( err == eFail ) { ads_printf ( ACRX_T ( " \n " ) ) ; if ( ! getYesNo ( ) ) { delete pBody ; goto cleanup ; } } else { ads_printf ( ACRX_T ( " \n \n " ) , getErrorMsg ( err ) ) ; delete pBody ; goto cleanup ; } } if ( append ( pBody ) ) { pBody -> close ( ) ; } else { delete pBody ; ads_printf ( ACRX_T ( " \n \n " ) ) ; } cleanup : cleanupEntity ( pStartFace ) ; cleanupEntity ( pEndFace ) ; delete [ ] vertices ; delete [ ] vertexData ; }
createExtrusionPath()
Creates a CBody object from one or two profile faces
(single-face AsdkBody objects) and an extrusion path.
createExtrusionPath () Creates a CBody object from one or two profile faces ( single - face AsdkBody objects ) and an extrusion path .
// empty body
 // Get morphing map if there is an end face
 //
 // Get extrusion path
 //
 // Get scale factor and twist angle
 //
 //
 // User probably cancelled.  Clean up and bail out.
