# eryar

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

Abstract. To provide the precision required in industrial design, drawings need to offer the possibility of removing lines, which are hidden in a given projection. OpenCASCADE provides two algorithms for this Hidden Line Removal component. The paper mainly translate the document of OpenCASCADE Modeling Algorithms, and give some applications in the plant design CAD software.

Key Words. OpenCASCADE, HLR, Hidden Line Removal

1. Introduction

Figure 1.1 Drawing generated from 3D model by PDMS

v 物体A在物体B的后面；

v 物体A与物体B在投影平面上有重叠部分；

HLRBRep_Algo是根据模型来计算的一种高精度的算法，而HLRBRep_PolyAlgo是基于离散数据的算法。当使用HLRBRep_Algo时可以得到精确结果，而使用HLRBRep_PolyAlgo可以提高计算速度。他们两个算法都可以处理任意类型的模型，如组合体、面或线，但也有些约束，如下情况就未被处理：

v 点未被处理；

v Z平面上没有被裁剪；

v 无限面或线没有处理；

Figure 1.2 Sharp, smooth and sewn edges in a simple screw shape

Figure 1.3 Outline edges and isoparameters in the same shape

Figure 1.4 An extraction showing hidden sharp edges

2.HLR Usage

2.2 Setting View Parameters

2.3 Computing the Projections

2.4 Extracting Edges

v Visible/hidden sharp edges;

v Visible/hidden smooth edges;

v Visible/hidden sewn edges;

v Visible/hidden outline edges;

3.Examples

osg::Node* TestPolyHlr(void)
{
osg::ref_ptr
<osg::Geode> aGeode = new osg::Geode();
osg::ref_ptr
<osg::Geometry> aLineGeometry = new osg::Geometry();
osg::ref_ptr
<osg::Vec3Array> aVertices = new osg::Vec3Array();

TopoDS_Shape aPipeModel;
"d:/PipeModels/2007.brep", BRep_Builder());

BRepMesh_IncrementalMesh aMesher(aPipeModel,
0.1);

OSD_Timer aTimer;
aTimer.Start();

Handle_HLRBRep_PolyAlgo aHlrPolyAlgo
= new HLRBRep_PolyAlgo();

HLRAlgo_Projector aProjector;
HLRBRep_PolyHLRToShape aHlr2Shape;

aHlrPolyAlgo

aHlrPolyAlgo
->Projector(aProjector);
aHlrPolyAlgo
->Update();

aHlr2Shape.Update(aHlrPolyAlgo);

aTimer.Stop();
aTimer.Show(std::cout);

for (TopExp_Explorer e(aHlr2Shape.VCompound(), TopAbs_EDGE); e.More(); e.Next())
{
TopoDS_Edge anEdge
= TopoDS::Edge(e.Current());
TopoDS_Vertex aFirstVertex
= TopExp::FirstVertex(anEdge);
TopoDS_Vertex aLastVertex
= TopExp::LastVertex(anEdge);
gp_Pnt aFirstPoint
= BRep_Tool::Pnt(aFirstVertex);
gp_Pnt aLastPoint
= BRep_Tool::Pnt(aLastVertex);

aVertices
->push_back(osg::Vec3(aFirstPoint.X(), aFirstPoint.Y(), aFirstPoint.Z()));
aVertices
->push_back(osg::Vec3(aLastPoint.X(), aLastPoint.Y(), aLastPoint.Z()));
}

for (TopExp_Explorer e(aHlr2Shape.OutLineVCompound(), TopAbs_EDGE); e.More(); e.Next())
{
TopoDS_Edge anEdge
= TopoDS::Edge(e.Current());
TopoDS_Vertex aFirstVertex
= TopExp::FirstVertex(anEdge);
TopoDS_Vertex aLastVertex
= TopExp::LastVertex(anEdge);
gp_Pnt aFirstPoint
= BRep_Tool::Pnt(aFirstVertex);
gp_Pnt aLastPoint
= BRep_Tool::Pnt(aLastVertex);

aVertices
->push_back(osg::Vec3(aFirstPoint.X(), aFirstPoint.Y(), aFirstPoint.Z()));
aVertices
->push_back(osg::Vec3(aLastPoint.X(), aLastPoint.Y(), aLastPoint.Z()));
}

aLineGeometry
->setVertexArray(aVertices);
aLineGeometry

aGeode

return aGeode.release();
}

Figure 3.1 HLR for pipe model

Figure 3.2 HLR pipe model in OpenSceneGraph

Figure 3.3 HLR time usage

Figure 3.4 HLR pipe model in less tesslate precision

Figure 3.5 HLR pipe model in less tesslate precision time usage

4.Conclusion

5. References

1. OpenCASCADE Modeling Algorithms User Guide6.8.0 2014

2. 何援军. 计算机图形学. 机械工业出版社. 2010

3. 孙家广. 计算机图形学. 清华大学出版社. 2000