Hi,

I tried to write PythonOCC equivalent of the STLReader code that Thomas
provided. You can find it in this gist: https://gist.github.com/1446374

I use a representation of a cube in the form of vertex-faces data and build
a compound shape in the same way as done in STL reader code. The final
shape gets successfully built. However when I try to perform a boolean fuse
operation with another shape I get

RuntimeError: StdFail_NotDone
BRep_API: command not done

(See the commented lines at the end in above mentioned code)
Any idea how to investigate this further?
Thanks,
--
Jayesh


On Thu, Dec 1, 2011 at 8:47 AM, Jayesh Salvi <jayeshsa...@gmail.com> wrote:

> Thomas,
>
> I had the same idea, so I tried a shortcut method. I converted the mesh
> data of a simple cube into STL and tried to load it using STLReader API (of
> PythonOCC). I got NotDone failure, if I recall correctly. I will try to
> port the code snippet to python and see if that helps.
> --
> Jayesh
>
>
> On Wed, Nov 30, 2011 at 3:10 PM, Thomas Paviot <tpav...@gmail.com> wrote:
>
>> 2011/11/30 Thomas Paviot <tpav...@gmail.com>
>>
>>> 2011/11/30 Jayesh Salvi <jayeshsa...@gmail.com>
>>>
>>>> Thomas,
>>>>
>>>> Is there a way to do this other way around? i.e. if I have mesh
>>>> information how do I convert it to Solid.
>>>>
>>>
>>> I think we should have a look at the STL Importer implemented in OCC.
>>> They actually convert mesh information into solids.
>>>
>>>
>>>> I think that's what Chris was asking too. I've tried to do it 
>>>> (here<https://gist.github.com/1351019>),
>>>> but the solids I create do not behave correctly in subsequent boolean
>>>> operations on them.
>>>>
>>>> Any hint will be appreciated. Thanks.
>>>> --
>>>> Jayesh
>>>>
>>>>
>>> Thomas
>>>
>>>
>> Attached below a snippet of the OCC code from STL_Reader.cxx. The
>> algorithm for mesh to TopoDS_Shape conversion can be ported to python.
>>
>> Thomas
>>
>>  ===
>> void StlAPI_Reader::Read(TopoDS_Shape& aShape, const Standard_CString
>> aFileName)
>> {
>>   OSD_Path aFile(aFileName);
>>
>>   Handle(StlMesh_Mesh) aSTLMesh = RWStl::ReadFile(aFile);
>>   Standard_Integer NumberDomains = aSTLMesh->NbDomains();
>>   Standard_Integer iND;
>>   gp_XYZ p1, p2, p3;
>>   TopoDS_Vertex Vertex1, Vertex2, Vertex3;
>>   TopoDS_Face AktFace;
>>   TopoDS_Wire AktWire;
>>   BRepBuilderAPI_Sewing aSewingTool;
>>   Standard_Real x1, y1, z1;
>>   Standard_Real x2, y2, z2;
>>   Standard_Real x3, y3, z3;
>>
>>   aSewingTool.Init(1.0e-06,Standard_True);
>>
>>   TopoDS_Compound aComp;
>>   BRep_Builder BuildTool;
>>   BuildTool.MakeCompound( aComp );
>>
>>   StlMesh_MeshExplorer aMExp (aSTLMesh);
>>
>>   for (iND=1;iND<=NumberDomains;iND++)
>>   {
>>     for (aMExp.InitTriangle (iND); aMExp.MoreTriangle ();
>> aMExp.NextTriangle ())
>>     {
>>       aMExp.TriangleVertices (x1,y1,z1,x2,y2,z2,x3,y3,z3);
>>       p1.SetCoord(x1,y1,z1);
>>       p2.SetCoord(x2,y2,z2);
>>       p3.SetCoord(x3,y3,z3);
>>
>>       if ((!(p1.IsEqual(p2,0.0))) && (!(p1.IsEqual(p3,0.0))))
>>       {
>>         Vertex1 = BRepBuilderAPI_MakeVertex(p1);
>>         Vertex2 = BRepBuilderAPI_MakeVertex(p2);
>>         Vertex3 = BRepBuilderAPI_MakeVertex(p3);
>>
>>         AktWire = BRepBuilderAPI_MakePolygon( Vertex1, Vertex2, Vertex3,
>> Standard_True);
>>
>>         if( !AktWire.IsNull())
>>         {
>>           AktFace = BRepBuilderAPI_MakeFace( AktWire);
>>           if(!AktFace.IsNull())
>>             BuildTool.Add( aComp, AktFace );
>>         }
>>       }
>>     }
>>   }
>>   aSTLMesh->Clear();
>>
>>   aSewingTool.Load( aComp );
>>   aSewingTool.Perform();
>>   aShape = aSewingTool.SewedShape();
>>   if ( aShape.IsNull() )
>>     aShape = aComp;
>> }
>>
>>
>> _______________________________________________
>> Pythonocc-users mailing list
>> Pythonocc-users@gna.org
>> https://mail.gna.org/listinfo/pythonocc-users
>>
>>
>
_______________________________________________
Pythonocc-users mailing list
Pythonocc-users@gna.org
https://mail.gna.org/listinfo/pythonocc-users

Reply via email to