当前位置: 首页>>代码示例>>C++>>正文


C++ BRepBuilderAPI_MakeWire::Vertex方法代码示例

本文整理汇总了C++中BRepBuilderAPI_MakeWire::Vertex方法的典型用法代码示例。如果您正苦于以下问题:C++ BRepBuilderAPI_MakeWire::Vertex方法的具体用法?C++ BRepBuilderAPI_MakeWire::Vertex怎么用?C++ BRepBuilderAPI_MakeWire::Vertex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BRepBuilderAPI_MakeWire的用法示例。


在下文中一共展示了BRepBuilderAPI_MakeWire::Vertex方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: exp

bool IfcGeom::Kernel::convert(const IfcSchema::IfcCompositeCurve* l, TopoDS_Wire& wire) {
	if ( getValue(GV_PLANEANGLE_UNIT)<0 ) {
		Logger::Message(Logger::LOG_WARNING,"Creating a composite curve without unit information:",l->entity);

		// Temporarily pretend we do have unit information
		setValue(GV_PLANEANGLE_UNIT,1.0);
		
		bool succes_radians = false;
        bool succes_degrees = false;
        bool use_radians = false;
        bool use_degrees = false;

		// First try radians
		TopoDS_Wire wire_radians, wire_degrees;
        try {
		    succes_radians = IfcGeom::Kernel::convert(l,wire_radians);
        } catch (...) {}

		// Now try degrees
		setValue(GV_PLANEANGLE_UNIT,0.0174532925199433);
        try {
		    succes_degrees = IfcGeom::Kernel::convert(l,wire_degrees);
        } catch (...) {}

		// Restore to unknown unit state
		setValue(GV_PLANEANGLE_UNIT,-1.0);

		if ( succes_degrees && ! succes_radians ) {
			use_degrees = true;
		} else if ( succes_radians && ! succes_degrees ) {
			use_radians = true;
		} else if ( succes_radians && succes_degrees ) {
			if ( wire_degrees.Closed() && ! wire_radians.Closed() ) {
				use_degrees = true;
			} else if ( wire_radians.Closed() && ! wire_degrees.Closed() ) {
				use_radians = true;
			} else {
				// No heuristic left to prefer the one over the other,
				// apparently both variants are equally succesful.
				// The curve might be composed of only straight segments.
				// Let's go with the wire created using radians as that
				// at least is a SI unit.
				use_radians = true;
			}
		}

		if ( use_radians ) {
			Logger::Message(Logger::LOG_NOTICE,"Used radians to create composite curve");
            wire = wire_radians;
		} else if ( use_degrees ) {
			Logger::Message(Logger::LOG_NOTICE,"Used degrees to create composite curve");
            wire = wire_degrees;
		}

		return use_radians || use_degrees;
	}
	IfcSchema::IfcCompositeCurveSegment::list::ptr segments = l->Segments();
	BRepBuilderAPI_MakeWire w;
	//TopoDS_Vertex last_vertex;
	for( IfcSchema::IfcCompositeCurveSegment::list::it it = segments->begin(); it != segments->end(); ++ it ) {
		IfcSchema::IfcCurve* curve = (*it)->ParentCurve();
		TopoDS_Wire wire2;
		if ( !convert_wire(curve,wire2) ) {
			Logger::Message(Logger::LOG_ERROR,"Failed to convert curve:",curve->entity);
			continue;
		}
		if ( ! (*it)->SameSense() ) wire2.Reverse();
		ShapeFix_ShapeTolerance FTol;
		FTol.SetTolerance(wire2, getValue(GV_WIRE_CREATION_TOLERANCE), TopAbs_WIRE);
		/*if ( it != segments->begin() ) {
			TopExp_Explorer exp (wire2,TopAbs_VERTEX);
			const TopoDS_Vertex& first_vertex = TopoDS::Vertex(exp.Current());
			gp_Pnt first = BRep_Tool::Pnt(first_vertex);
			gp_Pnt last = BRep_Tool::Pnt(last_vertex);
			Standard_Real distance = first.Distance(last);
			if ( distance > ALMOST_ZERO ) {
				w.Add( BRepBuilderAPI_MakeEdge( last_vertex, first_vertex ) );
			}
		}*/
		w.Add(wire2);
		//last_vertex = w.Vertex();
		if ( w.Error() != BRepBuilderAPI_WireDone ) {
			Logger::Message(Logger::LOG_ERROR,"Failed to join curve segments:",l->entity);

			TopoDS_Vertex v1, v2, last;
			last = w.Vertex();
				
			if (!last.IsNull()) {
				std::stringstream ss;
				gp_Pnt p = BRep_Tool::Pnt(last);
				ss << std::setprecision(4) << "Last vertex at (" << p.X() << " " << p.Y() << " " << p.Z() << ")";
				Logger::Message(Logger::LOG_NOTICE, ss.str());
			}

			TopExp::Vertices(wire2, v1, v2);
			if (!v1.IsNull()) {
				std::stringstream ss;
				gp_Pnt p = BRep_Tool::Pnt(v1);
				ss << std::setprecision(4) << "Segment starts at (" << p.X() << " " << p.Y() << " " << p.Z() << ") for:";
				Logger::Message(Logger::LOG_NOTICE, ss.str(), (*it)->entity);
//.........这里部分代码省略.........
开发者ID:Fredounet,项目名称:IfcOpenShell,代码行数:101,代码来源:IfcGeomWires.cpp


注:本文中的BRepBuilderAPI_MakeWire::Vertex方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。