def _get_sorted_hlr_edges(self, topods_shape, ax=gp_Ax2(), export_hidden_edges=True, use_smooth_edges=False, use_sewn_edges=False): """ Return hidden and visible edges as two lists of edges """ hlr = HLRBRep_Algo() hlr.Add(topods_shape) projector = HLRAlgo_Projector(ax) hlr.Projector(projector) hlr.Update() hlr.Hide() hlr_shapes = HLRBRep_HLRToShape(hlr) # visible edges visible = [] visible_sharp_edges_as_compound = hlr_shapes.VCompound() if visible_sharp_edges_as_compound: visible += list(TopologyExplorer(visible_sharp_edges_as_compound).edges()) visible_smooth_edges_as_compound = hlr_shapes.Rg1LineVCompound() if visible_smooth_edges_as_compound and use_smooth_edges: visible += list(TopologyExplorer(visible_smooth_edges_as_compound).edges()) visible_sewn_edges_as_compound = hlr_shapes.RgNLineVCompound() if visible_sewn_edges_as_compound and use_sewn_edges: visible += list(TopologyExplorer(visible_sewn_edges_as_compound).edges()) visible_contour_edges_as_compound = hlr_shapes.OutLineVCompound() if visible_contour_edges_as_compound: visible += list(TopologyExplorer(visible_contour_edges_as_compound).edges()) #visible_isoparameter_edges_as_compound = hlr_shapes.IsoLineVCompound() #if visible_isoparameter_edges_as_compound: # visible += list(TopologyExplorer(visible_isoparameter_edges_as_compound).edges()) # hidden edges hidden = [] if export_hidden_edges: hidden_sharp_edges_as_compound = hlr_shapes.HCompound() if hidden_sharp_edges_as_compound: hidden += list(TopologyExplorer(hidden_sharp_edges_as_compound).edges()) hidden_smooth_edges_as_compound = hlr_shapes.Rg1LineHCompound() if hidden_smooth_edges_as_compound and use_smooth_edges: hidden += list(TopologyExplorer(hidden_smooth_edges_as_compound).edges()) hidden_sewn_edges_as_compound = hlr_shapes.RgNLineHCompound() if hidden_sewn_edges_as_compound and use_sewn_edges: hidden += list(TopologyExplorer(hidden_sewn_edges_as_compound).edges()) hidden_contour_edges_as_compound = hlr_shapes.OutLineHCompound() if hidden_contour_edges_as_compound: hidden += list(TopologyExplorer(hidden_contour_edges_as_compound).edges()) return visible, hidden
def hlr_project(self, shapes): hlralgo = HLRBRep_Algo() if len(shapes) > 0: for s in shapes: hlralgo.Add(s) self.children = [] trsf = gp_Trsf() p = HLRAlgo_Projector(gp_Ax2(gp_Pnt(), gp_Dir(0, 0, 1))) hlralgo.Projector(p) hlralgo.Update() hlralgo.Hide() hlrtoshape = HLRBRep_HLRToShape(hlralgo) vcompound = hlrtoshape.VCompound() voutline = hlrtoshape.OutLineVCompound() rg1linevcompound = hlrtoshape.Rg1LineVCompound() rgnlinevcompound = hlrtoshape.RgNLineVCompound() isolinevcompound = hlrtoshape.IsoLineVCompound() hcompound = hlrtoshape.HCompound() houtline = hlrtoshape.OutLineHCompound() rg1linehcompound = hlrtoshape.Rg1LineHCompound() rgnlinehcompound = hlrtoshape.RgNLineHCompound() isolinehcompound = hlrtoshape.IsoLineHCompound() debug("vcompound: %s" % (str(vcompound), )) debug("voutline: %s" % (str(voutline), )) debug("rg1linevcompound: %s" % (str(rg1linevcompound), )) debug("rgnlinevcompound: %s" % (str(rgnlinevcompound), )) debug("isolinevcompound: %s" % (str(isolinevcompound), )) debug("hcompound: %s" % (str(hcompound), )) debug("houtline: %s" % (str(houtline), )) debug("rg1linehcompound: %s" % (str(rg1linehcompound), )) debug("rgnlinehcompound: %s" % (str(rgnlinehcompound), )) debug("isolinehcompound: %s" % (str(isolinehcompound), )) name = get_inc_name("projection") if (vcompound != None): sclp = SCLPart3(self) scls = SCLShape(vcompound) scls.set_linestyle("main_projection") sclp.set_shape(scls) sclp.set_name(name + 'vcompound') self.add_child_context(sclp) if (voutline != None): sclp = SCLPart3(self) scls = SCLShape(voutline) scls.set_linestyle("main_projection") sclp.set_shape(scls) sclp.set_name(name + 'voutline') self.add_child_context(sclp) if (rg1linevcompound != None): sclp = SCLPart3(self) scls = SCLShape(rg1linevcompound) scls.set_linestyle("main_projection") sclp.set_shape(scls) sclp.set_name(name + 'rg1linevcompound') self.add_child_context(sclp) if (rgnlinevcompound != None): sclp = SCLPart3(self) scls = SCLShape(rgnlinevcompound) scls.set_linestyle("main_projection") sclp.set_shape(scls) sclp.set_name(name + 'rgnlinecompound') self.add_child_context(sclp) if (isolinevcompound != None): sclp = SCLPart3(self) scls = SCLShape(isolinevcompound) scls.set_linestyle("main_projection") sclp.set_shape(scls) sclp.set_name(name + 'isolinevcompound') self.add_child_context(sclp) if (hcompound != None): sclp = SCLPart3(self) scls = SCLShape(hcompound) scls.set_linestyle("hidden") scls.set_hidden(True) sclp.set_shape(scls) sclp.set_name(name + 'hcompound') self.add_child_context(sclp) if (houtline != None): sclp = SCLPart3(self) scls = SCLShape(houtline) scls.set_linestyle("hidden") scls.set_hidden(True) sclp.set_shape(scls) sclp.set_name(name + 'houtline') self.add_child_context(sclp) if (rg1linehcompound != None): sclp = SCLPart3(self) scls = SCLShape(rg1linehcompound) scls.set_linestyle("hidden") scls.set_hidden(True) sclp.set_shape(scls) sclp.set_name(name + 'rg1linehcompound') self.add_child_context(sclp) if (rgnlinehcompound != None): sclp = SCLPart3(self) scls = SCLShape(rgnlinehcompound) scls.set_linestyle("hidden") scls.set_hidden(True) sclp.set_shape(scls) sclp.set_name(name + 'rgnlinehcompound') self.add_child_context(sclp) if (isolinehcompound != None): sclp = SCLPart3(self) scls = SCLShape(isolinehcompound) scls.set_linestyle("hidden") scls.set_hidden(True) sclp.set_shape(scls) sclp.set_name(name + 'isolinehcompound') self.add_child_context(sclp)