# eryar

PipeCAD - Plant Piping Design Software.
RvmTranslator - Translate AVEVA RVM to OBJ, glTF, etc.
posts - 603, comments - 590, trackbacks - 0, articles - 0

Abstract. Rendering a generic surface is a two steps process: first, computing the points that will form the mesh of the surface and then, send this mesh to 3D API. Use the Triangle to triangulate the parametric space and then lifting map to the model 3D space. This is the main method to visualize the generic shaded surface. This paper show the OpenCascade triangulation of the parametric space and  the map result: mesh in 3D model space. Use the method can visualize a generic surface.

1. Introduction

u COMPSOLID由面共享的SOLID组成；

u SOLID（Cylinder, Cone, Sphere, Torus, etc.）由SHELLS分隔出来的体（Volume）；

u SHELL由边Edges相连的FACES组成；

u FACE是一个映射（MAP），从矩形的参数UV空间映射到3D空间。（Cylinder: [0, 2*PI] x[0, H] -> R3，Cone, Sphere, Torus, Bezier Surface, NURBS Surface, etc.）

u FACE的边界由WIRE组成；

u WIRE由相连的EDGES组成；

u EDGE也是一个映射，从一维参数空间U映射到3D空间。（Bezier’s Curve: [0,1] -> R3， NURBS Curve, etc.）

u VERTEX是用来限制EDGE的；

Figure 2.1 Shape BRep in OpenCascade

Figure 2.2 Graph structure of the BRep Shape

3. How the Mesh is Generated

for (TopExp_Explorer edgeExp(theCompSolid, TopAbs_EDGE);
edgeExp.More();
edgeExp.Next())
{

// The U-interval of the EDGE is subdivided into

// segments with respect to the edge length and

// deflection in 3D-space. By the map, the segments

// of the U-interval give the segments in 3D-Space.
const TopoDS_Edge& theEdge = TopoDS::Edge(edgeExp.Current());

GCPnts_TangentialDeflection thePointsOnCurve;
Standard_Real u
= 0.0;
gp_Pnt aPoint;

for (Standard_Integer i = 1; i <= thePointsOnCurve.NbPoints(); ++i)
{
u
= thePointsOnCurve.Parameter(i);
aPoint
= thePointsOnCurve.Value(i);
}
}

Figure 3.1 Creation of U-Mesh and 3D-Mesh for each EDGE

for (TopExp_Explorer faceExp(theCompSolid, TopAbs_FACE);
faceExp.More();
faceExp.Next())
{

for (TopExp_Explorer wireExp(faceExp.Current(), TopAbs_WIRE);
wireExp.More();
wireExp.Next())
{

for (TopExp_Explorer edgeExp(wireExp.Current(), TopAbs_EDGE);
edgeExp.More();
edgeExp.Next())
{

// The U-Mesh of the EDGE is assembled after scaling in the

// UV-domain to constitute the WIRE.
Standard_Real theFirst = 0.0;
Standard_Real theLast
= 0.0;
gp_Pnt2d theUV;

Handle_Geom2d_Curve thePCurve
=
BRep_Tool::CurveOnSurface(theEdge, theFace, theFirst, theLast);

theUV
= thePCurve.Value(theFirst);
}
}
}

Figure 3.2 Hole in Parametric UV space

Figure 3.3 Hole in Surface

for (TopExp_Explorer faceExp(theCompSolid, TopAbs_FACE);
faceExp.More();
faceExp.Next())
{

// The 3d-mesh of the FACE is assembled to form the

// boundary of the SOLID.
}

Figure 3.4 Mesh of the Shape

4. Deflection Control

osg::Geode* BuildUVMesh(const Handle_Poly_Triangulation& theMesh)
{
osg::ref_ptr
<osg::Geode> theGeode = new osg::Geode();
osg::ref_ptr
<osg::Geometry> theTriangles = new osg::Geometry();
osg::ref_ptr
<osg::Vec3Array> theVertices = new osg::Vec3Array();

for (Standard_Integer t = 1; t <= theMesh->NbTriangles(); ++t)
{

const Poly_Triangle& theTriangle = theMesh->Triangles().Value(t);

gp_Pnt2d theUV1
= theMesh->UVNodes().Value(theTriangle(1));
gp_Pnt2d theUV2
= theMesh->UVNodes().Value(theTriangle(2));
gp_Pnt2d theUV3
= theMesh->UVNodes().Value(theTriangle(3));

theVertices
->push_back(osg::Vec3(theUV1.X(), 0.0, theUV1.Y()));
theVertices
->push_back(osg::Vec3(theUV2.X(), 0.0, theUV2.Y()));
theVertices
->push_back(osg::Vec3(theUV3.X(), 0.0, theUV3.Y()));
}

theTriangles
->setVertexArray(theVertices.get());
theTriangles

new osg::DrawArrays(osg::PrimitiveSet::TRIANGLES, 0, theVertices->size()));

osgUtil::SmoothingVisitor smv;
smv.smooth(
*theTriangles);

theGeode

return theGeode.release();
}

Figure 4.1 Triangulation of the Sphere parametric space

Figure 4.2 Triangulation of the Sphere

Figure 4.3 Triangulation of the Sphere Generated by Netgen

Figure 4.4 Triangulation of the Sphere

Figure 4.5 Triangulation of a Shape by Netgen

Figure 4.6 Triangulation of a Shape by OpenCascade

Figure 4.7 Shaded mode of the Shape

5. Conclusions

6. References

1. Alain PERRONNET. NEF: A Mesher based on OpenCascade C.A.D software

2. Kelly Dempski. Focus on Curves and Surfaces. Premier Press 2003

### Feedback

http://www.cppblog.com/eryar/archive/2014/01/01/205102.html

@Mr Li

@Sirius

https://wenku.baidu.com/view/92524de981c758f5f61f678f.html
@eryar

@Sirius

 只有注册用户登录后才能发表评论。 【推荐】100%开源！大型工业跨平台软件C++源码提供，建模，组态！ 相关文章: