def tangent(self,u,v, recurse=False): dU, dV = gp_Dir(), gp_Dir() curv = self.curvature(u,v) if curv.IsCurvatureDefined(): curv.TangentU(dU), curv.TangentV(dV) return dU, dV else: # most likely the curvature is just out of bounds... # move it a little close to the center of the surface... tol = 1e-2 print 'trying to fix shit...' domain = self.instance.domain() if u in domain: uorv = 'u' elif v in domain: uorv = 'v' else: raise ValueError('no curvature defined while sample does not lie on border...') if uorv is not None: indx = domain.index(u) if uorv == 'u' else domain.index(v) if indx in (1,3): # v v = v + tol if indx == 1 else v - tol else: u = u + tol if indx == 0 else u - tol print 'hopefully fixed it?' if not recurse: self.tangent(u,v, True) else: return None
def DisplayVector(self, vec, pnt, update=False): if self._inited: aPresentation = Prs3d.Prs3d_Presentation(self._struc_mgr) arrow = Prs3d_Arrow() arrow.Draw(aPresentation.GetHandle(), (pnt.as_vec() + vec).as_pnt(), gp_Dir(vec), math.radians(20), vec.Magnitude()) aPresentation.Display() # it would be more coherent if a AIS_InteractiveObject would be returned if update: self.Repaint() return aPresentation
def DisplayVector(self, vec, pnt, update=False): if self._inited: aPresentation = Prs3d.Prs3d_Presentation(self._struc_mgr) arrow = Prs3d_Arrow() arrow.Draw( aPresentation.GetHandle(), (pnt.as_vec() + vec).as_pnt(), gp_Dir(vec), math.radians(20), vec.Magnitude() ) aPresentation.Display() # it would be more coherent if a AIS_InteractiveObject would be returned if update: self.Repaint() return aPresentation