OpenCascade Ruled Surface

OpenCascade Ruled Surface

eryar@163.com

Abstract. A ruled surface is formed by moving a line connecting points of equal relative arc length or equal relative parametric value on two parametric curves from a start point to a terminate point on the curves. The paper focus on the ruled surface in opencascade.

Key words. OpenCascade, Ruled Surface,

1.Introduction

《解析几何》中有关于直纹面Ruled Surface的定义:一曲面S称为直纹面,如果存在一族直线使得这一族中的每一条直线全在S上。并且S上的每个点都在这一族的某一条直线上。这样一族直线称为S的一族直母线。其参数方程为:

wps_clip_image-10134

即可以将直纹面看作是曲面对当v=0和1时得到的两个边界曲线之间进行线性插值得到的曲面。

wps_clip_image-2878

Autodesk 3DS Max中的直纹面,图片来自:

https://knowledge.autodesk.com/support/3ds-max/learn-explore/caas/CloudHelp/cloudhelp/2015/ENU/3DSMax/files/GUID-364FE529-431B-448A-850B-DD9BBECAC90B-htm.html

直纹面是从两条曲线来构造曲面的方法,Coons曲面是由四边条界曲线来构造曲面,理解直纹面的构造原理,为进一步理解通用的放样Sweep造型打下基础。

2.Ruled Surface Parametric Equation

直纹面的参数方程也可以写成如下形式:

wps_clip_image-19769

直接根据参数方程可以定义出相应的直纹面。在OpenCASCADE中话,可以从Geom_Surface派生新的类,并实现相应的虚函数。如实现计算对应参数u,v的值的虚函数D0()等。为了简单起见,用相应的函数计算直纹面上的点,并生成OpenCASCADE Draw Test Harness的命令脚本文件,方便在Draw中可视化。

如有名的Mobius Strip也是个直纹面:

wps_clip_image-4834

Mobius Strip的参数方程为:

wps_clip_image-26570

根据上述参数方程在OpenCASCADE的Draw生成Mobius Strip,代码如下所示:

const Standard_Real MOBIUS_RADIUS = 50.0;

void MobiusStrip(Standard_Real theU, Standard_Real theV, gp_Pnt& thePoint)

{

    thePoint.SetX((MOBIUS_RADIUS + theU * Cos(0.5 * theV)) * Cos(theV));

    thePoint.SetY((MOBIUS_RADIUS + theU * Cos(0.5 * theV)) * Sin(theV));

    thePoint.SetZ(theU * Sin(0.5 * theV));

}

void TestMobiusStrip()

{

    std::ofstream aTclFile("d:/mobius.tcl");

    aTclFile << "pload ALL" << std::endl;

    aTclFile << "vinit" << std::endl;

    Standard_Real aWidth = 10.0;

    Standard_Integer aN = 0;

for (Standard_Real s = -aWidth; s < aWidth; s += 1.0)

{

        aTclFile << "polyline p" << ++aN ;

for (Standard_Real t = 0.0; t < M_PI * 2.0; t += 0.01)

{

            gp_Pnt aPoint;

            MobiusStrip(s, t, aPoint);

            aTclFile << " " << aPoint.X() << " " << aPoint.Y() << " " << aPoint.Z();

}

        aTclFile << "\n vdisplay p" << aN << std::endl;

}

for (Standard_Real t = 0.0; t < M_PI * 2.0; t += 0.2)

{

        aTclFile << "polyline p" << ++aN;

        gp_Pnt aPoint;

        MobiusStrip(-aWidth, t, aPoint);

        aTclFile << " " << aPoint.X() << " " << aPoint.Y() << " " << aPoint.Z();

        MobiusStrip(aWidth, t, aPoint);

        aTclFile << " " << aPoint.X() << " " << aPoint.Y() << " " << aPoint.Z();

        aTclFile << "\n vdisplay p" << aN << std::endl;

}

}

int main(int argc, char* argv[])

{

    TestMobiusStrip();

return 0;

}

在D盘生成一个mobius.tcl脚本文件,直接在Draw Test Harness中输入命令:

source d:/mobius.tcl

即可得到如下图所示的Mobius环:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/zyfxgj.html