天气与日历 切换到窄版

 找回密码
 立即注册
中国膜结构网
十大进口膜材评选 十大国产膜材评选 十大膜结构设计评选 十大膜结构公司评选
查看: 3|回复: 0

[ARX函数]:AcGeInterval

[复制链接]
  • TA的每日心情
    开心
    昨天 15:23
  • 签到天数: 69 天

    [LV.6]常住居民II

    410

    主题

    167

    回帖

    2704

    积分

    管理员

    积分
    2704
    发表于 2024-6-22 09:46:18 | 显示全部楼层 |阅读模式
    #include <aced.h>
    #include <adslib.h>
    #include <geassign.h>   // asDblArray
    #include <gecone.h>
    #include <gessint.h>
    #include <dbxutil.h>     // acdbWcs2Ucs



    void dcgMdtDrawInfo(const AcGeCurve3d* crv,short color)
    {
            // ads_printf("\nCurve is a %d", crv->type() );
            AcGeInterval iv; double lb,ub; double nominalRange = 10.0;
            crv->getInterval(iv);
            if( iv.isUnBounded() )
            {
                    ads_printf("\nCurve is unbounded");  
                    lb = -(nominalRange / 2.0);  
                    ub = nominalRange / 2.0;
            }
            else
            {  
                    iv.getBounds(lb,ub);
                    if( iv.isBounded() )
                    {  
                            ads_printf("\nCurve is bounded");
                    }
                    else if( iv.isBoundedBelow() )
                    {   
                            ads_printf("\nCurve is unbounded above");  
                            ub = lb + nominalRange;
                    }
                    else
                    {  
                            ads_printf("\nCurve is unbounded below");
                            lb = ub - nominalRange;
                    }  
            }  
            ads_printf("\nBounds of curve [lower,upper] = [%.3lf,%.3lf]",lb,ub);
            AcGePoint3dArray pts;
            AcGeDoubleArray params;  
            crv->getSamplePoints( lb, ub, 0.01, pts, params );
            int nPts = pts.length();
            AcGePoint3d start = pts[0];
            acdbWcs2Ucs(asDblArray(start),asDblArray(start),Adesk::kFalse);
            ads_printf("\nGot %d sample points",nPts);
            for( int i=1;i<nPts; i++ )
            {  
                    AcGePoint3d end = pts;  
                    ads_printf("\nSamplePoint [%d] = (%.3lf,%.3lf,%.3lf)",i,pts.x,pts.y,pts.z);
                    acdbWcs2Ucs(asDblArray(end),asDblArray(end),Adesk::kFalse);
                    ads_grdraw(asDblArray(start),asDblArray(end),color,0);
                    start = end;
            }
    }


    void dcgMdtDrawInfo(const AcGeSurface* srf,int color)
    {
            AcGeInterval vi,ui;
            double vlb,vub,ulb,uub; srf->getEnvelope(ui,vi);
            vi.getBounds(vlb,vub); ui.getBounds(ulb,uub);
            double vstep = (vub-vlb) / 4;
            AcGePoint3d p1,p2;
            double ustep = (uub - ulb) / 100;
            AcGePoint2d param(ulb,vlb);
            p1 = srf->evalPoint(param);
            while(param.y < vub)
            {
                    param.x = ulb;
                    p1 = srf->evalPoint(param);
                    acdbWcs2Ucs(asDblArray(p1),asDblArray(p1),Adesk::kFalse);  
                    while(param.x < uub)
                    {
                            param.x += ustep;  
                            p2 = srf->evalPoint(param);
                            acdbWcs2Ucs(asDblArray(p2),asDblArray(p2),Adesk::kFalse);   
                            ads_grdraw(asDblArray(p1),asDblArray(p2),color,0);
                            p1 = p2;
                    }
                    param.y += vstep;
            }
            param.y = vub;
            param.x = ulb;
            p1 = srf->evalPoint(param);
            while(param.x < uub)
            {
                    param.x += ustep;
                    p2 = srf->evalPoint(param);
                    acdbWcs2Ucs(asDblArray(p2),asDblArray(p2),Adesk::kFalse);
                    ads_grdraw(asDblArray(p1),asDblArray(p2),color,0);
                    p1 = p2;
            }
            param.y += vstep;
            vstep = (vub-vlb) / 100;
            ustep = (uub - ulb) / 4;
            param.set(ulb,vlb);
            while(param.x < uub)
            {  
                    param.y = vlb;
                    p1 = srf->evalPoint(param);  
                    while(param.y < vub)  
                    {
                            param.y += vstep;
                            p2 = srf->evalPoint(param);
                            acdbWcs2Ucs(asDblArray(p2),asDblArray(p2),Adesk::kFalse);
                            ads_grdraw(asDblArray(p1),asDblArray(p2),color,0);
                            p1 = p2;
                    }
                    param.x += ustep;  
            }
            param.x = uub;
            param.y = vlb;
            p1 = srf->evalPoint(param);
            while(param.y < vub)
            {  
                    param.y += vstep;  
                    p2 = srf->evalPoint(param);
                    acdbWcs2Ucs(asDblArray(p2),asDblArray(p2),Adesk::kFalse);
                    ads_grdraw(asDblArray(p1),asDblArray(p2),color,0);
                    p1 = p2;
            }
            param.x += ustep;
    }   


    void printInfo(AcGe::ssiConfig config)
    {
            switch(config)
            {
            case AcGe::kXOut :
                    ads_printf("\n      kXOut : Curve neighborhood is outside the surface.");
                    break;
            case AcGe::kXIn:  ads_printf("\n      kXIn  : Curve neighborhood is inside the surface.");
                    break;
            case AcGe::kXTanOut :  ads_printf("\n      kXTanOut : Curve neighborhood is outside the surface.");   
                    break;
            case AcGe::kXTanIn :  ads_printf("\n      kXTanIn  : Curve neighborhood is inside the surface.");
                    break;
            default :
                    ads_printf("\n      unknown ssiConfig %d",config);
                    break;
            }
    }

    void getIntConfigs(const AcGeSurfSurfInt& surfInt)
    {
            AcGeIntersectError err;
            int numResult = surfInt.numResults(err);
            int dim;
            AcGe::ssiConfig surf1Left,surf1Right,surf2Left,surf2Right;
            AcGe::ssiType intType;
            ads_printf("\n Configs of intersection : ");
            for(int i=0;i<numResult;i++)
            {  
                    surfInt.getIntConfigs(i,surf1Left,surf1Right,surf2Left,surf2Right,intType,dim,err);  
                    ads_printf("\n   Intersection %d",i);
                    ads_printf("\n   surf1Left : ");  printInfo(surf1Left);
                    ads_printf("\n   dim = %d",dim);
            }
    }


    int testfun()
    {
            double cosineAngle =  0.7071067811865;
            double sineAngle = - 0.7071067811865;
            AcGePoint3d origin(0,0,0);
            double radius = 2;
            AcGeVector3d axis(0,0,1);  
            AcGeIntersectError err;
            Boolean isExternal = kTrue;  // Draw the cone with ads_grdraw for visualization
            AcGeCone geCone(cosineAngle,sineAngle,origin,radius,axis);
            dcgMdtDrawInfo(&geCone,3);  
            ads_printf("\nFirst test case : "); // take the same cone and intersect it with a xz-plane
            AcGeCone hCone(cosineAngle,sineAngle,origin,radius,axis);
            AcGePlane hPlane(AcGePoint3d(0,0,0),AcGeVector3d(0,0,1));
            AcGeSurfSurfInt surfSurfInt(hCone,hPlane);
            getIntConfigs(surfSurfInt);
            int numInters = surfSurfInt.numResults(err);
            ads_printf("\nGot %d intersections : err = %d",numInters,err);
            AcGeCurve3d* pIntersCurve;
            for(int k=0;k<numInters;k++)
            {
                    pIntersCurve = surfSurfInt.intCurve(k,isExternal,err);
                    ads_printf("\nsurfSurfInt: err = %d",numInters,err);
                    if(pIntersCurve)  
                            dcgMdtDrawInfo(pIntersCurve,1);
            }  // intersect the cone with another plane
            ads_printf("\n\nSecond test case : ");
            AcGePlane hPlane2(AcGePoint3d(0,0,1.0),AcGeVector3d(0.1, 0, 1.0));
            AcGeSurfSurfInt surfSurfInt2(hCone,hPlane2);
            getIntConfigs(surfSurfInt2);  
            numInters = surfSurfInt2.numResults(err);
            ads_printf("\nGot %d intersections : err = %d",numInters,err);
            for(k=0;k<numInters;k++)
            {
                    pIntersCurve = surfSurfInt2.intCurve(k,isExternal,err);  
                    ads_printf("\nsurfSurfInt: err = %d",numInters,err);
                    if(pIntersCurve)   
                            dcgMdtDrawInfo(pIntersCurve,1);
            }
            // intersect the cone with a plane on the cones tip
            ads_printf("\n\nThird test case : ");
            AcGePlane hPlane3(AcGePoint3d(0,0,2),AcGeVector3d(0,0,1));
            AcGeSurfSurfInt surfSurfInt3(hCone,hPlane3);
            getIntConfigs(surfSurfInt3);  
            numInters = surfSurfInt3.numResults(err);
            ads_printf("\nGot %d intersections : err = %d",numInters,err);
            AcGePoint3d isPoint;
            for(k=0;k<numInters;k++)
            {
                    isPoint = surfSurfInt3.intPoint(k,err);  
                    ads_printf("\nIntersection point at (%.3lf,%.3lf,%.3lf)",isPoint.x,isPoint.y,isPoint.z);
            }
            return 1;
    }

     

     

     

     

    [ARX函数]:AcGeInterval
    中国膜结构网打造全中国最好的膜结构综合平台 ,统一协调膜结构设计,膜结构施工,膜材采购,膜材定制,膜结构预算全方位服务。 中国空间膜结构协会合作单位。
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    QQ|Archiver|手机版|中国膜结构网|中国膜结构协会|进口膜材|国产膜材|ETFE|PVDF|PTFE|设计|施工|安装|车棚|看台|污水池|

    GMT+8, 2024-7-1 05:56 , Processed in 0.059806 second(s), 23 queries .

    Powered by Discuz! X3.5

    © 2001-2024 Discuz! Team.

    快速回复 返回顶部 返回列表