1 """
2 Path.
3
4 """
5
6 from fabmetheus_utilities.geometry.geometry_tools import dictionary
7 from fabmetheus_utilities.geometry.geometry_tools import vertex
8 from fabmetheus_utilities.geometry.geometry_utilities.evaluate_elements import setting
9 from fabmetheus_utilities.geometry.geometry_utilities import evaluate
10 from fabmetheus_utilities.geometry.geometry_utilities import matrix
11 from fabmetheus_utilities.vector3 import Vector3
12 from fabmetheus_utilities import euclidean
13 from fabmetheus_utilities import svg_writer
14 from fabmetheus_utilities import xml_simple_reader
15 from fabmetheus_utilities import xml_simple_writer
16
17
18 __author__ = 'Enrique Perez (perez_enrique@yahoo.com)'
19 __credits__ = 'Art of Illusion <http://www.artofillusion.org/>'
20 __date__ = '$Date: 2008/02/05 $'
21 __license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
22
23
25 'Convert the xml element to a path xml element.'
26 createLinkPath(xmlElement)
27 xmlElement.xmlObject.vertexes = geometryOutput
28 vertex.addGeometryList(geometryOutput, xmlElement)
29
31 'Convert the xml element by geometryOutput.'
32 if geometryOutput == None:
33 return
34 if len(geometryOutput) < 1:
35 return
36 if len(geometryOutput) == 1:
37 firstLoop = geometryOutput[0]
38 if firstLoop.__class__ == list:
39 geometryOutput = firstLoop
40 firstElement = geometryOutput[0]
41 if firstElement.__class__ == list:
42 if len(firstElement) > 1:
43 convertXMLElementRenameByPaths(geometryOutput, xmlElement)
44 else:
45 convertXMLElementByPath(firstElement, xmlElement)
46 else:
47 convertXMLElementByPath(geometryOutput, xmlElement)
48
56
58 'Create and link a path object.'
59 xmlElement.localName = 'path'
60 xmlElement.linkObject(Path())
61
65
66
67 -class Path(dictionary.Dictionary):
122
123
125 'An svg carving.'
126 - def __init__(self, addLayerTemplate, xmlElement):
127 'Add empty lists.'
128 self.addLayerTemplate = addLayerTemplate
129 self.layerThickness = 1.0
130 self.rotatedLoopLayers = []
131 self.xmlElement = xmlElement
132
134 'Get the string representation of this carving.'
135 return self.getCarvedSVG()
136
137 - def addXML(self, depth, output):
140
142 'Get the corner maximum of the vertexes.'
143 return self.cornerMaximum
144
146 'Get the corner minimum of the vertexes.'
147 return self.cornerMinimum
148
152
154 'Get the layer thickness.'
155 return self.layerThickness
156
158 'Get the rotated boundary layers.'
159 return self.rotatedLoopLayers
160
164
166 'Return the suffix for a carving.'
167 return 'svg'
168
170 'Parse SVG element and store the layers.'
171 self.fileName = fileName
172 paths = self.xmlElement.xmlObject.getPaths()
173 oldZ = None
174 self.rotatedLoopLayers = []
175 rotatedLoopLayer = None
176 for path in paths:
177 if len(path) > 0:
178 z = path[0].z
179 if z != oldZ:
180 rotatedLoopLayer = euclidean.RotatedLoopLayer(z)
181 self.rotatedLoopLayers.append(rotatedLoopLayer)
182 oldZ = z
183 rotatedLoopLayer.loops.append(euclidean.getComplexPath(path))
184 if len(self.rotatedLoopLayers) < 1:
185 return
186 self.cornerMaximum = Vector3(-987654321.0, -987654321.0, -987654321.0)
187 self.cornerMinimum = Vector3(987654321.0, 987654321.0, 987654321.0)
188 svg_writer.setSVGCarvingCorners(self.cornerMaximum, self.cornerMinimum, self.layerThickness, self.rotatedLoopLayers)
189
191 'Set the infill in direction of bridge.'
192 pass
193
195 'Set the layer thickness.'
196 self.layerThickness = layerThickness
197
199 'Set the import radius.'
200 pass
201
203 'Set the is correct mesh flag.'
204 pass
205