Changeset 1107
- Timestamp:
- Mar 18, 2005, 2:28:19 PM (20 years ago)
- Location:
- inundation/ga/storm_surge/pmesh
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/ga/storm_surge/pmesh/mesh.py
r1074 r1107 1237 1237 self.userSegments.extend(newsegs) 1238 1238 return newsegs 1239 def autoSegmentFilter(self,): 1240 pass 1239 def autoSegmentFilter(self,raw_boundary=True, 1240 remove_holes=False, 1241 smooth_indents=False, 1242 expand_pinch=False): 1243 """ 1244 Precon: There is a self.shape 1245 """ 1246 #FIXME remove the precon. Internally check 1247 return self._boundary2mesh(raw_boundary=raw_boundary, 1248 remove_holes=remove_holes, 1249 smooth_indents=smooth_indents, 1250 expand_pinch=expand_pinch) 1251 1241 1252 1242 1253 def autoSegment(self, alpha = None, 1243 1244 1245 1246 1254 raw_boundary=True, 1255 remove_holes=False, 1256 smooth_indents=False, 1257 expand_pinch=False): 1247 1258 """ 1248 1259 Precon: There must be 3 or more vertices in the userVertices structure 1249 1260 """ 1250 1261 self._createBoundary(alpha=alpha) 1262 return self._boundary2mesh(raw_boundary=raw_boundary, 1263 remove_holes=remove_holes, 1264 smooth_indents=smooth_indents, 1265 expand_pinch=expand_pinch) 1266 1267 def _createBoundary(self,alpha=None): 1268 """ 1269 """ 1251 1270 points=[] 1252 1271 for vertex in self.getUserVertices(): 1253 1272 points.append((vertex.x,vertex.y)) 1254 1273 self.shape = alpha_shape.alpha_shape.Alpha_Shape(points, alpha = alpha) 1274 1275 def _boundary2mesh(self, raw_boundary=True, 1276 remove_holes=False, 1277 smooth_indents=False, 1278 expand_pinch=False): 1279 """ 1280 Precon there must be a shape object. 1281 """ 1255 1282 self.shape.set_boundary_type(raw_boundary=raw_boundary, 1256 1283 remove_holes=remove_holes, -
inundation/ga/storm_surge/pmesh/pmesh.py
r1033 r1107 657 657 add Segments to bound all vertices 658 658 659 the parent attribute isn't used by this function.660 need to userstand toolbarbutton.py to know how to661 get rid of it.662 659 """ 663 660 if len(self.mesh.getUserVertices()) >= 3: 664 if alpha == None: 665 newsegs, ObjectsToVisuallyDelete, self.meshLastAlpha = self.mesh.autoSegment(remove_holes=remove_holes, 666 smooth_indents=smooth_indents, 667 expand_pinch=expand_pinch) 668 else: 669 newsegs, ObjectsToVisuallyDelete, self.meshLastAlpha = self.mesh.autoSegment(alpha=alpha, remove_holes=remove_holes, 670 smooth_indents=smooth_indents, 671 expand_pinch=expand_pinch) 672 661 newsegs, ObjectsToVisuallyDelete, self.meshLastAlpha = \ 662 self.mesh.autoSegment(alpha=alpha, 663 remove_holes=remove_holes, 664 smooth_indents=smooth_indents, 665 expand_pinch=expand_pinch) 673 666 #print "newsegs",newsegs 674 667 #print "ObjectsToVisuallyDelete",ObjectsToVisuallyDelete … … 691 684 692 685 def autoSegmentFilter (self): 693 dialog = autoSegmentFilterDialog(self.canvas) 694 dialog.use_optimum.get() == SET_ALPHA 686 dialog = AutoSegmentFilterDialog(self.canvas) 687 newsegs, ObjectsToVisuallyDelete, self.meshLastAlpha = \ 688 self.mesh.autoSegmentFilter(raw_boundary=dialog.raw_boundary.get(), 689 remove_holes=dialog.remove_holes.get(), 690 smooth_indents=dialog.smooth_indents.get(), 691 expand_pinch=dialog.expand_pinch.get()) 692 #print "newsegs",newsegs 693 #print "ObjectsToVisuallyDelete",ObjectsToVisuallyDelete 694 695 for drawOb in ObjectsToVisuallyDelete: 696 self.UserMesh.unvisualise(drawOb, self.canvas) 697 698 for segment in newsegs: 699 self.serial +=1 700 self.uniqueID = 'M*%d' % self.serial 701 self.Segments.visualise(segment, 702 self.uniqueID, 703 self.canvas, 704 self.SCALE) 695 705 696 706 def joinVerticesButton (self, parent): … … 1602 1612 Dialog box for adding segments 1603 1613 """ 1604 def __init__(self, parent, alpha): 1605 self.alpha = alpha 1614 def __init__(self, parent): 1606 1615 Dialog.__init__(self, parent) 1607 1616 … … 1616 1625 # It doesn't 1617 1626 self.boundary_type = IntVar() 1618 1619 #self.use_optimum.set(NO_SELECTION) 1620 self.ck = Radiobutton(master, value = AUTO, variable=self.use_optimum) 1621 self.ck.grid(row=1, column=0) 1622 Label(master, text='Use optimum alpha').grid(row=1, column=1, sticky=W) 1623 1624 self.ck2 = Radiobutton(master, value = SET_ALPHA, 1625 variable=self.use_optimum) 1626 self.ck2.grid(row=2, column=0) 1627 1628 Label(master, text='alpha:').grid(row=2, column=1, sticky=W) 1629 if (self.alpha): 1630 alphaVar = StringVar() 1631 alphaVar.set(self.alpha) 1632 self.alpha_str = Entry(master, 1633 textvariable = alphaVar, 1634 width = 16, name ="entry") 1635 else: 1636 self.alpha_str = Entry(master, width = 16, name ="entry") 1637 1638 self.alpha_str.grid(row=2, column=3, sticky=W) 1639 1627 1640 1628 #boundary type buttons 1641 self.ck3 = Radiobutton(master, value = mesh.RAW, 1642 variable=self.boundary_type) 1629 self.raw_boundary = IntVar() 1630 self.remove_holes = IntVar() 1631 self.smooth_indents = IntVar() 1632 self.expand_pinch = IntVar() 1633 1634 self.ck3 = Checkbutton(master, state=NORMAL, 1635 variable=self.raw_boundary) 1643 1636 self.ck3.grid(row=3, column=0) 1644 1637 Label(master, text='Raw boundary').grid(row=3, column=1, sticky=W) 1645 1638 # 1646 self.ck4 = Radiobutton(master, value = mesh.REMOVE_HOLES,1647 variable=self. boundary_type)1639 self.ck4 = Checkbutton(master, state=NORMAL, 1640 variable=self.remove_holes) 1648 1641 self.ck4.grid(row=4, column=0) 1649 1642 Label(master, text='Remove small holes').grid(row=4,column=1, sticky=W) 1650 1643 # 1651 self.ck5 = Radiobutton(master, value = mesh.REMOVE_SHARP_INDENTS,1652 variable=self. boundary_type)1644 self.ck5 = Checkbutton(master,state=NORMAL, 1645 variable=self.smooth_indents) 1653 1646 self.ck5.grid(row=5, column=0) 1654 1647 Label(master, 1655 text='Remove small holes \n& sharp indents').grid(row=5, 1656 column=1, 1657 sticky=W) 1648 text='Remove sharp indents').grid(row=5, column=1, sticky=W) 1658 1649 # 1659 self.ck6 = Radiobutton(master, value = mesh.REMOVE_PINCH_OFF,1660 variable=self. boundary_type)1650 self.ck6 = Checkbutton(master,state=NORMAL, 1651 variable=self.expand_pinch) 1661 1652 self.ck6.grid(row=6, column=0) 1662 1653 Label(master, 1663 text='Remove small holes & \nsharp indents & pinch off').grid( \ 1664 row=6, 1665 column=1, 1666 sticky=W) 1667 1668 1669 self.alpha = 0 1670 self.alphaValueOk = False 1671 1672 1673 def apply(self): 1674 """ 1675 check entered values 1676 """ 1677 try: 1678 self.alpha = float(self.alpha_str.get()) 1679 self.alphaValueOk = True 1680 1681 except ValueError: 1682 pass 1683 #showerror('Bad Alpha value', 1684 # 'Alpha is negative.') 1685 1654 text='Remove pinch off').grid(row=6, column=1, sticky=W) 1655 1656 1686 1657 1687 1658
Note: See TracChangeset
for help on using the changeset viewer.