Revert "Updating CadQuery library to include sagittaArc changes."
This reverts commit 19994ffd48
.
This commit is contained in:
parent
bfaa18163f
commit
92b07d059d
|
@ -14,12 +14,12 @@ before_install:
|
||||||
conda config --set always_yes yes --set changeps1 no;
|
conda config --set always_yes yes --set changeps1 no;
|
||||||
conda update -q conda;
|
conda update -q conda;
|
||||||
conda info -a;
|
conda info -a;
|
||||||
conda create -y -q -n freecad_cq3 -c cadquery -c conda-forge freecad=0.17 python=3.6 pyparsing conda mock coverage codecov;
|
conda create -y -q -n freecad_cq3 -c freecad -c freecad/label/broken -c conda-forge freecad=0.17=py36_11 occt=7.2.0=occt7.2.0_0 python=3.6 pyparsing conda mock coverage codecov;
|
||||||
source ~/miniconda/bin/activate freecad_cq3;
|
source ~/miniconda/bin/activate freecad_cq3;
|
||||||
else
|
else
|
||||||
sudo add-apt-repository -y ppa:freecad-maintainers/freecad-stable;
|
sudo add-apt-repository -y ppa:freecad-maintainers/freecad-stable;
|
||||||
sudo apt-get update -qq;
|
sudo apt-get update -qq;
|
||||||
sudo apt-get install -y freecad;
|
sudo apt-get install -y freecad freecad-doc;
|
||||||
pip install -r requirements-dev.txt;
|
pip install -r requirements-dev.txt;
|
||||||
pip install travis-sphinx;
|
pip install travis-sphinx;
|
||||||
pip install sphinx_rtd_theme;
|
pip install sphinx_rtd_theme;
|
||||||
|
|
|
@ -12,7 +12,7 @@ install:
|
||||||
- set "PATH=%MINICONDA_DIRNAME%;%MINICONDA_DIRNAME%\\Scripts;%PATH%"
|
- set "PATH=%MINICONDA_DIRNAME%;%MINICONDA_DIRNAME%\\Scripts;%PATH%"
|
||||||
- conda config --set always_yes yes
|
- conda config --set always_yes yes
|
||||||
- conda update -q conda
|
- conda update -q conda
|
||||||
- conda create --quiet --name cqtest -c cadquery -c conda-forge python=%PYTHON_VERSION% freecad=0.17 python=3.6 pyparsing mock coverage codecov
|
- conda create --quiet --name cqtest -c freecad -c freecad/label/broken -c conda-forge python=%PYTHON_VERSION% freecad=0.17=py36_vc14_13 occt=7.2.0 python=3.6 pyparsing mock coverage codecov
|
||||||
- activate cqtest
|
- activate cqtest
|
||||||
- python setup.py install
|
- python setup.py install
|
||||||
|
|
||||||
|
|
|
@ -1320,77 +1320,17 @@ class Workplane(CQ):
|
||||||
provide tangent arcs
|
provide tangent arcs
|
||||||
"""
|
"""
|
||||||
|
|
||||||
startPoint = self._findFromPoint(False)
|
gstartPoint = self._findFromPoint(False)
|
||||||
point1 = self.plane.toWorldCoords(point1)
|
gpoint1 = self.plane.toWorldCoords(point1)
|
||||||
point2 = self.plane.toWorldCoords(point2)
|
gpoint2 = self.plane.toWorldCoords(point2)
|
||||||
|
|
||||||
arc = Edge.makeThreePointArc(startPoint, point1, point2)
|
arc = Edge.makeThreePointArc(gstartPoint, gpoint1, gpoint2)
|
||||||
|
|
||||||
if not forConstruction:
|
if not forConstruction:
|
||||||
self._addPendingEdge(arc)
|
self._addPendingEdge(arc)
|
||||||
|
|
||||||
return self.newObject([arc])
|
return self.newObject([arc])
|
||||||
|
|
||||||
def sagittaArc(self, endPoint, sag, forConstruction=False):
|
|
||||||
"""
|
|
||||||
Draw an arc from the current point to endPoint with an arc defined by the sag (sagitta).
|
|
||||||
|
|
||||||
:param endPoint: end point for the arc
|
|
||||||
:type endPoint: 2-tuple, in workplane coordinates
|
|
||||||
:param sag: the sagitta of the arc
|
|
||||||
:type sag: float, perpendicular distance from arc center to arc baseline.
|
|
||||||
:return: a workplane with the current point at the end of the arc
|
|
||||||
|
|
||||||
The sagitta is the distance from the center of the arc to the arc base.
|
|
||||||
Given that a closed contour is drawn clockwise;
|
|
||||||
A positive sagitta means convex arc and negative sagitta means concave arc.
|
|
||||||
See "https://en.wikipedia.org/wiki/Sagitta_(geometry)" for more information.
|
|
||||||
"""
|
|
||||||
|
|
||||||
startPoint = self._findFromPoint(useLocalCoords=True)
|
|
||||||
endPoint = Vector(endPoint)
|
|
||||||
midPoint = endPoint.add(startPoint).multiply(0.5)
|
|
||||||
|
|
||||||
sagVector = endPoint.sub(startPoint).normalized().multiply(abs(sag))
|
|
||||||
if(sag > 0):
|
|
||||||
sagVector.x, sagVector.y = -sagVector.y, sagVector.x # Rotate sagVector +90 deg
|
|
||||||
else:
|
|
||||||
sagVector.x, sagVector.y = sagVector.y, -sagVector.x # Rotate sagVector -90 deg
|
|
||||||
|
|
||||||
sagPoint = midPoint.add(sagVector)
|
|
||||||
|
|
||||||
return self.threePointArc(sagPoint, endPoint, forConstruction)
|
|
||||||
|
|
||||||
def radiusArc(self, endPoint, radius, forConstruction=False):
|
|
||||||
"""
|
|
||||||
Draw an arc from the current point to endPoint with an arc defined by the sag (sagitta).
|
|
||||||
|
|
||||||
:param endPoint: end point for the arc
|
|
||||||
:type endPoint: 2-tuple, in workplane coordinates
|
|
||||||
:param radius: the radius of the arc
|
|
||||||
:type radius: float, the radius of the arc between start point and end point.
|
|
||||||
:return: a workplane with the current point at the end of the arc
|
|
||||||
|
|
||||||
Given that a closed contour is drawn clockwise;
|
|
||||||
A positive radius means convex arc and negative radius means concave arc.
|
|
||||||
"""
|
|
||||||
|
|
||||||
startPoint = self._findFromPoint(useLocalCoords=True)
|
|
||||||
endPoint = Vector(endPoint)
|
|
||||||
|
|
||||||
# Calculate the sagitta from the radius
|
|
||||||
length = endPoint.sub(startPoint).Length / 2.0
|
|
||||||
try:
|
|
||||||
sag = abs(radius) - math.sqrt(radius**2 - length**2)
|
|
||||||
except ValueError:
|
|
||||||
raise ValueError("Arc radius is not large enough to reach the end point.")
|
|
||||||
|
|
||||||
# Return a sagittaArc
|
|
||||||
if radius > 0:
|
|
||||||
return self.sagittaArc(endPoint, sag, forConstruction)
|
|
||||||
else:
|
|
||||||
return self.sagittaArc(endPoint, -sag, forConstruction)
|
|
||||||
|
|
||||||
def rotateAndCopy(self, matrix):
|
def rotateAndCopy(self, matrix):
|
||||||
"""
|
"""
|
||||||
Makes a copy of all edges on the stack, rotates them according to the
|
Makes a copy of all edges on the stack, rotates them according to the
|
||||||
|
@ -1798,13 +1738,6 @@ class Workplane(CQ):
|
||||||
|
|
||||||
s = Workplane().lineTo(1,0).lineTo(1,1).close().extrude(0.2)
|
s = Workplane().lineTo(1,0).lineTo(1,1).close().extrude(0.2)
|
||||||
"""
|
"""
|
||||||
endPoint = self._findFromPoint(True)
|
|
||||||
startPoint = self.ctx.firstPoint
|
|
||||||
|
|
||||||
# Check if there is a distance between startPoint and endPoint
|
|
||||||
# that is larger than what is considered a numerical error.
|
|
||||||
# If so; add a line segment between endPoint and startPoint
|
|
||||||
if endPoint.sub(startPoint).Length > 1e-6:
|
|
||||||
self.lineTo(self.ctx.firstPoint.x, self.ctx.firstPoint.y)
|
self.lineTo(self.ctx.firstPoint.x, self.ctx.firstPoint.y)
|
||||||
|
|
||||||
# Need to reset the first point after closing a wire
|
# Need to reset the first point after closing a wire
|
||||||
|
|
|
@ -18,27 +18,14 @@ thickness = 0.25 # Thickness of the plate
|
||||||
# half-way back to the origin in the X direction and 0.5 mm above where
|
# half-way back to the origin in the X direction and 0.5 mm above where
|
||||||
# the last line ended at. The arc then ends at (0.0, 1.0), which is 1.0 mm
|
# the last line ended at. The arc then ends at (0.0, 1.0), which is 1.0 mm
|
||||||
# above (in the Y direction) where our first line started from.
|
# above (in the Y direction) where our first line started from.
|
||||||
# 5. An arc is drawn from the last point that ends on (-0.5, 1.0), the sag of
|
# 5. close() is called to automatically draw the last line for us and close
|
||||||
# the curve 0.2 determines that the curve is concave with the midpoint 0.1 mm
|
|
||||||
# from the arc baseline. If the sag was -0.2 the arc would be convex.
|
|
||||||
# This convention is valid when the profile is drawn counterclockwise.
|
|
||||||
# The reverse is true if the profile is drawn clockwise.
|
|
||||||
# Clockwise: +sag => convex, -sag => concave
|
|
||||||
# Counterclockwise: +sag => concave, -sag => convex
|
|
||||||
# 6. An arc is drawn from the last point that ends on (-0.7, -0.2), the arc is
|
|
||||||
# determined by the radius of -1.5 mm.
|
|
||||||
# Clockwise: +radius => convex, -radius => concave
|
|
||||||
# Counterclockwise: +radius => concave, -radius => convex
|
|
||||||
# 7. close() is called to automatically draw the last line for us and close
|
|
||||||
# the sketch so that it can be extruded.
|
# the sketch so that it can be extruded.
|
||||||
# 7a. Without the close(), the 2D sketch will be left open and the extrude
|
# 5a. Without the close(), the 2D sketch will be left open and the extrude
|
||||||
# operation will provide unpredictable results.
|
# operation will provide unpredictable results.
|
||||||
# 8. The 2D sketch is extruded into a solid object of the specified thickness.
|
# 6. The 2D sketch is extruded into a solid object of the specified thickness.
|
||||||
result = cq.Workplane("front").lineTo(width, 0) \
|
result = cq.Workplane("front").lineTo(width, 0) \
|
||||||
.lineTo(width, 1.0) \
|
.lineTo(width, 1.0) \
|
||||||
.threePointArc((1.0, 1.5), (0.0, 1.0)) \
|
.threePointArc((1.0, 1.5), (0.0, 1.0)) \
|
||||||
.sagittaArc((-0.5, 1.0), 0.2) \
|
|
||||||
.radiusArc((-0.7, -0.2), -1.5) \
|
|
||||||
.close().extrude(thickness)
|
.close().extrude(thickness)
|
||||||
|
|
||||||
# Displays the result of this script
|
# Displays the result of this script
|
||||||
|
|
|
@ -867,20 +867,6 @@ class TestCadQuery(BaseTest):
|
||||||
r.vertices(selectors.NearestToPointSelector((0.0, 0.0, 0.0)))\
|
r.vertices(selectors.NearestToPointSelector((0.0, 0.0, 0.0)))\
|
||||||
.first().val().Y))
|
.first().val().Y))
|
||||||
|
|
||||||
# Test the sagittaArc and radiusArc functions
|
|
||||||
a1 = Workplane(Plane.YZ()).threePointArc((5, 1), (10, 0))
|
|
||||||
a2 = Workplane(Plane.YZ()).sagittaArc((10, 0), -1)
|
|
||||||
a3 = Workplane(Plane.YZ()).threePointArc((6, 2), (12, 0))
|
|
||||||
a4 = Workplane(Plane.YZ()).radiusArc((12, 0), -10)
|
|
||||||
|
|
||||||
assert(a1.edges().first().val().geomType() == "CIRCLE")
|
|
||||||
assert(a2.edges().first().val().geomType() == "CIRCLE")
|
|
||||||
assert(a3.edges().first().val().geomType() == "CIRCLE")
|
|
||||||
assert(a4.edges().first().val().geomType() == "CIRCLE")
|
|
||||||
|
|
||||||
assert(a1.edges().first().val().Length() == a2.edges().first().val().Length())
|
|
||||||
assert(a3.edges().first().val().Length() == a4.edges().first().val().Length())
|
|
||||||
|
|
||||||
def testLargestDimension(self):
|
def testLargestDimension(self):
|
||||||
"""
|
"""
|
||||||
Tests the largestDimension function when no solids are on the stack and when there are
|
Tests the largestDimension function when no solids are on the stack and when there are
|
||||||
|
@ -1605,36 +1591,3 @@ class TestCadQuery(BaseTest):
|
||||||
self.assertTupleAlmostEquals(delta.toTuple(),
|
self.assertTupleAlmostEquals(delta.toTuple(),
|
||||||
(0.,0.,2.*h),
|
(0.,0.,2.*h),
|
||||||
decimal_places)
|
decimal_places)
|
||||||
|
|
||||||
def testClose(self):
|
|
||||||
# Close without endPoint and startPoint coincide.
|
|
||||||
# Create a half-circle
|
|
||||||
a = Workplane(Plane.XY()).sagittaArc((10, 0), 2).close().extrude(2)
|
|
||||||
|
|
||||||
# Close when endPoint and startPoint coincide.
|
|
||||||
# Create a double half-circle
|
|
||||||
b = Workplane(Plane.XY()).sagittaArc((10, 0), 2).sagittaArc((0, 0), 2).close().extrude(2)
|
|
||||||
|
|
||||||
# The b shape shall have twice the volume of the a shape.
|
|
||||||
self.assertAlmostEqual(a.val().wrapped.Volume * 2.0, b.val().wrapped.Volume)
|
|
||||||
|
|
||||||
# Testcase 3 from issue #238
|
|
||||||
thickness = 3.0
|
|
||||||
length = 10.0
|
|
||||||
width = 5.0
|
|
||||||
|
|
||||||
obj1 = Workplane('XY', origin=(0, 0, -thickness / 2)) \
|
|
||||||
.moveTo(length / 2, 0).threePointArc((0, width / 2), (-length / 2, 0)) \
|
|
||||||
.threePointArc((0, -width / 2), (length / 2, 0)) \
|
|
||||||
.close().extrude(thickness)
|
|
||||||
|
|
||||||
os_x = 8.0 # Offset in X
|
|
||||||
os_y = -19.5 # Offset in Y
|
|
||||||
|
|
||||||
obj2 = Workplane('YZ', origin=(os_x, os_y, -thickness / 2)) \
|
|
||||||
.moveTo(os_x + length / 2, os_y).sagittaArc((os_x -length / 2, os_y), width / 2) \
|
|
||||||
.sagittaArc((os_x + length / 2, os_y), width / 2) \
|
|
||||||
.close().extrude(thickness)
|
|
||||||
|
|
||||||
# The obj1 shape shall have the same volume as the obj2 shape.
|
|
||||||
self.assertAlmostEqual(obj1.val().wrapped.Volume, obj2.val().wrapped.Volume)
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user