设为首页收藏本站

中国膜结构网

 找回密码
 立即注册

QQ登录

只需一步,快速开始

膜结构车棚
膜结构车棚膜结构资质国产膜材 膜结构网中国膜结构协会
查看: 149|回复: 1

沿三维路径扫掠轮廓(闭合的样条线)

[复制链接]
  • TA的每日心情
    开心
    2021-6-19 14:40
  • 签到天数: 1539 天

    [LV.Master]伴坛终老

    发表于 2021-2-7 23:46 | 显示全部楼层 |阅读模式
    #include <aced.h>
    #include "rxregsvc.h"
    #include "acutads.h"
    #include "dbapserv.h"
    #include "dbsymtb.h"
    #include "gepnt3d.h"
    #include "dbsol3d.h"
    #include "dbents.h"
    #include "dbregion.h"


    static Acad::ErrorStatus postToDb(AcDbEntity* ent, AcDbObjectId& objId) {
       Acad::ErrorStatus      es;
       AcDbBlockTable*        pBlockTable;
       AcDbBlockTableRecord*  pSpaceRecord;
       if ((es = acdbHostApplicationServices()->workingDatabase()->
          getSymbolTable(pBlockTable, AcDb::kForRead))
          != Acad::eOk) {
             return es;
          }
       if ((es = pBlockTable->getAt(ACDB_MODEL_SPACE,  
          pSpaceRecord,
          AcDb::kForWrite)) != Acad::eOk) {
             return es;
          }
       if ((es = pBlockTable->close()) != Acad::eOk) {
          return es;
          }
       if ((es = pSpaceRecord->appendAcDbEntity(objId, ent)) != Acad::eOk) {
          return es;
          }
       if ((es = pSpaceRecord->close()) != Acad::eOk) {
          return es;
          }
       return ent->close();
       }


    bool LOCAL_createSweepedSolidAcad() {
       AcDb2dPolyline *pPolyProf = new AcDb2dPolyline();
       AcDb2dVertex *vp1 = new AcDb2dVertex( AcGePoint3d(  0, 0, 0 ) );  pPolyProf->appendVertex( vp1 );
       AcDb2dVertex *vp2 = new AcDb2dVertex( AcGePoint3d(  1, 1, 0 ) );  pPolyProf->appendVertex( vp2 );
       AcDb2dVertex *vp3 = new AcDb2dVertex( AcGePoint3d(  0, 5, 0 ) );  pPolyProf->appendVertex( vp3 );
       AcDb2dVertex *vp4 = new AcDb2dVertex( AcGePoint3d( -1, 1, 0 ) );  pPolyProf->appendVertex( vp4 );
       pPolyProf->makeClosed();

       AcDb3dPolyline *pPolyPath1 = new AcDb3dPolyline();
       AcDb3dPolylineVertex *v1a = new AcDb3dPolylineVertex( AcGePoint3d( 10,10,10 ) );  pPolyPath1->appendVertex( v1a );
       AcDb3dPolylineVertex *v1b = new AcDb3dPolylineVertex( AcGePoint3d( 20,20,12 ) );  pPolyPath1->appendVertex( v1b );

       AcDb3dPolyline *pPolyPath2 = new AcDb3dPolyline();
       AcDb3dPolylineVertex *v2a = new AcDb3dPolylineVertex( AcGePoint3d( -10,-10,10 ) );  pPolyPath2->appendVertex( v2a );
       AcDb3dPolylineVertex *v2b = new AcDb3dPolylineVertex( AcGePoint3d( -20,-20,12 ) );  pPolyPath2->appendVertex( v2b );

       AcDbSweepOptions sweepOptions;
       sweepOptions.setAlign( AcDbSweepOptions::kAlignSweepEntityToPath );
       sweepOptions.setBasePoint( AcGePoint3d(0,0,0) );
       
       AcDb3dSolid* cad3dSolid1 = new AcDb3dSolid();
       Acad::ErrorStatus es1 = cad3dSolid1->createSweptSolid( pPolyProf, pPolyPath1, sweepOptions );
       cad3dSolid1->setColorIndex(2);  
       AcDbObjectId idSolid1;
       postToDb( cad3dSolid1, idSolid1 );

       AcDb3dSolid* cad3dSolid2 = new AcDb3dSolid();
       Acad::ErrorStatus es2 = cad3dSolid2->createSweptSolid( pPolyProf, pPolyPath2, sweepOptions );
       cad3dSolid2->setColorIndex(2);  
       AcDbObjectId idSolid2;
       postToDb( cad3dSolid2, idSolid2 );

       delete pPolyPath1;
       delete pPolyPath2;
       delete pPolyProf;
       return es1 == Acad::eOk && es2 == Acad::eOk;
       }


    //******************************************************************************
    /// purpose: define new cad-command
    void runIt()
    {
    acutPrintf(L"\nTest-Command");
    LOCAL_createSweepedSolidAcad();
    }


    //******************************************************************************
    /// purpose: main function
    extern "C" AcRx::AppRetCode acrxEntryPoint(AcRx::AppMsgCode msg, void* appId)
    {
    switch(msg) {
       case AcRx::kInitAppMsg:
          acrxUnlockApplication(appId);
          acrxRegisterAppMDIAware(appId);
          acutPrintf(L"\nExample Application Loaded");
          acedRegCmds->addCommand(L"ASDK_MAKE_ENTS", L"ASDK_MKENTS", L"RUNIT", ACRX_CMD_MODAL, runIt);
          break;
       case AcRx::kUnloadAppMsg:
          acutPrintf(L"\nExample Application Unloaded");
          break;
       }
    return AcRx::kRetOK;
    }
    回复


    http://www.mjgw.org/ 专业从事膜结构设计、制作加工、施工安装的膜结构工程服务,能够为客户提供专业的膜结构整体解决方案。做中国最好的膜结构综合服务平台。欢迎大家联系电话:198-7840-1958,QQ:463017170.
    相关关键词:膜结构车棚,膜结构车棚覆盖,膜结构车棚公司,膜结构车棚多少钱,膜结构车棚厂家,膜结构车棚价格,社区膜结构车棚,膜结构车棚膜布厂家 ,膜结构车棚哪家好,膜结构车棚多少钱一米,膜结构车棚报价,膜结构车棚哪里有,膜结构车棚定制,膜结构车棚安装,膜结构车棚设计,膜结构车棚电话,膜结构车棚加工,膜结构车棚膜布价格,膜结构车棚批发,膜结构车棚制造商,膜结构车棚生产厂家,膜结构车棚设计,膜结构车棚施工,膜结构车棚多少钱一平米,膜结构车棚订制,张拉膜车棚,张拉膜车棚覆盖,张拉膜车棚公司,张拉膜车棚多少钱,张拉膜车棚厂家,张拉膜车棚价格,社区张拉膜车棚,张拉膜车棚膜布厂家 ,张拉膜车棚哪家好,张拉膜车棚多少钱一米,张拉膜车棚报价,张拉膜车棚哪里有,张拉膜车棚定制,张拉膜车棚安装,张拉膜车棚设计,张拉膜车棚电话,张拉膜车棚加工,张拉膜车棚膜布价格,张拉膜车棚批发,张拉膜车棚制造商,张拉膜车棚生产厂家,张拉膜车棚设计,张拉膜车棚施工,张拉膜车棚多少钱一平米,张拉膜车棚订制,常用膜材品牌:德国杜肯、法国法拉利、德国海德斯、德国米乐、日本平岗、韩国秀博、比利时希运、美国赫虏伯、中国科宝、上海慧遥。

    使用道具 举报

  • TA的每日心情
    开心
    2021-6-19 14:40
  • 签到天数: 1539 天

    [LV.Master]伴坛终老

     楼主| 发表于 2021-2-7 23:47 | 显示全部楼层
    // Calculat the alignment matrix.
    // The source object is supposed to be in XY-plane.
    // ptAlign of the source object shall be aligned to the startpoint of curve
    void calculateAlignmentMatrix(const AcGePoint3d &ptAlign, AcDbCurve *curve, AcGeMatrix3d &matAlign)
    {       
            AcGePoint3d ptStart;
            AcGeVector3d x, y, z;
            double parStart;

            curve->getStartPoint(ptStart);
            curve->getStartParam(parStart);
            curve->getFirstDeriv(parStart, z); // This is the start direction of the path.
            z.normalize();
            x = z.perpVector(); // x-axis direction. We use the "arbitrary axis algorithm here. Change to your needs.
            y = z.crossProduct(x);
            matAlign = AcGeMatrix3d::alignCoordSys(ptAlign, AcGeVector3d::kXAxis, AcGeVector3d::kYAxis, AcGeVector3d::kZAxis, ptStart, x, y, z);
    }

    bool LOCAL_createSweepedSolidAcad() {
            AcDb2dPolyline *pPolyProf = new AcDb2dPolyline();
            AcDb2dVertex *vp1 = new AcDb2dVertex(AcGePoint3d(0, 0, 0));  pPolyProf->appendVertex(vp1);
            AcDb2dVertex *vp2 = new AcDb2dVertex(AcGePoint3d(1, 1, 0));  pPolyProf->appendVertex(vp2);
            AcDb2dVertex *vp3 = new AcDb2dVertex(AcGePoint3d(0, 5, 0));  pPolyProf->appendVertex(vp3);
            AcDb2dVertex *vp4 = new AcDb2dVertex(AcGePoint3d(-1, 1, 0));  pPolyProf->appendVertex(vp4);
            pPolyProf->makeClosed();
            AcGePoint3d plineAlignmentPoint(0,0,0);

            AcDb3dPolyline *pPolyPath1 = new AcDb3dPolyline();
            AcDb3dPolylineVertex *v1a = new AcDb3dPolylineVertex(AcGePoint3d(10, 10, 10));  pPolyPath1->appendVertex(v1a);
            AcDb3dPolylineVertex *v1b = new AcDb3dPolylineVertex(AcGePoint3d(20, 20, 12));  pPolyPath1->appendVertex(v1b);

            AcDb3dPolyline *pPolyPath2 = new AcDb3dPolyline();
            AcDb3dPolylineVertex *v2a = new AcDb3dPolylineVertex(AcGePoint3d(-10, -10, 10));  pPolyPath2->appendVertex(v2a);
            AcDb3dPolylineVertex *v2b = new AcDb3dPolylineVertex(AcGePoint3d(-20, -20, 12));  pPolyPath2->appendVertex(v2b);

            AcDbSweepOptions sweepOptions;
            sweepOptions.setAlign(AcDbSweepOptions::kNoAlignment); // We align ourself. Was AcDbSweepOptions::kAlignSweepEntityToPath
            sweepOptions.setBasePoint(AcGePoint3d(0, 0, 0));

            AcGeMatrix3d matAlign;
            AcDbEntity *pPolyProfAligned1=NULL, *pPolyProfAligned2=NULL;
            Acad::ErrorStatus es;

            AcDb3dSolid* cad3dSolid1 = new AcDb3dSolid();
            calculateAlignmentMatrix(plineAlignmentPoint, pPolyPath1, matAlign);
            es = pPolyProf->getTransformedCopy(matAlign, pPolyProfAligned1);
            Acad::ErrorStatus es1 = cad3dSolid1->createSweptSolid(pPolyProfAligned1, pPolyPath1, sweepOptions);
            cad3dSolid1->setColorIndex(2);
            AcDbObjectId idSolid1;
            postToDb(cad3dSolid1, idSolid1);

            AcDb3dSolid* cad3dSolid2 = new AcDb3dSolid();
            calculateAlignmentMatrix(plineAlignmentPoint, pPolyPath2, matAlign);
            es = pPolyProf->getTransformedCopy(matAlign, pPolyProfAligned2);
            Acad::ErrorStatus es2 = cad3dSolid2->createSweptSolid(pPolyProfAligned2, pPolyPath2, sweepOptions);
            cad3dSolid2->setColorIndex(2);
            AcDbObjectId idSolid2;
            postToDb(cad3dSolid2, idSolid2);

            static int append=1;
            if (append)
            {
                    AcDbObjectId idPath1, idPath2, idPoly;
                    postToDb(pPolyPath1, idPath1);
                    postToDb(pPolyPath2, idPath2);
                    postToDb(pPolyProf, idPoly);
                    postToDb(pPolyProfAligned1, idPoly);
                    postToDb(pPolyProfAligned2, idPoly);
            }
            else
            {
                    delete pPolyPath1;
                    delete pPolyPath2;
                    delete pPolyProf;
                    delete pPolyProfAligned1;
                    delete pPolyProfAligned2;
            }

            return es1 == Acad::eOk && es2 == Acad::eOk;
    }
    回复 支持 反对

    使用道具 举报

    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    关闭

    推荐膜材品牌上一条 /6 下一条

    进口膜材 国产膜材 pvdf膜材ptfe膜材ETFE膜材
    最好的膜结构公司 一级膜结构资质 膜结构一级资质
    膜结构设计-膜结构十大品牌-etfe设计-充气膜结构
    诺科膜结构
    遨都膜结构设计
    中国膜结构网
    中国空间膜结构

    QQ|申请友链|手机版|中国膜结构论坛