Changeset 1041 in main


Ignore:
Timestamp:
04/25/12 16:09:08 (7 years ago)
Author:
agalech
Message:

Add migration for document3D.classes.Product , now Product has attribute id

Location:
trunk/openPLM/document3D
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/openPLM/document3D/STP_converter_WebGL.py

    r1031 r1041  
    154154            raise MultiRoot_Error 
    155155 
    156         deep=0             
    157         self.product_relationship_arbre=Product(GetLabelNom(roots.Value(1)),deep,roots.Value(1),self.id,self.file)  
     156        deep=0 
     157        product_id=[1]             
     158        self.product_relationship_arbre=Product(GetLabelNom(roots.Value(1)),deep,roots.Value(1),self.id,product_id[0],self.file) 
     159        product_id[0]+=1  
    158160        parcour_product_relationship_arbre(self.shape_tool,self.product_relationship_arbre,self.shapes_simples, 
    159         (deep+1),self.id,self.product_relationship_arbre) 
     161        (deep+1),self.id,self.product_relationship_arbre,product_id) 
    160162        
    161163        return self.product_relationship_arbre 
     
    205207     
    206208     
    207 def parcour_product_relationship_arbre(shape_tool,product,shapes_simples,deep,doc_id,product_root): 
     209def parcour_product_relationship_arbre(shape_tool,product,shapes_simples,deep,doc_id,product_root,product_id): 
    208210    """ 
    209211     
     
    266268                if not reference_found: 
    267269 
    268                     product_assembly=search_assembly(GetLabelNom(label_reference),label_reference,doc_id,product_root,shape_tool.IsSimpleShape(label_reference)) 
    269                               
    270                     if product_assembly:   
     270                    new_product=Product(GetLabelNom(label_reference),deep,label_reference,doc_id,product_id[0]) 
     271                    product_assembly=search_assembly(new_product,product_root)          
     272                    if product_assembly: 
    271273                        product.links.append(Link(product_assembly)) 
    272274          
    273275                    else:       
    274                         product.links.append(Link(Product(GetLabelNom(label_reference),deep,label_reference,doc_id)))                                
    275                         parcour_product_relationship_arbre(shape_tool,product.links[-1].product,shapes_simples,deep+1,doc_id,product_root) 
     276                        product.links.append(Link(new_product))   
     277                        product_id[0]+=1                              
     278                        parcour_product_relationship_arbre(shape_tool,new_product,shapes_simples,deep+1,doc_id,product_root,product_id) 
    276279                         
    277280                         
  • trunk/openPLM/document3D/classes.py

    r1034 r1041  
    4343    .. attribute:: label_reference 
    4444     
    45         When we generate an arborescense using pythonOCC, here we will store the label that represents the :class:`.Product` ,if we generate the arborescense reading a file **.geo**, this attribute will be **False** 
     45        When we generate an arborescense using :class:`.NEW_STEP_Import` , here we will store the label that represents the :class:`.Product` ,if we generate the arborescense reading a file **.geo**, this attribute will be **False** 
    4646         
    4747    .. attribute:: name 
     
    7272     
    7373        Used in the decomposition , indicates if a :class:`.Product`  has been visited in the tour of the arborescense 
     74         
     75    .. attribute:: id 
     76     
     77        identified the :class:`.Product` 
    7478               
    7579    """ 
    76     __slots__ = ("label_reference","name","doc_id","links","geometry","deep","doc_path","visited","part_to_decompose") 
    77      
    78      
    79     def __init__(self,name,deep,label_reference,doc_id,doc_path=None,geometry=False): 
     80    __slots__ = ("label_reference","name","doc_id","links","geometry","deep","doc_path","visited","part_to_decompose","id") 
     81     
     82     
     83    def __init__(self,name,deep,label_reference,doc_id,id,doc_path=None,geometry=False): 
    8084        #no tiene location 
    8185        self.links = []           
     
    8993        self.geometry=geometry  
    9094        self.deep=deep 
     95        self.id=id 
    9196        self.visited=False 
    9297    def set_geometry(self,geometry): 
     
    238243     
    239244    
     245    The :class:`.Product` generated from a file **.geo ** (The case of this function) have his attribute **label_reference** False 
     246     
     247    When we generate an :class:`.Product` using :class:`.NEW_STEP_Import` , the attribute **label_reference** will represents and identify the :class:`.Product` ,  
     248     
    240249     
    241250    From the information contained in a file **.arb** (**arbre**), it generates the corresponding :class:`Product` 
     
    265274     
    266275    """ 
    267     label_reference=False 
    268276                  
    269277    if not product_root:  
     
    274282    elif to_update_product_root: #Important, in case of generation of a tree contained in several files, it supports updated product_root 
    275283        product=generateProduct(arbre,deep) 
    276         product_assembly=search_assembly(product.name,label_reference,product.doc_id,product_root,product.geometry,product) 
     284 
     285        product_assembly=search_assembly(product,product_root) 
    277286        if product_assembly:  
    278287            to_update_product_root.links.append(Link(product_assembly)) 
     
    285294         
    286295        product_child=generateProduct(arbre[i+1][1],deep+1) 
    287         product_assembly=search_assembly(product_child.name,label_reference,product_child.doc_id,product_root,product_child.geometry,product) 
    288  
    289             
     296         
     297    
     298        product_assembly=search_assembly(product_child,product_root) 
     299           
    290300        if product_assembly: 
    291301            product_child=product_assembly  
     
    322332    """ 
    323333    label_reference=False 
    324     return Product(arbre[0][0],deep,label_reference,arbre[0][1],arbre[0][3],arbre[0][2])    
    325  
    326  
    327  
    328  
    329 def search_assembly(name,label,doc_id,product_root,geometry,product_father=False):  
    330     """ 
    331      
    332     :param product_root: :class:`Product` that represents a root arborescense   
    333     :type plmobject: :class:`.Product` 
    334     :param geometry: indicates if the :class:`Product` for that we look is a Assembly (**product.geometry** is False )or a simple :class:`Product` (**product.geometry** >=1) 
    335     :param name: name of :class:`Product` for that we look 
    336     :param doc_id: id of :class:`.DocumentFile` that contains the :class:`Product` for that we look 
    337     :param label: :class:`.OCC.TDF.TDF_Label` generated by pythonOCC that represent the :class:`Product` for that we look 
     334    return Product(arbre[0][0],deep,label_reference,arbre[0][1],arbre[0][4],arbre[0][3],arbre[0][2])    
     335 
     336 
     337 
     338 
     339def search_assembly(product,product_root):  
     340    """ 
     341     
     342    :param product_root: :class:`Product` root of the arborescense    
     343    :param product: :class:`Product` for that we look in the **product_root** 
     344 
    338345          
    339     Function that it checks if a :class:`Product` (determined by **name** , **id** and **geometry** or by **name** and **label**)is already present in a arborescense :class:`Product` (**product_root**) 
    340     There are two manners of comparison, across **name** and **label_reference**, generated for pythonOCC for every product, or across **name**, **doc_id** and **geometry** ,extracted of a file **.geo** 
    341      
    342     Important: puede haber dos ficheros con el mismo nombre en la misma assamblaje 
    343     """ 
    344    
    345     if product_root and not product_father==product_root:  
     346    Function that it checks if a :class:`Product` is already present in a arborescense :class:`Product` (**product_root**) 
     347    There are two manners of comparison, across **label_reference** ( generated for :class:`.NEW_STEP_Import` for every :class:`Product`), or across **id** and **doc_id** (extracted of a file **.geo** for every :class:`Product`) 
     348     
     349 
     350    """ 
     351 
     352    if product_root:  
    346353        for link in product_root.links: 
    347354         
    348          
    349             if (name and link.product.name==name and   
    350             ((geometry and link.product.geometry) or (not geometry and not link.product.geometry))):# 2 assemblys or 2 geometrys wtih same name        
    351                                  
    352                 if label: 
    353                      
    354                     if link.product.label_reference==label: 
    355                         return link.product 
    356                      
    357                      
    358                 elif doc_id==link.product.doc_id and geometry==link.product.geometry: 
    359                     return link.product                                         
    360                      
    361          
    362                 #raise "2 diferent assembly or geometrys with same name" #is not recomndable to had 2 product or 2 assembly whit same name 
    363  
    364                      
    365  
    366       
    367             product=search_assembly(name,label,doc_id,link.product,geometry,product_father) 
    368             if product: 
    369                 return product 
     355 
     356            if product.label_reference: 
     357 
     358                 
     359                if link.product.label_reference==product.label_reference: 
     360 
     361                    return link.product 
     362                 
     363                  
     364            elif product.id==link.product.id and product.doc_id==link.product.doc_id: 
     365                return link.product                                         
     366 
     367 
     368            product_found=search_assembly(product,link.product) 
     369            if product_found: 
     370                return product_found 
    370371 
    371372     
     
    381382    """ 
    382383    output=[] 
    383  
    384     output.append([product.name,product.doc_id,product.geometry,product.doc_path])   
     384     
     385    output.append([product.name,product.doc_id,product.geometry,product.doc_path,product.id])   
    385386     
    386387    for link in product.links: 
  • trunk/openPLM/document3D/models.py

    r1031 r1041  
    779779 
    780780    product =Product_from_Arb(json.loads(new_ArbreFile.file.read())) 
     781   
     782     
    781783    if recursif and product: 
    782784        child_ArbreFile_to_Product(doc_file,product,product_root=product,deep=1)         
Note: See TracChangeset for help on using the changeset viewer.