本文整理汇总了Python中OCC.gp.gp_Pnt函数的典型用法代码示例。如果您正苦于以下问题:Python gp_Pnt函数的具体用法?Python gp_Pnt怎么用?Python gp_Pnt使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了gp_Pnt函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: copyToZ
def copyToZ(self, z):
"makes a copy of this slice, transformed to the specified z height"
theCopy = Slice()
theCopy.zLevel = z
theCopy.zHeight = self.zHeight
theCopy.sliceHeight = self.sliceHeight
theCopy.fillWidth = self.fillWidth
theCopy.hatchDir = self.hatchDir
theCopy.checkSum = self.checkSum
# make transformation
p1 = gp.gp_Pnt(0, 0, 0)
p2 = gp.gp_Pnt(0, 0, z)
xform = gp.gp_Trsf()
xform.SetTranslation(p1, p2)
bt = BRepBuilderAPI.BRepBuilderAPI_Transform(xform)
# copy all of the faces
for f in hSeqIterator(self.faces):
bt.Perform(f, True)
theCopy.addFace(Wrappers.cast(bt.Shape()))
# copy all of the fillWires
for w in hSeqIterator(self.fillWires):
bt.Perform(w, True)
# TestDisplay.display.showShape(bt.Shape() );
theCopy.fillWires.Append(Wrappers.cast(bt.Shape()))
# copy all of the fillEdges
for e in hSeqIterator(self.fillEdges):
bt.Perform(e, True)
# TestDisplay.display.showShape(bt.Shape() );
theCopy.fillEdges.Append(Wrappers.cast(bt.Shape()))
return theCopy
开发者ID:adam-urbanczyk,项目名称:emcfab,代码行数:35,代码来源:OccSliceLib.py
示例2: get_mesh_precision
def get_mesh_precision(shape, quality_factor):
bbox = Bnd_Box()
BRepBndLib_Add(shape, bbox)
x_min,y_min,z_min,x_max,y_max,z_max = bbox.Get()
diagonal_length = gp_Vec(gp_Pnt(x_min, y_min, z_min),
gp_Pnt(x_max, y_max, z_max)).Magnitude()
return (diagonal_length / 20.) / quality_factor
开发者ID:amarh,项目名称:openPLM,代码行数:7,代码来源:mesh.py
示例3: pipe
def pipe(event=None):
CurvePoles = TColgp_Array1OfPnt(1,6)
pt1 = gp_Pnt(0.,0.,0.);
pt2 = gp_Pnt(20.,50.,0.);
pt3 = gp_Pnt(60.,100.,0.);
pt4 = gp_Pnt(150.,0.,0.);
CurvePoles.SetValue(1, pt1)
CurvePoles.SetValue(2, pt2)
CurvePoles.SetValue(3, pt3)
CurvePoles.SetValue(4, pt4)
curve = Geom_BezierCurve(CurvePoles)
print type(curve)
E = BRepBuilderAPI_MakeEdge(curve.GetHandle()).Edge()
W = BRepBuilderAPI_MakeWire(E).Wire()
#ais1 = AIS_Shape(W)
#self.interactive_context.Display(ais1,1)
c = gp_Circ(gp_Ax2(gp_Pnt(0.,0.,0.),gp_Dir(0.,1.,0.)),10.)
Ec = BRepBuilderAPI_MakeEdge(c).Edge()
Wc = BRepBuilderAPI_MakeWire(Ec).Wire()
#ais3 = AIS_Shape(Wc)
#self.interactive_context.Display(ais3,1)
F = BRepBuilderAPI_MakeFace(gp_Pln(gp_Ax3(gp.gp().ZOX())),Wc,1).Face()
MKPipe = BRepOffsetAPI_MakePipe(W,F)
MKPipe.Build()
display.DisplayShape(MKPipe.Shape())
开发者ID:davad,项目名称:cntsim,代码行数:30,代码来源:test-make-pipe.py
示例4: copyToZ
def copyToZ(self, z, layerNo):
"makes a copy of this slice, transformed to the specified z height"
theCopy = Slice()
theCopy.zLevel = z
theCopy.fillAngle = self.fillAngle
theCopy.layerNo = layerNo
theCopy.thickness = self.thickness
# make transformation
p1 = gp.gp_Pnt(0, 0, 0)
p2 = gp.gp_Pnt(0, 0, z)
xform = gp.gp_Trsf()
xform.SetTranslation(p1, p2)
bt = BRepBuilderAPI.BRepBuilderAPI_Transform(xform)
# copy all of the faces
for f in self.faces:
bt.Perform(f.face, True)
newFace = Face(OCCUtil.cast(bt.Shape()))
# copy shells
for shell in f.shellWires:
# print shell
bt.Perform(shell, True)
newFace.shellWires.append(OCCUtil.cast(bt.Shape()))
# copy fillWires
for fill in f.fillWires:
bt.Perform(fill, True)
newFace.shellWires.append(OCCUtil.cast(bt.Shape()))
theCopy.addFace(newFace)
return theCopy
开发者ID:adam-urbanczyk,项目名称:emcfab,代码行数:35,代码来源:Slicer.py
示例5: make_face_to_contour_from
def make_face_to_contour_from():
v1 = make_vertex(gp_Pnt(0, 0, 0))
v2 = make_vertex(gp_Pnt(10, 0, 0))
v3 = make_vertex(gp_Pnt(7, 10, 0))
v4 = make_vertex(gp_Pnt(10, 20, 0))
v5 = make_vertex(gp_Pnt(0, 20, 0))
v6 = make_vertex(gp_Pnt(3, 10, 0))
e1 = make_edge(v1, v2)
e2 = make_edge(v2, v3)
e3 = make_edge(v3, v4)
e4 = make_edge(v4, v5)
e5 = make_edge(v5, v6)
e6 = make_edge(v6, v1)
v7 = make_vertex(gp_Pnt(2, 2, 0))
v8 = make_vertex(gp_Pnt(8, 2, 0))
v9 = make_vertex(gp_Pnt(7, 3, 0))
v10 = make_vertex(gp_Pnt(3, 3, 0))
e7 = make_edge(v7, v8)
e8 = make_edge(v8, v9)
e9 = make_edge(v9, v10)
e10 = make_edge(v10, v7)
w1 = make_wire([e1, e2, e3, e4, e5, e6])
f = make_face(w1)
w2 = make_wire(e7, e8, e9, e10)
f2 = make_face(w2)
f3 = boolean_cut(f, f2)
return f3
开发者ID:gideonmay,项目名称:pythonocc-core,代码行数:27,代码来源:core_geometry_medial_axis_offset.py
示例6: DisplayG01Line
def DisplayG01Line(coor1,coor2):
array=TColgp_Array1OfPnt(1,2)
array.SetValue(1,gp_Pnt(coor1[0],coor1[1],coor1[2]))
array.SetValue(2,gp_Pnt(coor2[0],coor2[1],coor2[2]))
bspline2 = GeomAPI_PointsToBSpline(array).Curve()
path_edge = BRepBuilderAPI_MakeEdge(bspline2).Edge()
display.DisplayColoredShape(path_edge,'GREEN')
开发者ID:ZhengLungWu,项目名称:PythonOCCQt5ForGcodeGUI,代码行数:7,代码来源:OCCGUI.py
示例7: create_AirconicsShape
def create_AirconicsShape():
"""Populates a basic airconics shape with a unit cube striding by 1 in x y
and z from the origin, and a unit sphere centered at the origin"""
cube = BRepPrimAPI_MakeBox(gp_Pnt(0,0,0), 1, 1, 1).Shape()
sphere = BRepPrimAPI_MakeSphere(gp_Pnt(0,0,0), 1).Shape()
shape = AirconicsShape(components={'cube': cube, 'sphere': sphere})
return shape
开发者ID:p-chambers,项目名称:occ_airconics,代码行数:7,代码来源:test_base.py
示例8: move
def move(orig_pypt, location_pypt, occtopology):
"""
This function moves an OCCtopology from the orig_pypt to the location_pypt.
Parameters
----------
orig_pypt : tuple of floats
The OCCtopology will move in reference to this point.
A pypt is a tuple that documents the xyz coordinates of a pt e.g. (x,y,z)
location_pypt : tuple of floats
The destination of where the OCCtopology will be moved in relation to the orig_pypt.
A pypt is a tuple that documents the xyz coordinates of a pt e.g. (x,y,z)
occtopology : OCCtopology
The OCCtopology to be moved.
OCCtopology includes: OCCshape, OCCcompound, OCCcompsolid, OCCsolid, OCCshell, OCCface, OCCwire, OCCedge, OCCvertex
Returns
-------
moved topology : OCCtopology (OCCshape)
The moved OCCtopology.
"""
gp_ax31 = gp_Ax3(gp_Pnt(orig_pypt[0], orig_pypt[1], orig_pypt[2]), gp_DZ())
gp_ax32 = gp_Ax3(gp_Pnt(location_pypt[0], location_pypt[1], location_pypt[2]), gp_DZ())
aTrsf = gp_Trsf()
aTrsf.SetTransformation(gp_ax32,gp_ax31)
trsf_brep = BRepBuilderAPI_Transform(aTrsf)
trsf_brep.Perform(occtopology, True)
trsf_shp = trsf_brep.Shape()
return trsf_shp
开发者ID:chenkianwee,项目名称:envuo,代码行数:31,代码来源:modify.py
示例9: WindowContour
def WindowContour(self, WinCenter):
"""Creates and returns the contour of the window at WinCenter
Parameters
----------
WinCenter : list or array, length 2
The [X, Z] coordinate of the center of the window
Returns
-------
W_wire : TopoDS_Wire
The wire of the B-spline contour
"""
raise NotImplementedError(
"This function is in development, and its output is untested")
P1 = gp_Pnt(WinCenter[0], 0, WinCenter[1] + 0.468/2.)
P2 = gp_Pnt(WinCenter[0] + 0.272/2., 0, WinCenter[1])
P3 = gp_Pnt(WinCenter[0], 0, WinCenter[1] - 0.468/2.)
P4 = gp_Pnt(WinCenter[0] - 0.272/2., 0, WinCenter[1])
tangents = np.array([[0, 0, 2.5],
[0, 0, -2.5]])
WCurveU = act.points_to_bspline([P4, P1, P2], tangents=tangents)
# Need to reverse the tangents for the following shape:
WCurveL = act.points_to_bspline([P2, P3, P4], tangents=tangents[::-1])
edgeU = act.make_edge(WCurveU)
edgeL = act.make_edge(WCurveL)
# W_face= act.make_face(act.make_wire([edgeU, edgeL]))
W_wire = act.make_wire([edgeU, edgeL])
return W_wire
开发者ID:p-chambers,项目名称:occ_airconics,代码行数:33,代码来源:fuselage_oml.py
示例10: test_CalculateSurfaceArea
def test_CalculateSurfaceArea():
"""Use a few simple shapes to test the surface area function.
Notes
-----
This isnt testing the area building algorithm, just that my setup of the
function works for a variety of different OCC objects - PChambers
"""
# A flat square edge lengths 1
from OCC.BRepBuilderAPI import BRepBuilderAPI_MakePolygon
p1 = gp_Pnt(0, 0, 0)
p2 = gp_Pnt(1, 0, 0)
p3 = gp_Pnt(1, 1, 0)
p4 = gp_Pnt(0, 1, 0)
surf1 = act.make_face(
BRepBuilderAPI_MakePolygon(p1, p2, p3, p4, True).Wire())
# The tolerance for difference between output and expected area
tol = 1e-12
assert(np.abs(act.CalculateSurfaceArea(surf1) - 1) < tol)
# A sphere with radius 1
from OCC.BRepPrimAPI import BRepPrimAPI_MakeSphere
r = 1
# The tolerance need to be relaxed a bit for this case
tol = 1e-04
sphere = BRepPrimAPI_MakeSphere(r).Shape()
assert(np.abs(act.CalculateSurfaceArea(sphere) - 4 * np.pi * (r**2)) < tol)
开发者ID:p-chambers,项目名称:occ_airconics,代码行数:27,代码来源:test_AirCONICStools.py
示例11: test_project_curve_to_plane
def test_project_curve_to_plane():
# Projects a line of length 1 from above the XOY plane, and tests points
# on the resulting line
from OCC.Geom import Geom_Plane, Geom_TrimmedCurve
from OCC.GC import GC_MakeSegment
from OCC.gp import gp_Ax3, gp_XOY, gp_Pnt, gp_Dir
XOY = Geom_Plane(gp_Ax3(gp_XOY()))
curve = GC_MakeSegment(gp_Pnt(0, 0, 5),
gp_Pnt(1, 0, 5)).Value()
direction = gp_Dir(0, 0, 1)
Hproj_curve = act.project_curve_to_plane(curve, XOY.GetHandle(),
direction)
proj_curve = Hproj_curve.GetObject()
# The start and end points of the curve
p1 = proj_curve.Value(0)
p2 = proj_curve.Value(1)
p1_array = np.array([p1.X(), p1.Y(), p1.Z()])
p2_array = np.array([p2.X(), p2.Y(), p2.Z()])
# The expected start and end points
start = np.array([0, 0, 0])
end = np.array([1, 0, 0])
# Assert that neither points have a Y or Z component, and that
assert((np.all(p1_array == start) and np.all(p2_array == end)) or
(np.all(p1_array == end) and np.all(p2_array == start)))
开发者ID:p-chambers,项目名称:occ_airconics,代码行数:30,代码来源:test_AirCONICStools.py
示例12: get_transform
def get_transform(self):
d = self.declaration
t = gp_Trsf()
#: TODO: Order matters... how to configure it???
if d.mirror:
try:
p,v = d.mirror
except ValueError:
raise ValueError("You must specify a tuple containing a (point,direction)")
t.SetMirror(gp_Ax1(gp_Pnt(*p),
gp_Dir(*v)))
if d.scale:
try:
p,s = d.scale
except ValueError:
raise ValueError("You must specify a tuple containing a (point,scale)")
t.SetScale(gp_Pnt(*p),s)
if d.translate:
t.SetTranslation(gp_Vec(*d.translate))
if d.rotate:
try:
p,v,a = d.rotate
except ValueError:
raise ValueError("You must specify a tuple containing a (point,direction,angle)")
t.SetRotation(gp_Ax1(gp_Pnt(*p),
gp_Dir(*v)),a)
return t
开发者ID:frmdstryr,项目名称:enamlx,代码行数:30,代码来源:occ_algo.py
示例13: test_list
def test_list(self):
'''
Test python lists features
'''
P1 = gp_Pnt(1, 2, 3)
P2 = gp_Pnt(2, 3, 4)
P3 = gp_Pnt(5, 7, 8)
l = [P1, P2]
self.assertEqual(P1 in l, True)
self.assertNotEqual(P3 in l, True)
self.assertEqual(l.index(P1), 0)
self.assertEqual(l.index(P2), 1)
# Do the same for Vertices (TopoDS_Shape has
# a HashCode() method overloaded
V1 = BRepBuilderAPI_MakeVertex(P1).Vertex()
V2 = BRepBuilderAPI_MakeVertex(P2).Vertex()
V3 = BRepBuilderAPI_MakeVertex(P3) .Vertex()
vl = [V1, V2]
self.assertEqual(V1 in vl, True)
self.assertNotEqual(V3 in vl, True)
# index test()
self.assertEqual(vl.index(V1), 0)
self.assertEqual(vl.index(V2), 1)
# reverse() test
vl.reverse()
self.assertEqual(vl.index(V1), 1)
self.assertEqual(vl.index(V2), 0)
开发者ID:dunkyp,项目名称:pythonocc-core,代码行数:27,代码来源:core_wrapper_features_unittest.py
示例14: fillet
def fillet(event=None):
Box = BRepPrimAPI_MakeBox(gp_Pnt(-400, 0, 0), 200, 230, 180).Shape()
fillet = BRepFilletAPI_MakeFillet(Box)
# Add fillet on each edge
for e in Topo(Box).edges():
fillet.Add(20, e)
blendedBox = fillet.Shape()
P1 = gp_Pnt(250, 150, 75)
S1 = BRepPrimAPI_MakeBox(300, 200, 200).Shape()
S2 = BRepPrimAPI_MakeBox(P1, 120, 180, 70).Shape()
Fuse = BRepAlgoAPI_Fuse(S1, S2)
FusedShape = Fuse.Shape()
fill = BRepFilletAPI_MakeFillet(FusedShape)
for e in Topo(FusedShape).edges():
fill.Add(e)
for i in range(1, fill.NbContours() + 1):
length = fill.Length(i)
Rad = 0.15 * length
fill.SetRadius(Rad, i, 1)
blendedFusedSolids = fill.Shape()
display.EraseAll()
display.DisplayShape(blendedBox)
display.DisplayShape(blendedFusedSolids)
display.FitAll()
开发者ID:gideonmay,项目名称:pythonocc-core,代码行数:30,代码来源:core_topology_fillet.py
示例15: TestDivideEdge
def TestDivideEdge():
#lines are parameterized between 0 and line length
edge = edgeFromTwoPoints ( gp.gp_Pnt(0,0,0), gp.gp_Pnt(2,2,0));
(handleCurve, p1, p2 ) = brepTool.Curve(edge); #p1=0, #p2=2.828
print p1,p2
totalLen = (p2 - p1);
display.DisplayColoredShape(edge, 'BLUE');
#divide the edge into two edges, split at 0.25 units from param=1.414, with a gap of 0.1 between them
edges = divideEdgeAtParam(edge, 1.414, 0.25,0.1); #divide the edge into two edges
assert(len(edges)== 2);
(e1,e2) = ( edges[0],edges[1]);
(hc,q1,q2) = brepTool.Curve(e1);
print q1,q2;
(hc,q1,q2) = brepTool.Curve(e2);
print q1,q2;
print Wrappers.Edge(e1).distanceBetweenEnds();
assert (abs(Wrappers.Edge(e1).distanceBetweenEnds()- (1.414 + 0.25)) < 0.000001);
assert (abs(Wrappers.Edge(e2).distanceBetweenEnds() - (totalLen - 1.414 - 0.25 - 0.1)) < 0.0000001 );
display.DisplayColoredShape(edges,'RED');
edges = divideEdgeAtParam(edge, 1.414, 2.5,0.1); #should return one edge of length 0.1 less than total
assert ( len(edges) ==1);
assert ( abs(Wrappers.Edge(edges[0]).distanceBetweenEnds() - (totalLen - 0.1)) < 0.0000001 );
display.DisplayColoredShape(edges,'GREEN');
开发者ID:adam-urbanczyk,项目名称:emcfab,代码行数:25,代码来源:OCCUtil.py
示例16: BBox_FromExtents
def BBox_FromExtents(xmin, ymin, zmin, xmax, ymax, zmax):
"""Generates the Wire Edges defining the Bounding Box defined in the input
arguments: Can be used to display the bounding box"""
s = BRepPrimAPI_MakeBox(gp_Pnt(xmin, ymin, zmin),
gp_Pnt(xmax, ymax, zmax)).Shape()
ais_bbox = AIS_Shape(s)
ais_bbox.SetDisplayMode(AIS_WireFrame)
return ais_bbox.GetHandle()
开发者ID:p-chambers,项目名称:occ_airconics,代码行数:8,代码来源:AirCONICStools.py
示例17: center_boundingbox
def center_boundingbox(shape):
'''
compute the center point of a TopoDS_Shape, based on its bounding box
@param shape: TopoDS_* instance
returns a gp_Pnt instance
'''
xmin, ymin, zmin, xmax, ymax, zmax = get_boundingbox(shape, 1e-6)
return midpoint(gp_Pnt(xmin, ymin, zmin), gp_Pnt(xmax, ymax, zmax))
开发者ID:chenkianwee,项目名称:envuo,代码行数:8,代码来源:Common.py
示例18: CutSect
def CutSect(Shape, SpanStation):
"""
Parameters
----------
Shape : TopoDS_Shape
The Shape to find planar cut section (parallel to xz plane)
SpanStation : scalar in range (0, 1)
y-direction location at which to cut Shape
Returns
-------
Section : result of OCC.BRepAlgoAPI.BRepAlgoAPI_Section (TopoDS_Shape)
The cut section of shape given a cut plane parallel to xz at input
Spanstation.
Chord : result of OCC.GC.GC_MakeSegment.Value (Geom_TrimmedCurve)
The Chord line between x direction extremeties
"""
(Xmin, Ymin, Zmin, Xmax, Ymax, Zmax) = ObjectsExtents([Shape])
YStation = Ymin + (Ymax - Ymin) * SpanStation
OriginX = Xmin - 1
OriginZ = Zmin - 1
P = gp_Pln(gp_Pnt(OriginX, YStation, OriginZ), gp_Dir(gp_Vec(0, 1, 0)))
# Note: using 2*extents here as previous +1 trimmed plane too short
CutPlaneSrf = make_face(P, 0, Zmax + 2, 0, Xmax +2)
I = BRepAlgoAPI_Section(Shape, CutPlaneSrf)
I.ComputePCurveOn1(True)
I.Approximation(True)
I.Build()
Section = I.Shape()
(Xmin, Ymin, Zmin, Xmax, Ymax, Zmax) = ObjectsExtents([Section])
# Currently assume only one edge exists in the intersection:
exp = TopExp_Explorer(Section, TopAbs_EDGE)
edge = topods_Edge(exp.Current())
# Find the apparent chord of the section (that is, the line connecting the
# fore most and aftmost points on the curve
DivPoints = Uniform_Points_on_Curve(edge, 200)
Xs = np.array([pt.X() for pt in DivPoints])
min_idx = np.argmin(Xs)
LeadingPoint = gp_Pnt(Xs[min_idx], DivPoints[min_idx].Y(),
DivPoints[min_idx].Z())
max_idx = np.argmax(Xs)
TrailingPoint = gp_Pnt(Xs[max_idx], DivPoints[max_idx].Y(),
DivPoints[max_idx].Z())
HChord = GC_MakeSegment(TrailingPoint, LeadingPoint).Value()
# Chord = HChord.GetObject()
return Section, HChord
开发者ID:p-chambers,项目名称:occ_airconics,代码行数:58,代码来源:AirCONICStools.py
示例19: make_circle3pt
def make_circle3pt(pt1, pt2, pt3):
"""Makes a circle allowing python lists as input points"""
try:
pt1 = gp_Pnt(*pt1)
pt2 = gp_Pnt(*pt2)
pt3 = gp_Pnt(*pt3)
except:
pass
return GC_MakeCircle(pt1, pt2, pt3).Value()
开发者ID:p-chambers,项目名称:occ_airconics,代码行数:9,代码来源:AirCONICStools.py
示例20: DisplayG00Line
def DisplayG00Line(coor1,coor2):
coors=[coor1,[coor2[0],coor1[1],coor1[2]],[coor2[0],coor2[1],coor1[2]],coor2]
for i in range(3):
array=TColgp_Array1OfPnt(1,2)
array.SetValue(1,gp_Pnt(coors[i][0],coors[i][1],coors[i][2]))
array.SetValue(2,gp_Pnt(coors[i+1][0],coors[i+1][1],coors[i+1][2]))
bspline2 = GeomAPI_PointsToBSpline(array).Curve()
path_edge = BRepBuilderAPI_MakeEdge(bspline2).Edge()
display.DisplayColoredShape(path_edge,'YELLOW')
开发者ID:ZhengLungWu,项目名称:PythonOCCQt5ForGcodeGUI,代码行数:9,代码来源:OCCGUI.py
注:本文中的OCC.gp.gp_Pnt函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论