def reset_tolerance_label(self): """ Reset the tolerance label to 0 bonds or 0 overlapping atoms """ if self.fuse_mode == MAKEBONDS: tol_str = fusechunks_lambda_tol_nbonds(self.tol, 0, 0, 0) # 0 bonds else: # 0 overlapping atoms tol_str = fusechunks_lambda_tol_natoms(self.tol, 0) tolerenceLabel = tol_str self.propMgr.toleranceSlider.labelWidget.setText(tolerenceLabel)
def find_overlapping_atoms(self, skip_hidden=True, ignore_chunk_picked_state=False): """ Checks atoms of the selected chunk to see if they overlap atoms in other chunks of the same type (element). Hidden chunks are skipped. """ # Future versions should allow more flexible rules for overlapping # atoms, but this needs to be discussed with others before implementing # anything. # For now, only atoms of the same type qualify as overlapping atoms. # As is, it is extremely useful for fusing chunks of diamond, # lonsdaleite or SiC, # which is done quite a lot with casings. This will save me hours of # modeling work. # Mark 050902 self.overlapping_atoms = [] for chunk in self.o.assy.selmols: if chunk.hidden or chunk.display == diINVISIBLE: # Skip selected chunk if hidden or invisible. # Fixes bug 970. mark 060404 continue # Loop through all the mols in the part to search for bondable # pairs of singlets. for mol in self.o.assy.molecules: if chunk is mol: continue # Skip itself if mol.hidden or mol.display == diINVISIBLE: continue # Skip hidden or invisible chunks if mol in self.o.assy.selmols: continue # Skip other selected chunks # Skip this mol if its bounding box does not overlap the # selected chunk's bbox. # Remember: chunk = a selected chunk, mol = a non-selected # chunk. if not chunk.overlapping_chunk(mol, self.tol): # print "Skipping ", mol.name continue else: # Loop through all the atoms in the selected chunk. # Use values() if the loop ever modifies chunk or mol-- for a1 in chunk.atoms.itervalues(): # Singlets can't be overlapping atoms -- if a1.element is Singlet: continue # We can skip mol if the atom lies outside its bbox. if not mol.overlapping_atom(a1, self.tol): continue # Loop through all the atoms in this chunk. for a2 in mol.atoms.itervalues(): # Only atoms of the same type can be overlapping. # This also screens singlets, since a1 can't be a # singlet. if a1.element is not a2.element: continue # Compares the distance between a1 and a2. # If the distance # is <= tol, then we have an overlapping atom. # I know this isn't a proper use of tol, # but it works for now. Mark 050901 if vlen(a1.posn() - a2.posn()) <= self.tol: # Add this pair to the list-- self.overlapping_atoms.append((a1, a2)) # No need to check other atoms in this chunk-- break # Update tolerance label and status bar msgs. natoms = len(self.overlapping_atoms) tol_str = fusechunks_lambda_tol_natoms(self.tol, natoms) tolerenceLabel = tol_str self.propMgr.toleranceSlider.labelWidget.setText(tolerenceLabel)
def find_overlapping_atoms(self, skip_hidden = True, ignore_chunk_picked_state = False): """ Checks atoms of the selected chunk to see if they overlap atoms in other chunks of the same type (element). Hidden chunks are skipped. """ # Future versions should allow more flexible rules for overlapping # atoms, but this needs to be discussed with others before implementing # anything. # For now, only atoms of the same type qualify as overlapping atoms. # As is, it is extremely useful for fusing chunks of diamond, # lonsdaleite or SiC, # which is done quite a lot with casings. This will save me hours of # modeling work. # Mark 050902 self.overlapping_atoms = [] for chunk in self.o.assy.selmols: if chunk.hidden or chunk.display == diINVISIBLE: # Skip selected chunk if hidden or invisible. # Fixes bug 970. mark 060404 continue # Loop through all the mols in the part to search for bondable # pairs of singlets. for mol in self.o.assy.molecules: if chunk is mol: continue # Skip itself if mol.hidden or mol.display == diINVISIBLE: continue # Skip hidden or invisible chunks if mol in self.o.assy.selmols: continue # Skip other selected chunks # Skip this mol if its bounding box does not overlap the # selected chunk's bbox. # Remember: chunk = a selected chunk, mol = a non-selected # chunk. if not chunk.overlapping_chunk(mol, self.tol): # print "Skipping ", mol.name continue else: # Loop through all the atoms in the selected chunk. # Use values() if the loop ever modifies chunk or mol-- for a1 in chunk.atoms.itervalues(): # Singlets can't be overlapping atoms -- if a1.element is Singlet: continue # We can skip mol if the atom lies outside its bbox. if not mol.overlapping_atom(a1, self.tol): continue # Loop through all the atoms in this chunk. for a2 in mol.atoms.itervalues(): # Only atoms of the same type can be overlapping. # This also screens singlets, since a1 can't be a # singlet. if a1.element is not a2.element: continue # Compares the distance between a1 and a2. # If the distance # is <= tol, then we have an overlapping atom. # I know this isn't a proper use of tol, # but it works for now. Mark 050901 if vlen (a1.posn() - a2.posn()) <= self.tol: # Add this pair to the list-- self.overlapping_atoms.append( (a1,a2) ) # No need to check other atoms in this chunk-- break # Update tolerance label and status bar msgs. natoms = len(self.overlapping_atoms) tol_str = fusechunks_lambda_tol_natoms(self.tol, natoms) tolerenceLabel = tol_str self.propMgr.toleranceSlider.labelWidget.setText(tolerenceLabel)