returns IncrementalMesh from BRepMesh;
---C++: alias "Standard_EXPORT virtual ~BRepMesh_IncrementalMesh();"
- Create (S : Shape from TopoDS;
- D : Real from Standard;
- Relatif : Boolean from Standard = Standard_False;
- Ang : Real from Standard = 0.5)
+ Create (S : Shape from TopoDS;
+ D : Real from Standard;
+ Relatif : Boolean from Standard = Standard_False;
+ Ang : Real from Standard = 0.5;
+ InParallel : Boolean from Standard = Standard_False)
returns IncrementalMesh from BRepMesh;
---Purpose: If the boolean <Relatif> is True, the
-- deflection used for the polygonalisation of
BRepMesh_IncrementalMesh::BRepMesh_IncrementalMesh (const TopoDS_Shape& theShape,
const Standard_Real theDeflection,
const Standard_Boolean theRelative,
- const Standard_Real theAngle)
+ const Standard_Real theAngle,
+ const Standard_Boolean theInParallel)
: myRelative (theRelative),
- myInParallel (Standard_False),
+ myInParallel (theInParallel),
myModified (Standard_False),
myStatus (0)
{
static Standard_Integer incrementalmesh(Draw_Interpretor& di, Standard_Integer nbarg, const char** argv)
{
- if (nbarg < 3) return 1;
+ if (nbarg < 3) {
+ di << " use incmesh shape deflection [inParallel (0/1) : 0 by default]\n";
+ return 0;
+ }
- Standard_Real d = atof(argv[2]);
- TopoDS_Shape S = DBRep::Get(argv[1]);
- if (S.IsNull()) return 1;
+ TopoDS_Shape aShape = DBRep::Get(argv[1]);
+ if (aShape.IsNull()) {
+ di << " null shapes is not allowed here\n";
+ return 0;
+ }
+ Standard_Real aDeflection = atof(argv[2]);
+
+ Standard_Boolean isInParallel = Standard_False;
+ if (nbarg == 4) {
+ isInParallel = atoi(argv[3]) == 1;
+ }
+ di << "Incremental Mesh, multi-threading "
+ << (isInParallel ? "ON\n" : "OFF\n");
+
+ Standard::SetReentrant(isInParallel);
- BRepMesh_IncrementalMesh MESH(S,d);
+ BRepMesh_IncrementalMesh MESH(aShape, aDeflection, Standard_False, 0.5, isInParallel);
Standard_Integer statusFlags = MESH.GetStatusFlags();
di << "Meshing statuses: ";
theCommands.Add("shpsec","shpsec result shape shape",__FILE__, shapesection, g);
theCommands.Add("plnsec","plnsec result shape plane",__FILE__, planesection, g);
- theCommands.Add("incmesh","incmesh shape deflection",__FILE__, incrementalmesh, g);
+ theCommands.Add("incmesh","incmesh shape deflection [inParallel (0/1) : 0 by default]",__FILE__, incrementalmesh, g);
theCommands.Add("MemLeakTest","MemLeakTest",__FILE__, MemLeakTest, g);
theCommands.Add("fastdiscret","fastdiscret shape deflection [shared [nbiter]]",__FILE__, fastdiscret, g);
theCommands.Add("mesh","mesh result Shape deflection [save partage]",__FILE__, triangule, g);
Standard_Real theDeflection = 0.006;
Handle(StlMesh_Mesh) theStlMesh = new StlMesh_Mesh;
- StlTransfer::BuildIncrementalMesh(aShape, theDeflection, theStlMesh);
+ StlTransfer::BuildIncrementalMesh(aShape, theDeflection, Standard_False, theStlMesh);
Standard_Integer NBTRIANGLES = theStlMesh->NbTriangles();
di<<"Info: Number of triangles = "<<NBTRIANGLES<<"\n";
-- file is an ASCII file. If the mode returns False, the
-- generated file is a binary file.
- Write(me : in out; aShape : Shape from TopoDS; aFileName : CString from Standard);
+ Write(me : in out;
+ aShape : Shape from TopoDS;
+ aFileName : CString from Standard;
+ InParallel : Boolean from Standard = Standard_False);
---Purpose: Converts a given shape to STL format and writes it to file with a given filename.
fields
return theASCIIMode;
}
-void StlAPI_Writer::Write(const TopoDS_Shape& aShape,const Standard_CString aFileName)
+void StlAPI_Writer::Write(const TopoDS_Shape& theShape, const Standard_CString theFileName, const Standard_Boolean theInParallel)
{
- OSD_Path aFile(aFileName);
+ OSD_Path aFile(theFileName);
if (theRelativeMode) {
Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
Bnd_Box Total;
- BRepBndLib::Add(aShape, Total);
+ BRepBndLib::Add(theShape, Total);
Total.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
theDeflection = MAX3(aXmax-aXmin , aYmax-aYmin , aZmax-aZmin)*theCoefficient;
}
- StlTransfer::BuildIncrementalMesh(aShape, theDeflection, theStlMesh);
+ StlTransfer::BuildIncrementalMesh(theShape, theDeflection, theInParallel, theStlMesh);
// Write the built mesh
if (theASCIIMode) {
RWStl::WriteAscii(theStlMesh, aFile);
is
BuildIncrementalMesh (Shape : in Shape from TopoDS;
- Deflection : in Real from Standard;
+ Deflection : in Real from Standard;
+ InParallel : in Boolean from Standard;
Mesh : Mesh from StlMesh)
raises ConstructionError;
end StlTransfer;
#include <CSLib.hxx>
#include <gp_Dir.hxx>
#include <gp_XYZ.hxx>
-#include <BRepMesh.hxx>
+#include <BRepMesh_IncrementalMesh.hxx>
#include <TopAbs.hxx>
#include <Precision.hxx>
#include <TopExp_Explorer.hxx>
}
void StlTransfer::BuildIncrementalMesh (const TopoDS_Shape& Shape,
- const Standard_Real Deflection,
- const Handle(StlMesh_Mesh)& Mesh)
+ const Standard_Real Deflection,
+ const Standard_Boolean InParallel,
+ const Handle(StlMesh_Mesh)& Mesh)
{
if (Deflection <= Precision::Confusion ()) {
Standard_ConstructionError::Raise ("StlTransfer::BuildIncrementalMesh");
}
Standard_Integer NbVertices, NbTriangles;
- BRepMesh::Mesh (Shape, Deflection);
+ BRepMesh_IncrementalMesh aMesher(Shape, Deflection, Standard_False, 0.5, InParallel);
for (TopExp_Explorer itf(Shape,TopAbs_FACE); itf.More(); itf.Next()) {
TopoDS_Face face = TopoDS::Face(itf.Current());
TopLoc_Location Loc, loc;
static Standard_Integer writestl
(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{
- if (argc<3 || argc>4) di << "Use: " << argv[0] << "shape file [ascii/binary (0/1) : 1 by default]" << "\n";
- else {
- TopoDS_Shape shape = DBRep::Get(argv[1]);
+ if (argc < 3 || argc > 5) {
+ di << "Use: " << argv[0]
+ << " shape file [ascii/binary (0/1) : 1 by default] [InParallel (0/1) : 0 by default]" << "\n";
+ } else {
+ TopoDS_Shape aShape = DBRep::Get(argv[1]);
Standard_Boolean anASCIIMode = Standard_False;
+ Standard_Boolean isInParallel = Standard_False;
if (argc==4) {
Standard_Integer mode = atoi(argv[3]);
if (mode==0) anASCIIMode = Standard_True;
}
- StlAPI::Write(shape, argv[2],anASCIIMode);
+ if (argc==5) {
+ isInParallel = atoi(argv[4]) == 1;
+ Standard::SetReentrant(isInParallel);
+ }
+ StlAPI_Writer aWriter;
+ aWriter.ASCIIMode() = anASCIIMode;
+ aWriter.Write (aShape, argv[2], isInParallel);
}
return 0;
}
//XSDRAW::LoadDraw(theCommands);
theCommands.Add ("writevrml", "shape file",__FILE__,writevrml,g);
- theCommands.Add ("writestl", "shape file [ascii/binary (0/1) : 1 by default]",__FILE__,writestl,g);
+ theCommands.Add ("writestl", "shape file [ascii/binary (0/1) : 1 by default] [InParallel (0/1) : 0 by default]",__FILE__,writestl,g);
theCommands.Add ("readstl", "shape file",__FILE__,readstl,g);
theCommands.Add ("loadvrml" , "shape file",__FILE__,loadvrml,g);
theCommands.Add ("storevrml" , "shape file defl [type]",__FILE__,storevrml,g);