forked from magwas/SurfaceMesh
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Layer.py
64 lines (51 loc) · 1.97 KB
/
Layer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# coding=UTF-8
import FreeCAD
from DocumentObject import DocumentObject
class SMLayer(DocumentObject):
""" A layer """
pytype = "SMLayer"
def __init__(self,mesh,name=None):
DocumentObject.__init__(self)
if name == None:
name = self.getDefaultName()
FreeCAD.ActiveDocument.addObject("App::FeaturePython","Layer",self,self)
self.addProperty("App::PropertyLinkList","Edges","Base", "Edges")
self.addProperty("App::PropertyLinkList","Points","Base", "Points")
self.addProperty("App::PropertyLinkList","Faces","Base", "Faces")
self.addProperty("App::PropertyLinkList","Layers","Base", "Faces")
#self.addProperty("App::PropertyLink","Mesh","Base", "The mesh this point is in")
#self.Mesh=mesh.getobj()
mesh.registerLayer(self)
self.Label = name
def getEdges(self):
ret = map(lambda x: x.Proxy,self.Edges)
for l in self.Layers:
ret.extend(l.Proxy.getEdges())
return ret
def getLayers(self):
ret = map(lambda x: x.Proxy,self.Layers)
for l in self.Layers:
ret.extend(l.Proxy.getLayers())
return ret
def getFaces(self):
ret = map(lambda x: x.Proxy,self.Faces)
for l in self.Layers:
ret.extend(l.Proxy.getFaces())
return ret
def getPoints(self):
ret = map(lambda x: x.Proxy,self.Points)
for l in self.Layers:
ret.extend(l.Proxy.getFaces())
return ret
def registerPoint(self,p):
self.Points += [p.getobj()]
def registerEdge(self,p):
self.Edges += [p.getobj()]
def registerFace(self,p):
self.Faces += [p.getobj()]
@staticmethod
def getDefaultName():
return "Default Layer"
def claimChildren(self):
#FreeCAD.Console.PrintMessage("claim %s\n"%(self.Object.Label))
return self.Object.Edges + self.Object.Points + self.Object.Faces