Commit 61dd368d authored by sumpfralle's avatar sumpfralle

added "export" function to the simple Model


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@458 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent 8ccf8897
......@@ -21,6 +21,7 @@ You should have received a copy of the GNU General Public License
along with PyCAM. If not, see <http://www.gnu.org/licenses/>.
"""
import pycam.Exporters.STLExporter
from pycam.Geometry import Triangle, Line, Point
from pycam.Toolpath import Bounds
from utils import INFINITE
......@@ -60,6 +61,8 @@ class BaseModel(object):
self.maxx = None
self.maxy = None
self.maxz = None
# derived classes should override this
self._export_function = None
def __add__(self, other_model):
""" combine two models """
......@@ -86,6 +89,16 @@ class BaseModel(object):
for item in self.next():
item.to_OpenGL()
def is_export_supported(self):
return not self._export_function is None
def export(self, comment=None):
if self.is_export_supported():
return self._export_function(self, comment=comment)
else:
raise NotImplementedError(("This type of model (%s) does not " \
+ "support the 'export' function.") % str(type(self)))
def _update_limits(self, item):
if self.minx is None:
self.minx = item.minx()
......@@ -169,6 +182,7 @@ class Model(BaseModel):
super(Model, self).__init__()
self._triangles = []
self._item_groups.append(self._triangles)
self._export_function = pycam.Exporters.STLExporter.STLExporter
def append(self, item):
super(Model, self).append(item)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment