From 3a5e5286258f1ffb0822e530931d0a20f6a274f1 Mon Sep 17 00:00:00 2001 From: Runar Tenfjord Date: Sun, 10 Jan 2016 15:47:31 +0100 Subject: [PATCH] Fix build against OCE 0.17 and Python3.5 --- Makefile | 8 +- occmodel/@src/OCCBase.cpp | 3 +- occmodel/@src/OCCFace.cpp | 2 +- occmodel/test.py | 205 +++++++++++++++++--------------------- 4 files changed, 100 insertions(+), 118 deletions(-) diff --git a/Makefile b/Makefile index ee655c4..c70508d 100644 --- a/Makefile +++ b/Makefile @@ -2,13 +2,13 @@ # File: Makefile (for library) # # The variables 'PYTHON' and 'PYVER' can be modified by -# passing parameters to make: make PYTHON=python PYVER=2.6 +# passing parameters to make: make PYTHON=python PYVER=2.7 # -PYTHON=python2 -PYVER=2.7 +PYTHON=python3 +PYVER=3.5 CC=g++ -CFLAGS=-Wall -fPIC -O2 -frtti -fexceptions -Isrc -I/usr/include/oce +CFLAGS=-Wall -fPIC -O2 -frtti -fexceptions -Isrc -I/mingw64/include/oce LIB=occmodel/liboccmodel.a LIBSRC = $(wildcard occmodel/@src/*.cpp) diff --git a/occmodel/@src/OCCBase.cpp b/occmodel/@src/OCCBase.cpp index 030458d..0af9e09 100644 --- a/occmodel/@src/OCCBase.cpp +++ b/occmodel/@src/OCCBase.cpp @@ -30,8 +30,7 @@ int OCCBase::transform(DVec mat, OCCBase *target) trans.SetValues( mat[0], mat[1], mat[2], mat[3], mat[4], mat[5], mat[6], mat[7], - mat[8], mat[9], mat[10], mat[11], - 0.00001,0.00001 + mat[8], mat[9], mat[10], mat[11] ); BRepBuilderAPI_Transform aTrans(shape, trans, Standard_True); aTrans.Build(); diff --git a/occmodel/@src/OCCFace.cpp b/occmodel/@src/OCCFace.cpp index 2580605..24d5c7f 100644 --- a/occmodel/@src/OCCFace.cpp +++ b/occmodel/@src/OCCFace.cpp @@ -453,7 +453,7 @@ OCCMesh *OCCFace::createMesh(double factor, double angle, bool qualityNormals = MSH.Perform(this->getShape()); - BRepMesh::Mesh(this->getShape(),factor*maxd); + BRepMesh_IncrementalMesh(this->getShape(),factor*maxd); if (this->getShape().ShapeType() != TopAbs_FACE) { TopExp_Explorer exFace; diff --git a/occmodel/test.py b/occmodel/test.py index 9425b53..1286291 100644 --- a/occmodel/test.py +++ b/occmodel/test.py @@ -5,13 +5,14 @@ # from math import pi, sin, cos, copysign +from geotools import * from occmodel import * ''' pnts = ((0.,0.,0.), (0.,2.,0.), (1.,2.,0.), (1.,0.,0.)) f1 = Face().createPolygonal(pnts) -print f1 -print f1.area() +print(f1) +print(f1.area()) ''' ''' @@ -19,15 +20,15 @@ end = Vertex(1.,0.,0.) pnts = ((0.,2.,0.), (1.,1.5,0.)) b1 = Edge().createBezier(start,end,pnts) -print b1 -print b1.length() +print(b1) +print(b1.length()) start = None end = None pnts = ((0.,0.,0.), (0.,2.,0.), (0.5,1.,0.), (1.,-1.,0.)) b1 = Edge().createBezier(start,end,pnts) -print b1 -print b1.length() +print(b1) +print(b1.length()) ''' ''' @@ -35,49 +36,49 @@ end = Vertex(1.,0.,0.) pnts = ((0.,2.,0.), (5.,1.5,0.)) s1 = Edge().createSpline(start,end,pnts) -print s1 -print s1.length() +print(s1) +print(s1.length()) ''' ''' start = None end = None -pnts = ((0.,0.,0.),(0.,2.,0.), (5.,1.5,0.)) +pnts = ((0.,0.,0.),(0.,2.,0.), (5.,1.5,0.),(0.,0.,0.)) e1 = Edge().createSpline(start,end,pnts) -print e1 -print e1.length() +print(e1) +print(e1.length()) face = Face().createFace(e1) -print face -print face.area() +print(face) +print(face.area()) solid = Solid().extrude(face, (0.,0.,0.), (0.,0.,5.)) -print solid -print 'area = ', solid.area() -print 'volume = ', solid.volume() +print(solid) +print('area = ', solid.area()) +print('volume = ', solid.volume()) ''' ''' start = Vertex(1.,0.,0.) end = Vertex(-1.,0.,0.) e1 = Edge().createLine(end,start) -print e1 -print e1.length() +print(e1) +print(e1.length()) pnt = (0.,1.,0.) e2 = Edge().createArc3P(start,end,pnt) -print e2 -print e2.length() +print(e2) +print(e2.length()) -face = Face().createFace((e1,e2), ((0.,.5,.5),)) -print face -print face.area() +face = Face().createConstrained((e1,e2), ((0.,.5,.5),)) +print(face) +print(face.area()) solid = Solid().extrude(face, (0.,0.,0.), (0.,0.,5.)) -print solid -print 'area = ', solid.area() -print 'volume = ', solid.volume() -viewer((face, e1), ('red', 'green')) +print(solid) +print('area = ', solid.area()) +print('volume = ', solid.volume()) +#viewer((face, e1), ('red', 'green')) ''' ''' @@ -85,7 +86,7 @@ e2 = Edge().createCircle(center=(0.,0.,5.),normal=(0.,0.,1.),radius = 1.5) e3 = Edge().createCircle(center=(0.,0.,10.),normal=(0.,0.,1.),radius = 1.0) solid = Solid().loft((e1,e2,e3), True) -print solid.volume() +print(solid.volume()) #solid.writeSTEP('test.stp') #viewer(solid) ''' @@ -100,35 +101,26 @@ ''' e1 = Edge().createCircle(center=(0.,0.,0.),normal=(0.,0.,1.),radius = 1.) face = Face().createFace(e1) -print face -print face.area() -print face.inertia() +print(face) +print(face.area()) +print(face.inertia()) solid = Solid().extrude(face, (0.,0.,0.), (0.,0.,1.)) -print solid -print 'area = ', solid.area() -print 'volume = ', solid.volume() +print(solid) +print('area = ', solid.area()) +print('volume = ', solid.volume()) ''' ''' e1 = Edge().createCircle(center=(0.,0.,0.),normal=(0.,0.,1.),radius = 1.) face = Face().createFace(e1) -print face -print face.area() +print(face) +print(face.area()) solid = Solid().revolve(face, (0.,2.,0.), (1.,2.,0.), 90.) -print solid -print 'area = ', solid.area() -print 'volume = ', solid.volume() -''' - -''' -model = Model() -model.createSphere(1.,2.,3.,.5) -#model.translate(-1.,-2.,-3.) -model.rotate((0.,0.,0.),(1.,0.,0.), 15.) -model.writeSTEP('test.stp') -print model +print(solid) +print('area = ', solid.area()) +print('volume = ', solid.volume()) ''' ''' @@ -137,82 +129,73 @@ plane = Plane.fromNormal((1.,2.,3.), (0.,1.,1.)) sec = solid.section(plane) -print 'area = ', sec.area() - -viewer(sec) -''' - -''' -solid = Solid().createBox((0.,0.,0.),(100.,100.,100.)) -solid.shell(-5, lambda near,far: near[2] > 50 and far[2] > 50) -solid.fillet(2., lambda near,far: True) -#solid.writeSTEP('test.stp') -viewer(solid) +print('area = ', sec.area()) +#viewer(sec) ''' ''' s1 = Solid().createSphere((0.,0.,0.),.5) s2 = Solid().createSphere((.25,0.,0.),.5) -#s1.booleanUnion(s2) -#s1.booleanDifference(s2) -s1.booleanIntersection(s2) +#s1.fuse(s2) +#s1.cut(s2) +s1.common(s2) #s1.writeSTEP('test.stp') -print s1.volume() +print(s1.volume()) ''' ''' s1 = Solid().createSphere((0.,0.,0.),.5) -print s1.centreOfMass() +print(s1.centreOfMass()) s1.translate((1.,0.,0.)) -print s1.centreOfMass() +print(s1.centreOfMass()) ''' ''' s1 = Solid().createSphere((0.,0.,0.),.5) -print s1.volume() +print(s1.volume()) s2 = Solid().createSphere((2.,0.,0.),.5) -print s2.volume() +print(s2.volume()) s3 = Solid().addSolids((s1,s2)) -print s3.volume() +print(s3.volume()) ''' ''' sp1 = Solid().createSphere((0.,0.,0.),.5) -print sp1.volume() +print(sp1.volume()) sp2 = sp1.copy() -print sp1.volume() +print(sp1.volume()) sp2.translate((.5, 0., 0.)) #sp2.scale((.5, 0., 0.), 1.25) -sp2.rotate((0.,-1.,0.),(0.,1.,0.),10.) -sp1.booleanDifference(sp2) +sp2.rotate(10.,(0.,-1.,0.),(0.,1.,0.)) +sp1.cut(sp2) ''' ''' sp1 = Solid().createCylinder((0.,0.,0.),(0.,0.,1.), 1.) -print sp1.volume() +print(sp1.volume()) ''' ''' sp1 = Solid().createTorus((0.,0.,0.),(0.,0.,1.), 1., 2.) -print sp1.volume() +print(sp1.volume()) ''' ''' c1 = Solid().createCone((0.,0.,0.),(0.,0.,1.), 1., 2.) -print c1.volume() +print(c1.volume()) ''' ''' b1 = Solid().createBox((0.,0.,0.),(1.,1.,1.)) -print b1.volume() +print(b1.volume()) ''' ''' b1 = Solid().createBox((0.,0.,0.),(1.,1.,1.)) -print b1.volume() +print(b1.volume()) b1.fillet(.25, lambda start,end: start[2] > .5 and end[2] > .5) -print b1.volume() +print(b1.volume()) ''' ''' @@ -225,7 +208,7 @@ face = Face().createFace(e2) s1 = Solid().pipe(face, e1) -print s1.volume() +print(s1.volume()) ''' ''' @@ -239,19 +222,19 @@ e4 = Edge().createLine(p4,p1) face = Face().createFace((e1,e2,e3,e4)) -print face.centreOfMass() +print(face.centreOfMass()) mesh = face.createMesh(0.1,.5) -print mesh +print(mesh) ''' ''' #solid = Solid().createSphere((0.,0.,0.),.5) solid = Solid().createBox((0.,0.,0.),(1.,1.,1.)) mesh = solid.createMesh(0.1,.5) -print mesh -print mesh.vertex(0) -print mesh.normal(0) -print mesh.triangle(0) +print(mesh) +print(mesh.vertex(0)) +print(mesh.normal(0)) +print(mesh.triangle(0)) ''' ''' @@ -259,16 +242,16 @@ end = Vertex(-1.,0.,0.) pnt = (0.,1.,0.) e1 = Edge().createArc3P(start,end,pnt) -print e1.boundingBox() +print(e1.boundingBox()) pnts = e1.tesselate() -print pnts +print(pnts) ''' ''' e1 = Edge().createHelix(.5, 2., 1.0, 0.) -print e1.length() -print e1.start -print e1.end +print(e1.length()) +print(e1.start) +print(e1.end) ''' ''' @@ -281,9 +264,9 @@ e3 = Edge().createLine(p3,p4) e4 = Edge().createLine(p4,p1) w1 = Wire().createWire((e1,e2,e3,e4)) -print w1.length() +print(w1.length()) f1 = Face().createFace(w1) -print f1.area() +print(f1.area()) ''' ''' @@ -291,26 +274,26 @@ e2 = Edge().createEllipse(center=(0.,0.,5.),normal=(0.,0.,1.), rMajor = 2.0, rMinor=1.0) e3 = Edge().createCircle(center=(0.,0.,10.),normal=(0.,0.,1.),radius = 1.0) solid = Solid().loft((e1,e2,e3), False) -print solid.volume() +print(solid.volume()) ''' ''' rect = Wire().createRectangle(height = 2., radius = .5) -print rect.length() +print(rect.length()) ''' ''' w1 = Wire().createRegularPolygon() -print w1.length() +print(w1.length()) f1 = Face().createFace(w1) -print f1.area() +print(f1.area()) ''' ''' e1 = Edge().createCircle(center=(0.,0.,0.),normal=(0.,0.,1.),radius = 1.) plane = Plane() -print e1.hasPlane(plane = plane) -print plane +print(e1.hasPlane(plane = plane)) +print(plane) ''' ''' @@ -328,7 +311,7 @@ e2 = Edge().createCircle(center=(0.,0.,.5),normal=(0.,0.,1.),radius = 1.5) v1 = Vertex(0.,0.,1.) solid = Solid().loft((e1,e2,v1)) -print solid.volume() +print(solid.volume()) ''' ''' @@ -341,7 +324,7 @@ e1 = Edge().createCircle(center=(0.,0.,0.),normal=(0.,0.,1.),radius = 1.) solid = Solid().sweep(w1, e1, cornerMode = SWEEP_RIGHT_CORNER) -print solid.volume() +print(solid.volume()) ''' ''' @@ -368,7 +351,7 @@ e1 = Edge().createCircle(center=(0.,0.,0.),normal=(0.,0.,1.),radius = 1.) solid = Solid().sweep(w1, e1, cornerMode = SWEEP_RIGHT_CORNER) -print solid.volume() +print(solid.volume()) ''' ''' @@ -383,7 +366,7 @@ face.cut(e3) s1 = Solid().pipe(face, e1) -print s1.volume() +print(s1.volume()) ''' ''' @@ -398,7 +381,7 @@ e2 = Edge().createArc(start,end,cen) face = Face().loft((e1,e2)) -print face.isValid() +print(face.isValid()) ''' ''' @@ -410,7 +393,7 @@ e2 = Edge().createCircle(center=(0.,0.,0.),normal=(0.,0.,1.),radius = 1.) face = Face().sweep(e2, e1) -print face.isValid() +print(face.isValid()) ''' ''' @@ -418,9 +401,9 @@ e2 = Edge().createCircle(center=(-1.,0.,0.),normal=(0.,0.,1.),radius = .5) e3 = Edge().createCircle(center=(1.,0.,0.),normal=(0.,0.,1.),radius = .5) w1 = Wire().createWire(e1) -print w1.length() +print(w1.length()) w1.cut((e2,e3)) -print w1.length() +print(w1.length()) ''' ''' @@ -428,7 +411,7 @@ e1 = Edge().createCircle(center=(.5,0.2,.5),normal=(0.,1.,0.),radius = .25) w1 = Wire().createWire(e1) w1.project(face) -print w1.isValid() +print(w1.isValid()) ''' ''' @@ -440,14 +423,14 @@ w1 = Wire().createWire((e1,e2)) #face = Face().extrude(w1, (0.,0.,0.),(0.,0.,1.)) face = Face().revolve(w1, (0.,0.,0.),(0.,1.,0.), 90.) -print face.isValid() -#print face.typeName() +print(face.isValid()) +#print(face.typeName()) #Tools.writeSTEP('test.stp', face) ''' #solid = Solid() #solid.createSphere((1.,2.,3.),.5) -#print solid.shapeType() +#print(solid.shapeType()) #Tools.writeSTEP('test.stp', solid) #Tools.writeBREP('test.brp', solid) #Tools.writeSTL('test.stl', solid) -print Tools.readSTEP('test.stp') \ No newline at end of file +#print(Tools.readSTEP('test.stp')) \ No newline at end of file