Skip to content

Commit bb5fdd1

Browse files
authored
Merge pull request #777 from tpaviot/review/qa
Review/qa
2 parents e87231d + 475e6ac commit bb5fdd1

File tree

8 files changed

+33
-77
lines changed

8 files changed

+33
-77
lines changed

INSTALL.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ Requirements
1919
pythonOCC needs the following libraries or programs to be installed before you
2020
can compile/use it :
2121

22-
- the python programming language (http://www.python.org). Python 3.x is required. Python 2
22+
* the python programming language (<http://www.python.org>). Python 3.x is required. Python 2
2323
is officially dropped since the release 7.4.0.
2424

25-
- OpenCascade 7.4.0 (https://dev.opencascade.org),
25+
* OpenCascade 7.4.0 (<https://dev.opencascade.org>),
2626

27-
- SWIG 3.0.11 or higher (http://www.swig.org),
27+
* SWIG 3.0.11 or higher (<http://www.swig.org>),
2828

2929
Create a local copy of the repository
3030
-------------------------------------
@@ -47,7 +47,6 @@ installation, you have to set OCE_INCLUDE_PATH and OCE_LIB_PATH:
4747

4848
cmake -DOCE_INCLUDE_PATH=/your_oce_headers -DOCE_LIB_PATH=/your_lib_dir ..
4949

50-
5150
And launch the build process
5251

5352
make
@@ -76,4 +75,4 @@ In order to check that everything is ok, run the pythonocc unittest suite:
7675

7776
demos
7877
-----
79-
Download/test demos available at https://github.com/tpaviot/pythonocc-demos
78+
Download/test demos available at <https://github.com/tpaviot/pythonocc-demos>

README.md

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ CAD/PDM/PLM applications.
1717

1818
Latest release : [pythonocc-core 7.4.0rc1 (december 2019)](https://github.com/tpaviot/pythonocc-core/releases/tag/7.4.0rc1)
1919

20-
2120
Build from source
2221
-----------------
2322

@@ -40,31 +39,31 @@ Conda packages are provided for python 3.6 and 3.7.
4039
Other pythonocc related resources
4140
---------------------------------
4241

43-
* Demos: python examples, as well as jupyter notebooks https://github.com/tpaviot/pythonocc-demos
42+
* Demos: python examples, as well as jupyter notebooks <https://github.com/tpaviot/pythonocc-demos>
4443

45-
* Docker, binderhub: docker and online jupyter notebooks https://github.com/tpaviot/pythonocc-binderhub
44+
* Docker, binderhub: docker and online jupyter notebooks <https://github.com/tpaviot/pythonocc-binderhub>
4645

47-
* Documentation: https://github.com/tpaviot/pythonocc-documentation
46+
* Documentation: <https://github.com/tpaviot/pythonocc-documentation>
4847

4948
Online resources for development
5049
--------------------------------
5150

5251
We use the following online resources:
5352

54-
* Homepage: http://www.pythonocc.org
53+
* Homepage: <http://www.pythonocc.org>
5554

56-
* Mailing list: http://groups.google.com/group/pythonocc
55+
* Mailing list: <http://groups.google.com/group/pythonocc>
5756

58-
* Twitter : https://twitter.com/pythonocc
57+
* Twitter : <https://twitter.com/pythonocc>
5958

60-
* LGTM code quality review: https://lgtm.com/projects/g/tpaviot/honocc-core/
59+
* LGTM code quality review: <https://lgtm.com/projects/g/tpaviot/honocc-core/>
6160

62-
* Codacy quality checker: https://app.codacy.com/app/tpaviot/pythonocc-core
61+
* Codacy quality checker: <https://app.codacy.com/app/tpaviot/pythonocc-core>
6362

6463
pythonocc, oce and opencascade dependencies
6564
-------------------------------------------
6665

67-
From release 7.4.0, pythonocc-core depends on the official OpenCascade-7.4.0 library (https://dev.opencascade.org)
66+
From release 7.4.0, pythonocc-core depends on the official OpenCascade-7.4.0 library (<https://dev.opencascade.org>)
6867

6968
Former releases rely on oce (OpenCascade Community Edition), available at
7069
[oce C++ library / CAD kernel](https://github.com/tpaviot/oce).

ci/conda/build.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ ninja
2424
ninja install
2525

2626
# fix rpaths
27-
if [ `uname` == Darwin ]; then
28-
for lib in `ls $SP_DIR/OCC/_*.so`; do
27+
if [ $(uname) == Darwin ]; then
28+
for lib in $(ls $SP_DIR/OCC/_*.so); do
2929
install_name_tool -rpath $PREFIX/lib @loader_path/../../../ $lib
3030
done
3131
fi

src/Addons/Font3d.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ TopoDS_Shape text_to_brep(const char* aText,
2626
bool anIsCompositeCurve)
2727
{
2828

29-
Standard_Integer anArgIt = 1;
30-
3129
Font_BRepFont aFont;
3230
TCollection_AsciiString aFontName (aName);
3331
gp_Ax3 aPenAx3 (gp::XOY());

src/Extend/DataExchange.py

Lines changed: 10 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@
3838
from OCC.Core.TopLoc import TopLoc_Location
3939
from OCC.Core.BRepBuilderAPI import BRepBuilderAPI_Transform
4040

41-
from OCC.Extend.TopologyUtils import (TopologyExplorer, discretize_edge,
42-
get_sorted_hlr_edges, list_of_shapes_to_compound)
41+
from OCC.Extend.TopologyUtils import (discretize_edge, get_sorted_hlr_edges,
42+
list_of_shapes_to_compound)
4343

4444
try:
4545
import svgwrite
@@ -74,9 +74,9 @@ def read_step_file(filename, as_compound=True, verbosity=True):
7474
_nbs = step_reader.NbShapes()
7575
if _nbs == 0:
7676
raise AssertionError("No shape to transfer.")
77-
if _nbs == 1: # most cases
77+
elif _nbs == 1: # most cases
7878
return step_reader.Shape(1)
79-
elif _nbs > 1 :
79+
elif _nbs > 1:
8080
print("Number of shapes:", _nbs)
8181
shps = []
8282
# loop over root shapes
@@ -94,6 +94,7 @@ def read_step_file(filename, as_compound=True, verbosity=True):
9494
return shps
9595
else:
9696
raise AssertionError("Error: can't read file.")
97+
return None
9798

9899

99100
def write_step_file(a_shape, filename, application_protocol="AP203"):
@@ -256,7 +257,7 @@ def _get_sub_shapes(lab, loc):
256257
if (color_tool.GetColor(lab, 0, c) or
257258
color_tool.GetColor(lab, 1, c) or
258259
color_tool.GetColor(lab, 2, c)):
259-
260+
260261
color_tool.SetInstanceColor(shape, 0, c)
261262
color_tool.SetInstanceColor(shape, 1, c)
262263
color_tool.SetInstanceColor(shape, 2, c)
@@ -392,7 +393,7 @@ def read_iges_file(filename, return_as_shapes=False, verbosity=False, visible_on
392393
iges_reader.PrintCheckTransfer(failsonly, IFSelect_ItemsByEntity)
393394
iges_reader.TransferRoots()
394395
nbr = iges_reader.NbRootsForTransfer()
395-
for n in range(1, nbr+1):
396+
for _ in range(1, nbr+1):
396397
nbs = iges_reader.NbShapes()
397398
if nbs == 0:
398399
print("At least one shape in IGES cannot be transfered")
@@ -450,9 +451,9 @@ def edge_to_svg_polyline(topods_edge, tol=0.1, unit="mm"):
450451
"""
451452
unit_factor = 1 # by default
452453

453-
if unit=="mm":
454+
if unit == "mm":
454455
unit_factor = 1
455-
elif unit=="m":
456+
elif unit == "m":
456457
unit_factor = 1e3
457458

458459
points_3d = discretize_edge(topods_edge, tol)
@@ -465,7 +466,7 @@ def edge_to_svg_polyline(topods_edge, tol=0.1, unit="mm"):
465466
y_p = point[1] * unit_factor
466467
box2d.Add(gp_Pnt2d(x_p, y_p))
467468
points_2d.append((x_p, y_p))
468-
469+
469470
return svgwrite.shapes.Polyline(points_2d, fill="none"), box2d
470471

471472
def export_shape_to_svg(shape, filename=None,
@@ -543,34 +544,3 @@ def export_shape_to_svg(shape, filename=None,
543544
print("Shape successfully exported to %s" % filename)
544545
return True
545546
return dwg.tostring()
546-
547-
548-
if __name__ == "__main__":
549-
from OCC.Core.BRepPrimAPI import BRepPrimAPI_MakeSphere, BRepPrimAPI_MakeBox
550-
sphere_shape = BRepPrimAPI_MakeSphere(30.).Shape()
551-
write_step_file(sphere_shape, "s_203.stp", application_protocol="AP203")
552-
write_step_file(sphere_shape, "s_214.stp", application_protocol="AP214IS")
553-
read_step_file("s_203.stp")
554-
read_step_file("s_214.stp")
555-
read_step_file("s_214.stp", return_as_shapes=True)
556-
write_stl_file(sphere_shape, "s_stl_ascii.stl")
557-
write_stl_file(sphere_shape, "s_stl_binary.stl", mode="binary")
558-
read_stl_file("s_stl_ascii.stl")
559-
read_stl_file("s_stl_binary.stl")
560-
# improve the precision by a factor 2
561-
write_stl_file(sphere_shape, "s_stl_precise_ascii.stl", linear_deflection=0.1, angular_deflection=0.2)
562-
read_stl_file("s_stl_precise_ascii.stl")
563-
# iges test
564-
write_iges_file(sphere_shape, "s_iges.igs")
565-
# write IGES with special character
566-
write_iges_file(sphere_shape, "sphère.igs")
567-
read_iges_file("sphère.igs")
568-
read_iges_file("s_iges.igs")
569-
read_iges_file("s_iges.igs", return_as_shapes=True)
570-
# test step with colors
571-
read_step_file_with_names_colors("s_214.stp")
572-
# create a box
573-
box_shp = BRepPrimAPI_MakeBox(10, 50, 300).Shape()
574-
get_sorted_hlr_edges(box_shp)
575-
export_shape_to_svg(box_shp, filename="box.svg", width="297mm", height="210mm",
576-
export_hidden_edges=False)

src/Extend/TopologyUtils.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ class WireExplorer:
4343
Wire traversal
4444
'''
4545
def __init__(self, wire):
46-
assert isinstance(wire, TopoDS_Wire), 'not a TopoDS_Wire'
46+
if not isinstance(wire, TopoDS_Wire):
47+
raise AsssertionError('not a TopoDS_Wire')
4748
self.wire = wire
4849
self.wire_explorer = BRepTools_WireExplorer(self.wire)
4950
self.done = False
@@ -148,7 +149,8 @@ def _loop_topo(self, topologyType, topologicalEntity=None, topologyTypeToAvoid=N
148149
TopAbs_COMPOUND: TopoDS_Compound,
149150
TopAbs_COMPSOLID: TopoDS_CompSolid}
150151

151-
assert topologyType in topoTypes.keys(), '%s not one of %s' % (topologyType, topoTypes.keys())
152+
if topologyType not in topoTypes.keys():
153+
raise AssertionError("%s not one of %s" % (topologyType, topoTypes.keys()))
152154
# use self.myShape if nothing is specified
153155
if topologicalEntity is None and topologyTypeToAvoid is None:
154156
self.topExp.Init(self.myShape, topologyType)
@@ -191,7 +193,7 @@ def faces(self):
191193

192194
def _number_of_topo(self, iterable):
193195
n = 0
194-
for i in iterable:
196+
for _ in iterable:
195197
n += 1
196198
return n
197199

@@ -366,7 +368,7 @@ def edges_from_face(self, face):
366368

367369
def number_of_edges_from_face(self, face):
368370
cnt = 0
369-
for i in self._loop_topo(TopAbs_EDGE, face):
371+
for _ in self._loop_topo(TopAbs_EDGE, face):
370372
cnt += 1
371373
return cnt
372374

test/core_extend_topology_unittest.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -118,20 +118,9 @@ def test_edge_wire(self):
118118

119119

120120
def test_vertex_edge(self):
121-
vert = next(topo.vertices())
122121
edge = next(topo.edges())
123122
verts_from_edge = [i for i in topo.vertices_from_edge(edge)]
124123
self.assertEqual(len(verts_from_edge), topo.number_of_vertices_from_edge(edge))
125-
# following test is commented out. Moving up to occt7.4.0
126-
# introduced a regression in this test:
127-
#Traceback (most recent call last):
128-
#File "core_extend_topology_unittest.py", line 126, in test_vertex_edge
129-
#self.assertEqual(len(edges_from_vert), topo.number_of_edges_from_vertex(vert))
130-
#AssertionError: 3 != 6
131-
# not sure this is really ap pythonocc bug
132-
# commented out for now, let's see later if the issue comes up
133-
edges_from_vert = [i for i in topo.edges_from_vertex(vert)]
134-
#self.assertEqual(len(edges_from_vert), topo.number_of_edges_from_vertex(vert))
135124

136125

137126
def test_vertex_face(self):

test/core_geometry_unittest.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
##You should have received a copy of the GNU Lesser General Public License
1818
##along with pythonOCC. If not, see <http://www.gnu.org/licenses/>.
1919

20-
from __future__ import print_function
21-
2220
import unittest
2321

2422
from OCC.Core.gp import (gp_Pnt, gp_Pnt2d, gp_Ax3, gp_Vec, gp_Pln,
@@ -184,6 +182,7 @@ def test_point_from_projections(self):
184182
Q = PPS.Point(i)
185183
distance = PPS.Distance(i)
186184
pstring = "Q" + repr(i) + ": at Distance :" + repr(PPS.Distance(i))
185+
print(pstring)
187186

188187
def test_points_from_intersection(self):
189188
'''Test: points from intersection'''
@@ -237,7 +236,7 @@ def test_axis(self):
237236
AXDirection = A.XDirection()
238237
self.assertIsInstance(AXDirection, gp_Dir)
239238
AYDirection = A.YDirection()
240-
self.assertIsInstance(AXDirection, gp_Dir)
239+
self.assertIsInstance(AYDirection, gp_Dir)
241240
P2 = gp_Pnt(5, 3, 4)
242241
A2 = gp_Ax3(P2, D)
243242
A2.YReverse()

0 commit comments

Comments
 (0)