示例#1
0
/*
Creates the hyperboloid using a formula. 
TODO: Update this so the hyperboloid actually represents a proper parametric model. 
*/
TopoDS_Shape hyperboloid::create(double innerRadius, double height, double heightUnder, double angle)
{
		int detail = 40;
		gp_Pnt Origin(0,0,0);
		gp_Vec Dir(0,0,1);

		int uCount = detail;
		double a = innerRadius;
		double c = angle;
		double totalHeight = height + heightUnder;
		TColgp_Array1OfPnt array (0,uCount - 1);

		for (double u = 0; u < uCount; u++)
		{	
			double uValue = ((totalHeight * u / (uCount - 1)) - heightUnder) / c;
			double vValue = 0;

			double sqrMe = 1 + uValue * uValue;

			double x = a * sqrt(sqrMe) * cos(vValue);
			double y = a * sqrt(sqrMe) * sin(vValue);
			double z = c * uValue;
			gp_Pnt P1(x,y,z);   
			array.SetValue(u,P1); 
		}
	                          
		Handle(Geom_BSplineCurve) hyperbola = GeomAPI_PointsToBSpline(array).Curve();    
		TopoDS_Edge hyperbolaTopoDS = BRepBuilderAPI_MakeEdge(hyperbola); 

		gp_Ax1 axis = gp_Ax1(Origin,Dir); 
		TopoDS_Shape hyperboloid = BRepPrimAPI_MakeRevol(hyperbolaTopoDS, axis); 

		return hyperboloid;
}
示例#2
0
void occQt::makeRevol()
{
    gp_Ax1 anAxis;

    // revol a vertex result is an edge.
    anAxis.SetLocation(gp_Pnt(0.0, 70.0, 0.0));
    TopoDS_Vertex aVertex = BRepBuilderAPI_MakeVertex(gp_Pnt(2.0, 70.0, 0.0));
    TopoDS_Shape aRevolVertex = BRepPrimAPI_MakeRevol(aVertex, anAxis);
    Handle_AIS_Shape anAisRevolVertex = new AIS_Shape(aRevolVertex);

    // revol an edge result is a face.
    anAxis.SetLocation(gp_Pnt(8.0, 70.0, 0.0));
    TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge(gp_Pnt(6.0, 70.0, 0.0), gp_Pnt(6.0, 70.0, 5.0));
    TopoDS_Shape aRevolEdge = BRepPrimAPI_MakeRevol(anEdge, anAxis);
    Handle_AIS_Shape anAisRevolEdge = new AIS_Shape(aRevolEdge);

    // revol a wire result is a shell.
    anAxis.SetLocation(gp_Pnt(20.0, 70.0, 0.0));
    anAxis.SetDirection(gp::DY());

    TopoDS_Edge aCircleEdge = BRepBuilderAPI_MakeEdge(gp_Circ(gp_Ax2(gp_Pnt(15.0, 70.0, 0.0), gp::DZ()), 1.5));
    TopoDS_Wire aCircleWire = BRepBuilderAPI_MakeWire(aCircleEdge);
    TopoDS_Shape aRevolCircle = BRepPrimAPI_MakeRevol(aCircleWire, anAxis, M_PI_2);
    Handle_AIS_Shape anAisRevolCircle = new AIS_Shape(aRevolCircle);

    // revol a face result is a solid.
    anAxis.SetLocation(gp_Pnt(30.0, 70.0, 0.0));
    anAxis.SetDirection(gp::DY());

    TopoDS_Edge aEllipseEdge = BRepBuilderAPI_MakeEdge(gp_Elips(gp_Ax2(gp_Pnt(25.0, 70.0, 0.0), gp::DZ()), 3.0, 2.0));
    TopoDS_Wire aEllipseWire = BRepBuilderAPI_MakeWire(aEllipseEdge);
    TopoDS_Face aEllipseFace = BRepBuilderAPI_MakeFace(gp_Pln(gp::XOY()), aEllipseWire);
    TopoDS_Shape aRevolEllipse = BRepPrimAPI_MakeRevol(aEllipseFace, anAxis, M_PI_4);
    Handle_AIS_Shape anAisRevolEllipse = new AIS_Shape(aRevolEllipse);

    anAisRevolVertex->SetColor(Quantity_NOC_LIMEGREEN);
    anAisRevolEdge->SetColor(Quantity_NOC_LINEN);
    anAisRevolCircle->SetColor(Quantity_NOC_MAGENTA1);
    anAisRevolEllipse->SetColor(Quantity_NOC_MAROON);

    mContext->Display(anAisRevolVertex);
    mContext->Display(anAisRevolEdge);
    mContext->Display(anAisRevolCircle);
    mContext->Display(anAisRevolEllipse);
}
示例#3
0
bool IfcGeom::Kernel::convert(const IfcSchema::IfcRevolvedAreaSolid* l, TopoDS_Shape& shape) {
    const double ang = l->Angle() * getValue(GV_PLANEANGLE_UNIT);

    TopoDS_Face face;
    if ( ! convert_face(l->SweptArea(),face) ) return false;

    gp_Ax1 ax1;
    IfcGeom::Kernel::convert(l->Axis(), ax1);

    gp_Trsf trsf;
    IfcGeom::Kernel::convert(l->Position(),trsf);

    if (ang >= M_PI * 2. - ALMOST_ZERO) {
        shape = BRepPrimAPI_MakeRevol(face, ax1);
    } else {
        shape = BRepPrimAPI_MakeRevol(face, ax1, ang);
    }

    shape.Move(trsf);
    return !shape.IsNull();
}
示例#4
0
bool IfcGeom::Kernel::convert(const IfcSchema::IfcSurfaceOfRevolution* l, TopoDS_Shape& shape) {
    TopoDS_Wire wire;
    if ( !convert_wire(l->SweptCurve(), wire) ) {
        TopoDS_Face face;
        if ( !convert_face(l->SweptCurve(),face) ) return false;
        TopExp_Explorer exp(face, TopAbs_WIRE);
        wire = TopoDS::Wire(exp.Current());
    }

    gp_Ax1 ax1;
    IfcGeom::Kernel::convert(l->AxisPosition(), ax1);

    gp_Trsf trsf;
    IfcGeom::Kernel::convert(l->Position(),trsf);

    shape = BRepPrimAPI_MakeRevol(wire, ax1);

    shape.Move(trsf);
    return !shape.IsNull();
}