Tessellate of sphere loops for ever.[Resolved]

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
keithsloan52
Veteran
Posts: 2764
Joined: Mon Feb 27, 2012 5:31 pm

Tessellate of sphere loops for ever.[Resolved]

Post by keithsloan52 »

I have some code which tessellates the shape of a selected obey. If I try it on a Part::Sphere it just loops for ever.
Is this a bug?

OS: macOS 10.15
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.16146 (Git)
Build type: Release
Branch: (HEAD detached at 0.18.4)
Hash: 980bf9060e28555fecd9e3462f68ca74007b70f8
Python version: 3.6.7
Qt version: 5.6.2
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/UnitedKingdom (en_GB)
Last edited by keithsloan52 on Thu Jun 04, 2020 1:06 pm, edited 1 time in total.
openBrain
Veteran
Posts: 9041
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: Tessellate of sphere loops for ever.

Post by openBrain »

Code ?
keithsloan52
Veteran
Posts: 2764
Joined: Mon Feb 27, 2012 5:31 pm

Re: Tessellate of sphere loops for ever.

Post by keithsloan52 »

openBrain wrote: Sun May 31, 2020 9:05 pmCode ?

Code: Select all

class TessellatePlanarFeature :

    def Activated(self) :
        from .GDMLObjects import GDMLTessellated, GDMLTriangular, \
                  ViewProvider, ViewProviderExtension

        for obj in FreeCADGui.Selection.getSelection():
            #if len(obj.InList) == 0: # allowed only for for top level objects
            print('Action Tessellate')
            if hasattr(obj,'Shape') :
               print(obj.Shape.ShapeType)
               if hasattr(obj.Shape,'Vertexes') :
                  numVert = len(obj.Shape.Vertexes)
                  print('Number of Vertex : '+str(numVert))
                  if numVert > 2 :
                     if hasattr(obj,'InList') :
                        parent = obj.InList[0]
                        #print(dir(parent))
                        myTess=parent.newObject("Part::FeaturePython", \
                                         "GDMLTessellate_Tessellate")
                        tess = GDMLTessellated(myTess,0)
                        print(dir(tess))
                        if FreeCAD.GuiUp :
                           ViewProviderExtension(myTess.ViewObject)
                           ViewProvider(myTess.ViewObject)
                        print('About to Tessellate')
                        list = obj.Shape.tessellate(1)
                        print(len(list))
                        print(list)                        
Works when one selects most Objects, but not for Part Sphere,
prints About to Tessellate loops and never prints list
keithsloan52
Veteran
Posts: 2764
Joined: Mon Feb 27, 2012 5:31 pm

Re: Tessellate of sphere loops for ever.

Post by keithsloan52 »

openBrain wrote: Sun May 31, 2020 9:05 pmCode ?
Actual code posted has check for number of vertex. I had the problem with sphere before I introduced the check.
I added the check to avoid the user doing something that looped.
keithsloan52
Veteran
Posts: 2764
Joined: Mon Feb 27, 2012 5:31 pm

Re: Tessellate of sphere loops for ever.

Post by keithsloan52 »

Interesting that if I try the Mesh workbench and Tessellate a Sphere choosing the standard option. It tessellates the sphere okay and
very quickly. Do I assume that the workbench which seems to be written in C++ uses different code to Tessellate a TopShape?

Would have thought at library level C++ or Python the function would be the same.

I assume that TopShape.Tessellate is using OCC function?
keithsloan52
Veteran
Posts: 2764
Joined: Mon Feb 27, 2012 5:31 pm

Re: Tessellate of sphere loops for ever[Resolved]

Post by keithsloan52 »

Have switched to using Mesh facilities rather than Tessellate of Shape ( TopShape )
Post Reply