0
点赞
收藏
分享

微信扫一扫

OCC笔记:访问拓扑边TopoDS_Edge的起末点


步骤

  • 使用TopExp取出拓扑边TopoDS_Edge的起末拓扑顶点TopoDS_Vertex;
  • 使用BRep_Tool从拓扑顶点取出几何点gp_Pnt

测试代码

#include <iostream>
#include "BRepBuilderAPI_MakeEdge.hxx"
#include "TopoDS_Edge.hxx"
#include "gp_Pnt.hxx"
#include "TopExp.hxx"
#include "BRep_Tool.hxx"

#ifdef _DEBUG
#pragma comment(lib, "TKerneld.lib")
#pragma comment(lib, "TKBRepd.lib")
#pragma comment(lib, "TKTopAlgod.lib")
#endif

void DumpPoint(const gp_Pnt& ptPoint)
{
	std::cout << "(" << ptPoint.X() << "," << ptPoint.Y() << "," << ptPoint.Z() << ")";
}

int main(int argc, char** argv )
{
	BRepBuilderAPI_MakeEdge aEdge(gp_Pnt(0, 0, 0), gp_Pnt(100, 0, 0));

	TopoDS_Vertex aFirstVertex = TopExp::FirstVertex(aEdge);
	TopoDS_Vertex aLastVertex = TopExp::LastVertex(aEdge);

	gp_Pnt aFirstPoint = BRep_Tool::Pnt(aFirstVertex);
	gp_Pnt aLastPoint = BRep_Tool::Pnt(aLastVertex);
	
	DumpPoint(aFirstPoint);
	DumpPoint(aLastPoint);
	std::cout << std::endl;

	return 0;
}


举报

相关推荐

0 条评论