mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-21 10:13:43 +03:00
0022867: Avoid performing mesh of a singled face model in parallel mode when flag IsParallel is set to true.
This commit is contained in:
parent
cf9a910a8a
commit
416d4426c4
@ -47,7 +47,8 @@ is
|
|||||||
Create (S : Shape from TopoDS;
|
Create (S : Shape from TopoDS;
|
||||||
D : Real from Standard;
|
D : Real from Standard;
|
||||||
Relatif : Boolean from Standard = Standard_False;
|
Relatif : Boolean from Standard = Standard_False;
|
||||||
Ang : Real from Standard = 0.5)
|
Ang : Real from Standard = 0.5;
|
||||||
|
InParallel : Boolean from Standard = Standard_False)
|
||||||
returns IncrementalMesh from BRepMesh;
|
returns IncrementalMesh from BRepMesh;
|
||||||
---Purpose: If the boolean <Relatif> is True, the
|
---Purpose: If the boolean <Relatif> is True, the
|
||||||
-- deflection used for the polygonalisation of
|
-- deflection used for the polygonalisation of
|
||||||
|
@ -86,9 +86,10 @@ BRepMesh_IncrementalMesh::BRepMesh_IncrementalMesh()
|
|||||||
BRepMesh_IncrementalMesh::BRepMesh_IncrementalMesh (const TopoDS_Shape& theShape,
|
BRepMesh_IncrementalMesh::BRepMesh_IncrementalMesh (const TopoDS_Shape& theShape,
|
||||||
const Standard_Real theDeflection,
|
const Standard_Real theDeflection,
|
||||||
const Standard_Boolean theRelative,
|
const Standard_Boolean theRelative,
|
||||||
const Standard_Real theAngle)
|
const Standard_Real theAngle,
|
||||||
|
const Standard_Boolean theInParallel)
|
||||||
: myRelative (theRelative),
|
: myRelative (theRelative),
|
||||||
myInParallel (Standard_False),
|
myInParallel (theInParallel),
|
||||||
myModified (Standard_False),
|
myModified (Standard_False),
|
||||||
myStatus (0)
|
myStatus (0)
|
||||||
{
|
{
|
||||||
|
@ -189,13 +189,28 @@ static Standard_Integer planesection(Draw_Interpretor&, Standard_Integer nbarg,
|
|||||||
|
|
||||||
static Standard_Integer incrementalmesh(Draw_Interpretor& di, Standard_Integer nbarg, const char** argv)
|
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 aShape = DBRep::Get(argv[1]);
|
||||||
TopoDS_Shape S = DBRep::Get(argv[1]);
|
if (aShape.IsNull()) {
|
||||||
if (S.IsNull()) return 1;
|
di << " null shapes is not allowed here\n";
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
Standard_Real aDeflection = atof(argv[2]);
|
||||||
|
|
||||||
BRepMesh_IncrementalMesh MESH(S,d);
|
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(aShape, aDeflection, Standard_False, 0.5, isInParallel);
|
||||||
Standard_Integer statusFlags = MESH.GetStatusFlags();
|
Standard_Integer statusFlags = MESH.GetStatusFlags();
|
||||||
|
|
||||||
di << "Meshing statuses: ";
|
di << "Meshing statuses: ";
|
||||||
@ -1597,7 +1612,7 @@ void MeshTest::Commands(Draw_Interpretor& theCommands)
|
|||||||
|
|
||||||
theCommands.Add("shpsec","shpsec result shape shape",__FILE__, shapesection, g);
|
theCommands.Add("shpsec","shpsec result shape shape",__FILE__, shapesection, g);
|
||||||
theCommands.Add("plnsec","plnsec result shape plane",__FILE__, planesection, 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("MemLeakTest","MemLeakTest",__FILE__, MemLeakTest, g);
|
||||||
theCommands.Add("fastdiscret","fastdiscret shape deflection [shared [nbiter]]",__FILE__, fastdiscret, g);
|
theCommands.Add("fastdiscret","fastdiscret shape deflection [shared [nbiter]]",__FILE__, fastdiscret, g);
|
||||||
theCommands.Add("mesh","mesh result Shape deflection [save partage]",__FILE__, triangule, g);
|
theCommands.Add("mesh","mesh result Shape deflection [save partage]",__FILE__, triangule, g);
|
||||||
|
@ -191,7 +191,7 @@ static Standard_Integer OCC1048 (Draw_Interpretor& di, Standard_Integer argc, co
|
|||||||
|
|
||||||
Standard_Real theDeflection = 0.006;
|
Standard_Real theDeflection = 0.006;
|
||||||
Handle(StlMesh_Mesh) theStlMesh = new StlMesh_Mesh;
|
Handle(StlMesh_Mesh) theStlMesh = new StlMesh_Mesh;
|
||||||
StlTransfer::BuildIncrementalMesh(aShape, theDeflection, theStlMesh);
|
StlTransfer::BuildIncrementalMesh(aShape, theDeflection, Standard_False, theStlMesh);
|
||||||
|
|
||||||
Standard_Integer NBTRIANGLES = theStlMesh->NbTriangles();
|
Standard_Integer NBTRIANGLES = theStlMesh->NbTriangles();
|
||||||
di<<"Info: Number of triangles = "<<NBTRIANGLES<<"\n";
|
di<<"Info: Number of triangles = "<<NBTRIANGLES<<"\n";
|
||||||
|
@ -65,7 +65,10 @@ is
|
|||||||
-- file is an ASCII file. If the mode returns False, the
|
-- file is an ASCII file. If the mode returns False, the
|
||||||
-- generated file is a binary file.
|
-- 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.
|
---Purpose: Converts a given shape to STL format and writes it to file with a given filename.
|
||||||
|
|
||||||
fields
|
fields
|
||||||
|
@ -54,17 +54,17 @@ Standard_Boolean& StlAPI_Writer::ASCIIMode()
|
|||||||
return theASCIIMode;
|
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) {
|
if (theRelativeMode) {
|
||||||
Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
|
Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
|
||||||
Bnd_Box Total;
|
Bnd_Box Total;
|
||||||
BRepBndLib::Add(aShape, Total);
|
BRepBndLib::Add(theShape, Total);
|
||||||
Total.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
|
Total.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
|
||||||
theDeflection = MAX3(aXmax-aXmin , aYmax-aYmin , aZmax-aZmin)*theCoefficient;
|
theDeflection = MAX3(aXmax-aXmin , aYmax-aYmin , aZmax-aZmin)*theCoefficient;
|
||||||
}
|
}
|
||||||
StlTransfer::BuildIncrementalMesh(aShape, theDeflection, theStlMesh);
|
StlTransfer::BuildIncrementalMesh(theShape, theDeflection, theInParallel, theStlMesh);
|
||||||
// Write the built mesh
|
// Write the built mesh
|
||||||
if (theASCIIMode) {
|
if (theASCIIMode) {
|
||||||
RWStl::WriteAscii(theStlMesh, aFile);
|
RWStl::WriteAscii(theStlMesh, aFile);
|
||||||
|
@ -39,6 +39,7 @@ uses
|
|||||||
is
|
is
|
||||||
BuildIncrementalMesh (Shape : in Shape from TopoDS;
|
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)
|
Mesh : Mesh from StlMesh)
|
||||||
raises ConstructionError;
|
raises ConstructionError;
|
||||||
end StlTransfer;
|
end StlTransfer;
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
#include <CSLib.hxx>
|
#include <CSLib.hxx>
|
||||||
#include <gp_Dir.hxx>
|
#include <gp_Dir.hxx>
|
||||||
#include <gp_XYZ.hxx>
|
#include <gp_XYZ.hxx>
|
||||||
#include <BRepMesh.hxx>
|
#include <BRepMesh_IncrementalMesh.hxx>
|
||||||
#include <TopAbs.hxx>
|
#include <TopAbs.hxx>
|
||||||
#include <Precision.hxx>
|
#include <Precision.hxx>
|
||||||
#include <TopExp_Explorer.hxx>
|
#include <TopExp_Explorer.hxx>
|
||||||
@ -114,6 +114,7 @@ static void Normal(const TopoDS_Face& aFace,
|
|||||||
}
|
}
|
||||||
void StlTransfer::BuildIncrementalMesh (const TopoDS_Shape& Shape,
|
void StlTransfer::BuildIncrementalMesh (const TopoDS_Shape& Shape,
|
||||||
const Standard_Real Deflection,
|
const Standard_Real Deflection,
|
||||||
|
const Standard_Boolean InParallel,
|
||||||
const Handle(StlMesh_Mesh)& Mesh)
|
const Handle(StlMesh_Mesh)& Mesh)
|
||||||
{
|
{
|
||||||
if (Deflection <= Precision::Confusion ()) {
|
if (Deflection <= Precision::Confusion ()) {
|
||||||
@ -121,7 +122,7 @@ void StlTransfer::BuildIncrementalMesh (const TopoDS_Shape& Shape,
|
|||||||
}
|
}
|
||||||
|
|
||||||
Standard_Integer NbVertices, NbTriangles;
|
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()) {
|
for (TopExp_Explorer itf(Shape,TopAbs_FACE); itf.More(); itf.Next()) {
|
||||||
TopoDS_Face face = TopoDS::Face(itf.Current());
|
TopoDS_Face face = TopoDS::Face(itf.Current());
|
||||||
TopLoc_Location Loc, loc;
|
TopLoc_Location Loc, loc;
|
||||||
|
@ -89,15 +89,24 @@
|
|||||||
static Standard_Integer writestl
|
static Standard_Integer writestl
|
||||||
(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
|
(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";
|
if (argc < 3 || argc > 5) {
|
||||||
else {
|
di << "Use: " << argv[0]
|
||||||
TopoDS_Shape shape = DBRep::Get(argv[1]);
|
<< " 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 anASCIIMode = Standard_False;
|
||||||
|
Standard_Boolean isInParallel = Standard_False;
|
||||||
if (argc==4) {
|
if (argc==4) {
|
||||||
Standard_Integer mode = atoi(argv[3]);
|
Standard_Integer mode = atoi(argv[3]);
|
||||||
if (mode==0) anASCIIMode = Standard_True;
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -961,7 +970,7 @@ void XSDRAWSTLVRML::InitCommands (Draw_Interpretor& theCommands)
|
|||||||
//XSDRAW::LoadDraw(theCommands);
|
//XSDRAW::LoadDraw(theCommands);
|
||||||
|
|
||||||
theCommands.Add ("writevrml", "shape file",__FILE__,writevrml,g);
|
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 ("readstl", "shape file",__FILE__,readstl,g);
|
||||||
theCommands.Add ("loadvrml" , "shape file",__FILE__,loadvrml,g);
|
theCommands.Add ("loadvrml" , "shape file",__FILE__,loadvrml,g);
|
||||||
theCommands.Add ("storevrml" , "shape file defl [type]",__FILE__,storevrml,g);
|
theCommands.Add ("storevrml" , "shape file defl [type]",__FILE__,storevrml,g);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user