import siconos.io.mechanics_run siconos.io.mechanics_run.set_backend('occ') import numpy as np import math # create sphere radius = 1.0 # The sphere center X1 = 0.0 Y1 = 0.0 Z1 = 0.0 # create OCC.gp.gp_Pnt-Point from vector point = gp_Pnt(X1, Y1, Z1) sphere_r1 = BRepPrimAPI_MakeSphere(point, radius) sphere_r1_shape = sphere_r1.Shape() radius = 0.01 sphere_r01 = BRepPrimAPI_MakeSphere(point, radius) sphere_r01_shape = sphere_r01.Shape() radius = 0.001 sphere_r001 = BRepPrimAPI_MakeSphere(point, radius) sphere_r001_shape = sphere_r001.Shape() from OCC.BRep import BRep_Builder from OCC.TopoDS import TopoDS_Compound builder = BRep_Builder() comp = TopoDS_Compound() builder.MakeCompound(comp)
def Shape(self): p = self.ballCurve.getPnt(self.index) ax = gp_Ax2(p, gp_Dir(0, 0, 1), gp_Dir(0, 1, 0)) ms = BRepPrimAPI_MakeSphere(ax, self.r) return ms.Shape()
def make_ellipsoid(centre_pt, dx, dy, dz): """Creates an ellipsoid from non-uniformly scaled unit sphere""" sphere = BRepPrimAPI_MakeSphere(gp_Pnt(0, 0, 0), 0.5) ellipsoid = transform_nonuniformal(sphere.Shape(), [dx, dy, dz], vec=centre_pt) return ellipsoid
def makeBall(r): ax = gp_Ax2(gp_Pnt(0, 0, 0), gp_Dir(0, 0, 1), gp_Dir(0, 1, 0)) ms = BRepPrimAPI_MakeSphere(ax, r) return ms.Shape()