|
22 | 22 | from OCC.GeomAPI import GeomAPI_ProjectPointOnSurf |
23 | 23 | from OCC.GeomLib import GeomLib_IsPlanarSurface |
24 | 24 | from OCC.TopAbs import TopAbs_IN |
25 | | -from OCC.TopExp import TopExp |
| 25 | +from OCC.TopExp import topexp |
26 | 26 | from OCC.TopoDS import * |
27 | 27 | from OCC.GeomLProp import GeomLProp_SLProps |
28 | 28 | from OCC.BRepCheck import BRepCheck_Face |
29 | | -from OCC.BRepTools import BRepTools, BRepTools_UVBounds |
| 29 | +from OCC.BRepTools import breptools_UVBounds |
30 | 30 | from OCC.BRepAdaptor import BRepAdaptor_Surface, BRepAdaptor_HSurface |
31 | 31 | from OCC.ShapeAnalysis import ShapeAnalysis_Surface |
32 | 32 | from OCC.IntTools import IntTools_FaceFace |
33 | 33 | from OCC.ShapeAnalysis import ShapeAnalysis_Surface |
34 | | -from OCC.GeomProjLib import GeomProjLib |
| 34 | +from OCC.GeomProjLib import geomprojlib |
35 | 35 | from OCC.Adaptor3d import Adaptor3d_IsoCurve |
36 | 36 |
|
37 | 37 | from base import Display, KbeObject, GlobalProperties |
@@ -77,7 +77,7 @@ def curvature(self, u, v): |
77 | 77 |
|
78 | 78 | _domain = self.instance.domain() |
79 | 79 | if u in _domain or v in _domain: |
80 | | - print '<<<CORRECTING DOMAIN...>>>' |
| 80 | + print('<<<CORRECTING DOMAIN...>>>') |
81 | 81 | div = 1000 |
82 | 82 | delta_u, delta_v = (_domain[0] - _domain[1])/div, (_domain[2] - _domain[3])/div |
83 | 83 |
|
@@ -207,14 +207,18 @@ def intersect_curve(self, crv): |
207 | 207 |
|
208 | 208 | class Face(KbeObject, TopoDS_Face): |
209 | 209 | """high level surface API |
210 | | - object is a Face iff part of a Solid |
| 210 | + object is a Face if part of a Solid |
211 | 211 | otherwise the same methods do apply, apart from the topology obviously |
212 | 212 | """ |
213 | 213 | def __init__(self, face): |
214 | 214 | ''' |
215 | 215 | ''' |
216 | 216 | KbeObject.__init__(self, name='face') |
217 | | - TopoDS_Face.__init__(self, face) |
| 217 | + # TopoDS_Face inheritance |
| 218 | + TopoDS_Face.__init__(self) |
| 219 | + self.TShape(face.TShape()) |
| 220 | + self.Location(face.Location()) |
| 221 | + self.Orientation(face.Orientation()) |
218 | 222 |
|
219 | 223 | # cooperative classes |
220 | 224 | self.DiffGeom = DiffGeomSurface(self) |
@@ -268,7 +272,7 @@ def domain(self): |
268 | 272 | '''the u,v domain of the curve |
269 | 273 | :return: UMin, UMax, VMin, VMax |
270 | 274 | ''' |
271 | | - return BRepTools_UVBounds(self) |
| 275 | + return breptools_UVBounds(self) |
272 | 276 |
|
273 | 277 | def mid_point(self): |
274 | 278 | """ |
@@ -358,10 +362,10 @@ def is_trimmed(self): |
358 | 362 | and implies that the surface is trimmed |
359 | 363 | """ |
360 | 364 | _round = lambda x: round(x, 3) |
361 | | - a = map(_round, BRepTools_UVBounds(self)) |
| 365 | + a = map(_round, breptools_UVBounds(self)) |
362 | 366 | b = map(_round, self.adaptor.Surface().Surface().GetObject().Bounds()) |
363 | 367 | if a != b: |
364 | | - print 'a,b', a, b |
| 368 | + print('a,b', a, b) |
365 | 369 | return True |
366 | 370 | return False |
367 | 371 |
|
@@ -443,11 +447,11 @@ def project_curve(self, other): |
443 | 447 | issubclass(other, Geom_Curve)): |
444 | 448 | if isinstance(other, TopoDS_Edge): |
445 | 449 | # convert edge to curve |
446 | | - first, last = TopExp.FirstVertex(other), TopExp.LastVertex(other) |
| 450 | + first, last = topexp.FirstVertex(other), topexp.LastVertex(other) |
447 | 451 | lbound, ubound = BRep_Tool().Parameter(first, other), BRep_Tool().Parameter(last, other) |
448 | 452 | other = BRep_Tool.Curve(other, lbound, ubound).GetObject() |
449 | 453 |
|
450 | | - return GeomProjLib().Project(other, self.surface_handle) |
| 454 | + return geomprojlib.Project(other, self.surface_handle) |
451 | 455 |
|
452 | 456 | def project_edge(self, edg): |
453 | 457 | if hasattr(edg, 'adaptor'): |
@@ -479,3 +483,5 @@ def __str__(self): |
479 | 483 | from OCC.BRepPrimAPI import BRepPrimAPI_MakeSphere |
480 | 484 | sph = BRepPrimAPI_MakeSphere(1, 1).Face() |
481 | 485 | fc = Face(sph) |
| 486 | + print(fc.is_trimmed()) |
| 487 | + print(fc.is_planar()) |
0 commit comments