opencascade 的example
时间: 2023-10-08 22:07:33 浏览: 110
1. Creating a Sphere
#include <TopoDS.hxx>
#include <BRepPrimAPI_MakeSphere.hxx>
int main()
{
// Create a sphere with radius 1.0
BRepPrimAPI_MakeSphere sphereMaker(1.0);
TopoDS_Shape sphere = sphereMaker.Shape();
return 0;
}
2. Creating a Box
#include <TopoDS.hxx>
#include <BRepPrimAPI_MakeBox.hxx>
int main()
{
// Create a box with dimensions 2.0 x 3.0 x 4.0
BRepPrimAPI_MakeBox boxMaker(2.0, 3.0, 4.0);
TopoDS_Shape box = boxMaker.Shape();
return 0;
}
3. Creating a Cylinder
#include <TopoDS.hxx>
#include <BRepPrimAPI_MakeCylinder.hxx>
int main()
{
// Create a cylinder with radius 1.0 and height 2.0
BRepPrimAPI_MakeCylinder cylinderMaker(1.0, 2.0);
TopoDS_Shape cylinder = cylinderMaker.Shape();
return 0;
}
4. Creating a Cone
#include <TopoDS.hxx>
#include <BRepPrimAPI_MakeCone.hxx>
int main()
{
// Create a cone with bottom radius 1.0, top radius 0.5, and height 2.0
BRepPrimAPI_MakeCone coneMaker(1.0, 0.5, 2.0);
TopoDS_Shape cone = coneMaker.Shape();
return 0;
}
5. Creating a Torus
#include <TopoDS.hxx>
#include <BRepPrimAPI_MakeTorus.hxx>
int main()
{
// Create a torus with major radius 2.0, minor radius 0.5
BRepPrimAPI_MakeTorus torusMaker(2.0, 0.5);
TopoDS_Shape torus = torusMaker.Shape();
return 0;
}
Note: These examples only scratch the surface of what is possible with OpenCASCADE. For more information and examples, refer to the official documentation and tutorials provided by OpenCASCADE.
阅读全文