Hi,everyone.
I always get a mesh obj, when I insert a model in obj format.But I want to turn this object to a topoShape, which can be used in Part workbench.How can I do it?
How to turn mesh shape to topoShape?
Forum rules
and Helpful information
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help
Also, be nice to others! Read the FreeCAD code of conduct!
Also, be nice to others! Read the FreeCAD code of conduct!
Re: How to turn mesh shape to topoShape?
Moved to help forum.
There are lots of forum topics explaining how to convert a stl to a solid. Basically, you import the file as a mesh, convert in Part workbench the mesh to a shape and the shape to a solid.
There are lots of forum topics explaining how to convert a stl to a solid. Basically, you import the file as a mesh, convert in Part workbench the mesh to a shape and the shape to a solid.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
Re: How to turn mesh shape to topoShape?
Use Part_ShapeFromMesh.
Last edited by vocx on Thu Jan 16, 2020 7:52 am, edited 1 time in total.
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
Re: How to turn mesh shape to topoShape?
In the process of converting mesh to Part, I encountered new troubles. Some obj model files are very slow in the process of converting to Part. I traced the code and found that the code that affects speed is in the function of setFace. One of them is aSewingTool.Perform ().
As far as I know, the function of this function is to stitch triangle patches.
Code: Select all
void TopoShape::setFaces(const std::vector<Base::Vector3d> &Points,
const std::vector<Facet> &Topo, float Accuracy)
{
gp_XYZ p1, p2, p3;
TopoDS_Vertex Vertex1, Vertex2, Vertex3;
TopoDS_Face newFace;
TopoDS_Wire newWire;
BRepBuilderAPI_Sewing aSewingTool;
Standard_Real x1, y1, z1;
Standard_Real x2, y2, z2;
Standard_Real x3, y3, z3;
aSewingTool.Init(Accuracy,Standard_True);
TopoDS_Compound aComp;
BRep_Builder BuildTool;
BuildTool.MakeCompound(aComp);
unsigned int ctPoints = Points.size();
for (std::vector<Facet>::const_iterator it = Topo.begin(); it != Topo.end(); ++it) {
if (it->I1 >= ctPoints || it->I2 >= ctPoints || it->I3 >= ctPoints)
continue;
x1 = Points[it->I1].x; y1 = Points[it->I1].y; z1 = Points[it->I1].z;
x2 = Points[it->I2].x; y2 = Points[it->I2].y; z2 = Points[it->I2].z;
x3 = Points[it->I3].x; y3 = Points[it->I3].y; z3 = Points[it->I3].z;
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);
newWire = BRepBuilderAPI_MakePolygon(Vertex1, Vertex2, Vertex3, Standard_True);
if (!newWire.IsNull()) {
newFace = BRepBuilderAPI_MakeFace(newWire);
if (!newFace.IsNull())
BuildTool.Add(aComp, newFace);
}
}
}
aSewingTool.Load(aComp);
aSewingTool.Perform();
_Shape = aSewingTool.SewedShape();
if (_Shape.IsNull())
_Shape = aComp;
}
- Attachments
-
- ttt.obj
- (561.27 KiB) Downloaded 10 times