@@ -595,6 +595,99 @@ def combine_faces(compshape, sew_tolerance):
595595
596596 return new_shell
597597
598+ def write_shape (self , l_shells , filename , tol ):
599+ """
600+ Method to recreate a TopoDS_Shape associated to a geometric shape
601+ after the modification of points of each Face. It
602+ returns a TopoDS_Shape (Shape).
603+
604+ :param l_shells: the list of shells after initial parsing
605+ :param filename: the output filename
606+ :param tol: tolerance on the surface creation after modification
607+ :return: None
608+
609+ """
610+ self .outfile = filename
611+ # global compound containing multiple shells
612+ global_compound_builder = BRep_Builder ()
613+ global_comp = OCC .TopoDS .TopoDS_Compound ()
614+ global_compound_builder .MakeCompound (global_comp )
615+
616+ if self .check_topo == 0 :
617+ # cycle on shells (multiple objects)
618+ shape_shells_explorer = TopExp_Explorer (self .shape
619+ .Oriented (TopAbs_FORWARD ),
620+ TopAbs_SHELL )
621+ ishell = 0
622+
623+ while shape_shells_explorer .More ():
624+ per_shell = OCC .TopoDS .topods_Shell (shape_shells_explorer
625+ .Current ())
626+ # a local compound containing a shell
627+ compound_builder = BRep_Builder ()
628+ comp = OCC .TopoDS .TopoDS_Compound ()
629+ compound_builder .MakeCompound (comp )
630+
631+ # cycle on faces
632+ faces_explorer = TopExp_Explorer (per_shell
633+ .Oriented (TopAbs_FORWARD ),
634+ TopAbs_FACE )
635+ iface = 0
636+ while faces_explorer .More ():
637+ topoface = OCC .TopoDS .topods .Face (faces_explorer .Current ())
638+ newface = self .write_face (l_shells [ishell ][iface ][0 ],
639+ l_shells [ishell ][iface ][1 ],
640+ topoface , tol )
641+
642+ # add face to compound
643+ compound_builder .Add (comp , newface )
644+ iface += 1
645+ faces_explorer .Next ()
646+
647+ new_shell = self .combine_faces (comp , 0.01 )
648+ itype = OCC .TopoDS .TopoDS_Shape .ShapeType (new_shell )
649+ # add the new shell to the global compound
650+ global_compound_builder .Add (global_comp , new_shell )
651+
652+ print ("Shell {0} of type {1} Processed " .format (ishell , itype ))
653+ print "=============================================="
654+
655+ ishell += 1
656+ shape_shells_explorer .Next ()
657+
658+ else :
659+ # cycle on faces
660+ # a local compound containing a shell
661+ compound_builder = BRep_Builder ()
662+ comp = OCC .TopoDS .TopoDS_Compound ()
663+ compound_builder .MakeCompound (comp )
664+
665+ # cycle on faces
666+ faces_explorer = TopExp_Explorer (
667+ self .shape .Oriented (TopAbs_FORWARD ),
668+ TopAbs_FACE )
669+ iface = 0
670+ while faces_explorer .More ():
671+ topoface = OCC .TopoDS .topods .Face (faces_explorer .Current ())
672+ newface = self .write_face (l_shells [0 ][iface ][0 ],
673+ l_shells [0 ][iface ][1 ],
674+ topoface , tol )
675+
676+ # add face to compound
677+ compound_builder .Add (comp , newface )
678+ iface += 1
679+ faces_explorer .Next ()
680+
681+ new_shell = self .combine_faces (comp , 0.01 )
682+ itype = OCC .TopoDS .TopoDS_Shape .ShapeType (new_shell )
683+ # add the new shell to the global compound
684+ global_compound_builder .Add (global_comp , new_shell )
685+
686+ print ("Shell {0} of type {1} Processed " .format (0 , itype ))
687+ print "=============================================="
688+
689+ self .write_shape_to_file (global_comp , self .outfile )
690+
598691 def write_shape_to_file (self , shape , filename ):
599692 """
600693 Abstract method to write the 'shape' to the `filename`.
0 commit comments