1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-07-30 13:05:50 +03:00

0022600: TBB has to be disabled in BRepMesh due to data races

This commit is contained in:
KGV 2011-09-07 08:30:31 +00:00 committed by bugmaster
parent 7edf74fd3d
commit 0b97567d24
14 changed files with 701 additions and 447 deletions

View File

@ -32,7 +32,8 @@ uses Standard,
GeomAbs, GeomAbs,
GeomAdaptor, GeomAdaptor,
TopLoc, TopLoc,
SortTools SortTools,
Plugin
is enumeration DegreeOfFreedom is is enumeration DegreeOfFreedom is
@ -79,6 +80,8 @@ is enumeration DegreeOfFreedom is
imported VertexCellFilter from BRepMesh; imported VertexCellFilter from BRepMesh;
imported VectorOfVertex from BRepMesh; imported VectorOfVertex from BRepMesh;
primitive PluginEntryType;
class ComparatorOfVertexOfDelaun; class ComparatorOfVertexOfDelaun;
class ComparatorOfIndexedVertexOfDelaun; class ComparatorOfIndexedVertexOfDelaun;
class SelectorOfDataStructureOfDelaun; class SelectorOfDataStructureOfDelaun;

View File

@ -1,71 +1,105 @@
-- File: BRepMesh_DiscretFactory.cdl -- File: BRepMesh_DiscretFactory.cdl
-- Created: Thu Apr 10 12:34:15 2008 -- Created: Thu Apr 10 12:34:15 2008
-- Author: Peter KURNEV -- Author: Peter KURNEV <pkv@irinox>
-- <pkv@irinox> --
---Copyright: Matra Datavision 2008 ---Copyright: Matra Datavision 2008
class DiscretFactory from BRepMesh
class DiscretFactory from BRepMesh ---Purpose:
-- This class intended to setup / retrieve default triangulation algorithm.
---Purpose: -- Use BRepMesh_DiscretFactory::Get() static method to retrieve global Factory instance.
-- Use BRepMesh_DiscretFactory::Discret() method to retrieve meshing tool.
uses uses
AsciiString from TCollection, DiscretRoot from BRepMesh,
PDiscretRoot from BRepMesh, FactoryError from BRepMesh,
MapOfAsciiString from TColStd, PluginEntryType from BRepMesh,
FactoryError from BRepMesh, AsciiString from TCollection,
Shape from TopoDS MapOfAsciiString from TColStd,
Shape from TopoDS,
MapOfFunctions from Plugin
--raises --raises
is
is
Create Create
returns DiscretFactory from BRepMesh returns DiscretFactory from BRepMesh
is protected; is protected;
---C++: alias "Standard_EXPORT virtual ~BRepMesh_DiscretFactory();" ---C++: alias "Standard_EXPORT virtual ~BRepMesh_DiscretFactory();"
Get(myclass) Get (myclass)
returns DiscretFactory from BRepMesh; returns DiscretFactory from BRepMesh;
---C++: return & ---C++: return &
---Purpose:
Names(me) -- Returns the global factory instance.
returns MapOfAsciiString from TColStd;
---C++: return const &
SetDefaultName(me:out; Names (me)
theName:AsciiString from TCollection); returns MapOfAsciiString from TColStd;
---C++: return const &
DefaultName(me) ---Purpose:
returns AsciiString from TCollection; -- Returns the list of registered meshing algorithms.
---C++: return const &
SetFunctionName(me:out;
theName:AsciiString from TCollection);
FunctionName(me)
returns AsciiString from TCollection;
---C++: return const &
Discret(me:out; SetDefaultName ( me : out;
theShape:Shape from TopoDS; theName : AsciiString from TCollection)
theDeflection : Real from Standard; returns Boolean from Standard;
theAngle : Real from Standard) ---Purpose:
returns PDiscretRoot from BRepMesh; -- Setup meshing algorithm by name.
---C++: return & -- Returns true if requested tool is available.
-- On fail Factory will continue to use previous algo.
ErrorStatus(me)
returns FactoryError from BRepMesh; DefaultName (me)
returns AsciiString from TCollection;
---C++: return const &
---Purpose:
-- Returns name for current meshing algorithm.
SetFunctionName ( me : out;
theFuncName : AsciiString from TCollection)
returns Boolean from Standard;
---Purpose:
-- Advanced function. Changes function name to retrieve from plugin.
-- Returns true if requested tool is available.
-- On fail Factory will continue to use previous algo.
SetDefault ( me : out;
theName : AsciiString from TCollection;
theFuncName : AsciiString from TCollection = "DISCRETALGO")
returns Boolean from Standard;
---Purpose:
-- Setup meshing algorithm that should be created by this Factory.
-- Returns true if requested tool is available.
-- On fail Factory will continue to use previous algo.
-- Call ::ErrorStatus() method to retrieve fault reason.
FunctionName (me)
returns AsciiString from TCollection;
---C++: return const &
---Purpose:
-- Returns function name that should be exported by plugin.
Discret (me : out;
theShape : Shape from TopoDS;
theDeflection : Real from Standard;
theAngle : Real from Standard)
returns DiscretRoot from BRepMesh;
---Purpose:
-- Returns triangulation algorithm instance.
ErrorStatus (me)
returns FactoryError from BRepMesh;
---Purpose:
-- Returns error status for last meshing algorithm switch.
Clear (me : out)
is protected;
fields
myPluginEntry : PluginEntryType from BRepMesh is protected;
myErrorStatus : FactoryError from BRepMesh is protected;
myNames : MapOfAsciiString from TColStd is protected;
myDefaultName : AsciiString from TCollection is protected;
myFunctionName : AsciiString from TCollection is protected;
myFactoryMethods : MapOfFunctions from Plugin is protected;
Clear(me:out)
is protected;
fields
myPDiscret : PDiscretRoot from BRepMesh is protected;
myErrorStatus : FactoryError from BRepMesh is protected;
myNames : MapOfAsciiString from TColStd is protected;
myFixedNames : AsciiString from TCollection[1] is protected;
myDefaultName : AsciiString from TCollection is protected;
myFunctionName: AsciiString from TCollection is protected;
end DiscretFactory; end DiscretFactory;

View File

@ -1,223 +1,242 @@
// File: BRepMesh_DiscretFactory.cxx // File: BRepMesh_DiscretFactory.cxx
// Created: Thu Apr 10 13:32:00 2008 // Created: Thu Apr 10 13:32:00 2008
// Author: Peter KURNEV // Author: Peter KURNEV <pkv@irinox>
// <pkv@irinox>
#include <BRepMesh_DiscretFactory.ixx> #include <BRepMesh_DiscretFactory.ixx>
#include <OSD_SharedLibrary.hxx> #include <OSD_SharedLibrary.hxx>
#include <OSD_Function.hxx> #include <OSD_Function.hxx>
#include <BRepMesh_IncrementalMesh.hxx> #include <BRepMesh_IncrementalMesh.hxx>
#include <BRepMesh_PDiscretRoot.hxx>
static namespace
void MakeLibName(const TCollection_AsciiString& , {
TCollection_AsciiString& ); //! Embedded triangulation tool(s)
static static TCollection_AsciiString THE_FAST_DISCRET_MESH ("FastDiscret");
Standard_Integer CreateDiscret(const TopoDS_Shape& theShape,
const Standard_Real , //! Generate system-dependent name for dynamic library
const Standard_Real , //! (add standard prefixes and postfixes)
OSD_Function& , static void MakeLibName (const TCollection_AsciiString& theDefaultName,
BRepMesh_PDiscretRoot& ); TCollection_AsciiString& theLibName)
{
theLibName = "";
#ifndef WNT
theLibName += "lib";
#endif
theLibName += theDefaultName;
#ifdef WNT
theLibName += ".dll";
#elif __APPLE__
theLibName += ".dylib";
#elif defined (HPUX) || defined(_hpux)
theLibName += ".sl";
#else
theLibName += ".so";
#endif
}
};
//======================================================================= //=======================================================================
//function : BRepMesh_DiscretFactory //function : BRepMesh_DiscretFactory
//purpose : //purpose :
//======================================================================= //=======================================================================
BRepMesh_DiscretFactory::BRepMesh_DiscretFactory() BRepMesh_DiscretFactory::BRepMesh_DiscretFactory()
: myPluginEntry (NULL),
myErrorStatus (BRepMesh_FE_NOERROR),
myDefaultName (THE_FAST_DISCRET_MESH),
myFunctionName ("DISCRETALGO")
{ {
myFixedNames[0]="FastDiscret"; // register built-in meshing algorithms
myNames.Add (THE_FAST_DISCRET_MESH);
//
myNames.Add(myFixedNames[0]);
myDefaultName=myFixedNames[0];
myFunctionName="DISCRETALGO";
myPDiscret=NULL;
} }
//======================================================================= //=======================================================================
//function : ~ //function : ~
//purpose : //purpose :
//======================================================================= //=======================================================================
BRepMesh_DiscretFactory::~BRepMesh_DiscretFactory() BRepMesh_DiscretFactory::~BRepMesh_DiscretFactory()
{ {
Clear(); Clear();
} }
//======================================================================= //=======================================================================
//function : ~ //function : ~
//purpose : //purpose :
//======================================================================= //=======================================================================
void BRepMesh_DiscretFactory::Clear() void BRepMesh_DiscretFactory::Clear()
{ {
if (myPDiscret) { // what should we do here? Unload dynamic libraries and reset plugins list?
delete myPDiscret;
myPDiscret=NULL;
}
} }
//======================================================================= //=======================================================================
//function : Get //function : Get
//purpose : //purpose :
//======================================================================= //=======================================================================
BRepMesh_DiscretFactory& BRepMesh_DiscretFactory::Get() BRepMesh_DiscretFactory& BRepMesh_DiscretFactory::Get()
{ {
static BRepMesh_DiscretFactory* sFactory; //! global factory instance
static Standard_Boolean isInit=Standard_False; static BRepMesh_DiscretFactory THE_GLOBAL_FACTORY;
if(!isInit) { return THE_GLOBAL_FACTORY;
isInit = Standard_True;
sFactory = new BRepMesh_DiscretFactory;
}
return *sFactory;
} }
//======================================================================= //=======================================================================
//function : ErrorStatus //function : ErrorStatus
//purpose : //purpose :
//======================================================================= //=======================================================================
BRepMesh_FactoryError BRepMesh_DiscretFactory::ErrorStatus()const BRepMesh_FactoryError BRepMesh_DiscretFactory::ErrorStatus() const
{ {
return myErrorStatus; return myErrorStatus;
} }
//======================================================================= //=======================================================================
//function : Names //function : Names
//purpose : //purpose :
//======================================================================= //=======================================================================
const TColStd_MapOfAsciiString& BRepMesh_DiscretFactory::Names()const const TColStd_MapOfAsciiString& BRepMesh_DiscretFactory::Names() const
{ {
return myNames; return myNames;
} }
//======================================================================= //=======================================================================
//function : SetDefaultName //function : SetDefaultName
//purpose : //purpose :
//======================================================================= //=======================================================================
void BRepMesh_DiscretFactory::SetDefaultName(const TCollection_AsciiString& theName) Standard_Boolean BRepMesh_DiscretFactory::SetDefaultName (const TCollection_AsciiString& theName)
{ {
myDefaultName=theName; return SetDefault (theName, myFunctionName);
} }
//======================================================================= //=======================================================================
//function : DefaultName //function : DefaultName
//purpose : //purpose :
//======================================================================= //=======================================================================
const TCollection_AsciiString& BRepMesh_DiscretFactory::DefaultName()const const TCollection_AsciiString& BRepMesh_DiscretFactory::DefaultName() const
{ {
return myDefaultName; return myDefaultName;
} }
//======================================================================= //=======================================================================
//function : SetFunctionName //function : SetFunctionName
//purpose : //purpose :
//======================================================================= //=======================================================================
void BRepMesh_DiscretFactory::SetFunctionName(const TCollection_AsciiString& theName) Standard_Boolean BRepMesh_DiscretFactory::SetFunctionName (const TCollection_AsciiString& theFuncName)
{ {
myFunctionName=theName; return SetDefault (myDefaultName, theFuncName);
} }
//======================================================================= //=======================================================================
//function : FunctionName //function : FunctionName
//purpose : //purpose :
//======================================================================= //=======================================================================
const TCollection_AsciiString& BRepMesh_DiscretFactory::FunctionName()const const TCollection_AsciiString& BRepMesh_DiscretFactory::FunctionName() const
{ {
return myFunctionName; return myFunctionName;
} }
//=======================================================================
//function : SetDefault
//purpose :
//=======================================================================
Standard_Boolean BRepMesh_DiscretFactory::SetDefault (const TCollection_AsciiString& theName,
const TCollection_AsciiString& theFuncName)
{
myErrorStatus = BRepMesh_FE_NOERROR;
if (theName == THE_FAST_DISCRET_MESH)
{
// built-in, nothing to do
myPluginEntry = NULL;
myDefaultName = theName;
myFunctionName = theFuncName;
return Standard_True;
}
else if (theName == myDefaultName && theFuncName == myFunctionName)
{
// already active
return myPluginEntry != NULL;
}
TCollection_AsciiString aMeshAlgoId = theName + "_" + theFuncName;
BRepMesh_PluginEntryType aFunc = NULL;
if (myFactoryMethods.IsBound (aMeshAlgoId))
{
// retrieve from cache
aFunc = (BRepMesh_PluginEntryType )myFactoryMethods (aMeshAlgoId);
}
else
{
TCollection_AsciiString aLibName;
MakeLibName (theName, aLibName);
OSD_SharedLibrary aSL (aLibName.ToCString());
if (!aSL.DlOpen (OSD_RTLD_LAZY))
{
// library is not found
myErrorStatus = BRepMesh_FE_LIBRARYNOTFOUND;
return Standard_False;
}
// retrieve the function from plugin
aFunc = (BRepMesh_PluginEntryType )aSL.DlSymb (theFuncName.ToCString());
myFactoryMethods.Bind (aMeshAlgoId, (OSD_Function )aFunc);
}
if (aFunc == NULL)
{
// function is not found - invalid plugin?
myErrorStatus = BRepMesh_FE_FUNCTIONNOTFOUND;
return Standard_False;
}
// try to create dummy tool
BRepMesh_PDiscretRoot anInstancePtr = NULL;
Standard_Integer anErr = aFunc (TopoDS_Shape(), 0.001, 0.1, anInstancePtr);
if (anErr != 0 || anInstancePtr == NULL)
{
// can not create the algo specified
myErrorStatus = BRepMesh_FE_CANNOTCREATEALGO;
delete anInstancePtr;
return Standard_False;
}
delete anInstancePtr;
// if all checks done - switch to this tool
myPluginEntry = aFunc;
myDefaultName = theName;
myFunctionName = theFuncName;
myNames.Add (theName);
return Standard_True;
}
//======================================================================= //=======================================================================
//function : Discret //function : Discret
//purpose : //purpose :
//======================================================================= //=======================================================================
BRepMesh_PDiscretRoot& Handle(BRepMesh_DiscretRoot) BRepMesh_DiscretFactory
BRepMesh_DiscretFactory::Discret(const TopoDS_Shape& theShape, ::Discret (const TopoDS_Shape& theShape,
const Standard_Real theDeflection, const Standard_Real theDeflection,
const Standard_Real theAngle) const Standard_Real theAngle)
{ {
myErrorStatus=BRepMesh_FE_NOERROR; Handle(BRepMesh_DiscretRoot) aDiscretRoot;
Clear(); BRepMesh_PDiscretRoot anInstancePtr = NULL;
// DEB f if (myPluginEntry != NULL)
//myDefaultName="TKXMesh"; {
// DEB t // use plugin
if(myDefaultName==myFixedNames[0]) { Standard_Integer anErr = myPluginEntry (theShape, theDeflection, theAngle, anInstancePtr);
myPDiscret=new BRepMesh_IncrementalMesh; if (anErr != 0 || anInstancePtr == NULL)
myPDiscret->SetDeflection(theDeflection); {
myPDiscret->SetAngle(theAngle); // can not create the algo specified - should never happens here
myPDiscret->SetShape(theShape); myErrorStatus = BRepMesh_FE_CANNOTCREATEALGO;
} return aDiscretRoot;
else {
Standard_Integer iErr;
TCollection_AsciiString aLibName;
OSD_Function aF;
//
myPDiscret=NULL;
//
MakeLibName(myDefaultName, aLibName);
//
OSD_SharedLibrary aSL(aLibName.ToCString());
if (!aSL.DlOpen(OSD_RTLD_LAZY)) {
myErrorStatus=BRepMesh_FE_LIBRARYNOTFOUND; // library is not found
return myPDiscret;
}
//
aF = aSL.DlSymb(myFunctionName.ToCString());
if(aF==NULL ) {
myErrorStatus=BRepMesh_FE_FUNCTIONNOTFOUND; // function is not found
return myPDiscret;
}
//
iErr=CreateDiscret(theShape,
theDeflection,
theAngle,
aF,
myPDiscret);
if (iErr) {
myErrorStatus=BRepMesh_FE_CANNOTCREATEALGO; // can not create the algo specified
}
else {
myNames.Add(myDefaultName);
} }
} }
// else //if (myDefaultName == THE_FAST_DISCRET_MESH)
return myPDiscret; {
} // use built-in
//======================================================================= BRepMesh_IncrementalMesh::Discret (theShape, theDeflection, theAngle, anInstancePtr);
//function : CreateDiscret }
//purpose :
//======================================================================= // cover with handle
Standard_Integer CreateDiscret(const TopoDS_Shape& theShape, aDiscretRoot = anInstancePtr;
const Standard_Real theDeflection,
const Standard_Real theAngle, // return the handle
OSD_Function& theF, return aDiscretRoot;
BRepMesh_PDiscretRoot& theAlgo)
{
Standard_Integer iErr;
Standard_Integer (*fp) (const TopoDS_Shape& ,
const Standard_Real ,
const Standard_Real ,
BRepMesh_PDiscretRoot& );
//
fp=(Standard_Integer (*)(const TopoDS_Shape& ,
const Standard_Real ,
const Standard_Real ,
BRepMesh_PDiscretRoot&)) theF;
//
iErr=(*fp)(theShape,
theDeflection,
theAngle,
theAlgo);
//
return iErr;
}
//=======================================================================
//function : MakeLibName
//purpose :
//=======================================================================
void MakeLibName(const TCollection_AsciiString& theDefaultName,
TCollection_AsciiString& theLibName)
{
theLibName="";
#ifndef WNT
theLibName+="lib";
#endif
theLibName+=theDefaultName;
#ifdef WNT
theLibName+=".dll";
#elif __APPLE__
theLibName+=".dylib";
#elif defined (HPUX) || defined(_hpux)
theLibName+=".sl";
#else
theLibName+=".so";
#endif
} }

View File

@ -1,65 +1,83 @@
-- File: BRepMesh_DiscretRoot.cdl -- File: BRepMesh_DiscretRoot.cdl
-- Created: Thu Apr 10 09:57:55 2008 -- Created: Thu Apr 10 09:57:55 2008
-- Author: Peter KURNEV -- Author: Peter KURNEV <pkv@irinox>
-- <pkv@irinox> --
---Copyright: Matra Datavision 2008 ---Copyright: Matra Datavision 2008
deferred class DiscretRoot from BRepMesh
deferred class DiscretRoot from BRepMesh inherits Transient from Standard
---Purpose: ---Purpose:
-- This is a common interface for meshing algorithms
-- instantiated by Mesh Factory and implemented by plugins.
uses uses
Shape from TopoDS Shape from TopoDS
--raises --raises
is is
Initialize
Initialize returns DiscretRoot from BRepMesh;
returns DiscretRoot from BRepMesh;
SetDeflection(me: out;
theDeflection : Real from Standard);
---C++: alias "Standard_EXPORT virtual ~BRepMesh_DiscretRoot();"
Deflection(me)
returns Real from Standard;
SetAngle(me: out; SetDeflection ( me : mutable;
theAngle: Real from Standard); theDeflection : Real from Standard);
---Purpose:
Angle(me) -- Setup linear deflection.
returns Real from Standard;
SetShape(me: out;
theShape: Shape from TopoDS);
Shape(me) ---C++: alias "Standard_EXPORT virtual ~BRepMesh_DiscretRoot();"
returns Shape from TopoDS;
---C++: return const &
Perform(me: out) Deflection (me)
is deferred; returns Real from Standard;
---Purpose:
-- Returns linear deflection.
IsDone(me) SetAngle ( me : mutable;
returns Boolean from Standard; theAngle : Real from Standard);
---Purpose:
-- Setup angular deflection.
-- Angle (me)
-- Protected methods returns Real from Standard;
-- ---Purpose:
SetDone(me:out) -- Returns angular deflection.
is protected;
SetShape ( me : mutable;
SetNotDone(me:out) theShape : Shape from TopoDS);
is protected; ---Purpose:
-- Set the shape to triangulate.
Init(me:out)
is virtual protected; Shape (me)
fields returns Shape from TopoDS;
myDeflection : Real from Standard is protected; ---C++: return const &
Perform (me : mutable)
is deferred;
---Purpose:
-- Compute triangulation for set shape.
IsDone (me)
returns Boolean from Standard;
---Purpose:
-- Returns true if triangualtion was performed and has success.
--
-- Protected methods
--
SetDone (me : mutable)
is protected;
SetNotDone (me : mutable)
is protected;
Init (me : mutable)
is virtual protected;
fields
myDeflection : Real from Standard is protected;
myAngle : Real from Standard is protected; myAngle : Real from Standard is protected;
myShape : Shape from TopoDS is protected; myShape : Shape from TopoDS is protected;
myIsDone : Boolean from Standard is protected; myIsDone : Boolean from Standard is protected;
end DiscretRoot; end DiscretRoot;

View File

@ -1,105 +1,115 @@
// File: BRepMesh_DiscretRoot.cxx // File: BRepMesh_DiscretRoot.cxx
// Created: Thu Apr 10 10:08:44 2008 // Created: Thu Apr 10 10:08:44 2008
// Author: Peter KURNEV // Author: Peter KURNEV <pkv@irinox>
// <pkv@irinox>
#include <BRepMesh_DiscretRoot.ixx> #include <BRepMesh_DiscretRoot.ixx>
//======================================================================= //=======================================================================
//function : BRepMesh_DiscretRoot //function : BRepMesh_DiscretRoot
//purpose : //purpose :
//======================================================================= //=======================================================================
BRepMesh_DiscretRoot::BRepMesh_DiscretRoot() BRepMesh_DiscretRoot::BRepMesh_DiscretRoot()
: myDeflection (0.001),
myAngle (0.1),
myIsDone (Standard_False)
{ {
myIsDone=Standard_False; //
myDeflection=0.001;
myAngle=0.1;
} }
//======================================================================= //=======================================================================
//function : ~ //function : ~
//purpose : //purpose :
//======================================================================= //=======================================================================
BRepMesh_DiscretRoot::~BRepMesh_DiscretRoot() BRepMesh_DiscretRoot::~BRepMesh_DiscretRoot()
{ {
} }
//======================================================================= //=======================================================================
//function : SetDeflection //function : SetDeflection
//purpose : //purpose :
//======================================================================= //=======================================================================
void BRepMesh_DiscretRoot::SetDeflection(const Standard_Real theDeflection) void BRepMesh_DiscretRoot::SetDeflection (const Standard_Real theDeflection)
{ {
myDeflection=theDeflection; myDeflection = theDeflection;
} }
//======================================================================= //=======================================================================
//function : Deflection //function : Deflection
//purpose : //purpose :
//======================================================================= //=======================================================================
Standard_Real BRepMesh_DiscretRoot::Deflection()const Standard_Real BRepMesh_DiscretRoot::Deflection() const
{ {
return myDeflection; return myDeflection;
} }
//======================================================================= //=======================================================================
//function : SetAngle //function : SetAngle
//purpose : //purpose :
//======================================================================= //=======================================================================
void BRepMesh_DiscretRoot::SetAngle(const Standard_Real theAngle) void BRepMesh_DiscretRoot::SetAngle (const Standard_Real theAngle)
{ {
myAngle=theAngle; myAngle = theAngle;
} }
//======================================================================= //=======================================================================
//function : Angle //function : Angle
//purpose : //purpose :
//======================================================================= //=======================================================================
Standard_Real BRepMesh_DiscretRoot::Angle()const Standard_Real BRepMesh_DiscretRoot::Angle() const
{ {
return myAngle; return myAngle;
} }
//======================================================================= //=======================================================================
//function : SetShape //function : SetShape
//purpose : //purpose :
//======================================================================= //=======================================================================
void BRepMesh_DiscretRoot::SetShape(const TopoDS_Shape& theShape) void BRepMesh_DiscretRoot::SetShape (const TopoDS_Shape& theShape)
{ {
myShape=theShape; myShape = theShape;
} }
//======================================================================= //=======================================================================
//function : Shape //function : Shape
//purpose : //purpose :
//======================================================================= //=======================================================================
const TopoDS_Shape& BRepMesh_DiscretRoot::Shape()const const TopoDS_Shape& BRepMesh_DiscretRoot::Shape() const
{ {
return myShape; return myShape;
} }
//======================================================================= //=======================================================================
//function : IsDone //function : IsDone
//purpose : //purpose :
//======================================================================= //=======================================================================
Standard_Boolean BRepMesh_DiscretRoot::IsDone()const Standard_Boolean BRepMesh_DiscretRoot::IsDone() const
{ {
return myIsDone; return myIsDone;
} }
//======================================================================= //=======================================================================
//function : SetDone //function : SetDone
//purpose : //purpose :
//======================================================================= //=======================================================================
void BRepMesh_DiscretRoot::SetDone() void BRepMesh_DiscretRoot::SetDone()
{ {
myIsDone=Standard_True; myIsDone = Standard_True;
} }
//======================================================================= //=======================================================================
//function : SetNotDone //function : SetNotDone
//purpose : //purpose :
//======================================================================= //=======================================================================
void BRepMesh_DiscretRoot::SetNotDone() void BRepMesh_DiscretRoot::SetNotDone()
{ {
myIsDone=Standard_False; myIsDone = Standard_False;
} }
//======================================================================= //=======================================================================
//function : Init //function : Init
//purpose : //purpose :
//======================================================================= //=======================================================================
void BRepMesh_DiscretRoot::Init() void BRepMesh_DiscretRoot::Init()
{ {
//
} }

View File

@ -165,6 +165,16 @@ is
defedge: Real from Standard) defedge: Real from Standard)
is static private; is static private;
SetParallel ( me : mutable;
theInParallel : Boolean from Standard);
---Purpose:
-- Request algorithm to launch in multiple threads
-- to improve performance (should be supported by plugin).
IsParallel (me)
returns Boolean from Standard;
---Purpose:
-- Returns the multi-threading usage flag.
-- Output : -- Output :
@ -293,6 +303,7 @@ fields
myDeflection : Real from Standard; myDeflection : Real from Standard;
myDtotale : Real from Standard; myDtotale : Real from Standard;
myWithShare : Boolean from Standard; myWithShare : Boolean from Standard;
myInParallel : Boolean from Standard;
myVertices : DataMapOfVertexInteger from BRepMesh; myVertices : DataMapOfVertexInteger from BRepMesh;
myEdges : DataMapOfShapePairOfPolygon from BRepMesh; myEdges : DataMapOfShapePairOfPolygon from BRepMesh;
myInternaledges: DataMapOfShapePairOfPolygon from BRepMesh; myInternaledges: DataMapOfShapePairOfPolygon from BRepMesh;

View File

@ -77,14 +77,9 @@
#include <vector> #include <vector>
// NOTE: replaced by more correct check
// #if defined(WNT) || defined(LIN)
// #define HAVE_TBB 1
// #endif
// paralleling with Intel TBB
#ifdef HAVE_TBB #ifdef HAVE_TBB
#include <tbb/parallel_for_each.h> // paralleling using Intel TBB
#include <tbb/parallel_for_each.h>
#endif #endif
#define UVDEFLECTION 1.e-05 #define UVDEFLECTION 1.e-05
@ -121,9 +116,14 @@ BRepMesh_FastDiscret::BRepMesh_FastDiscret(const Standard_Real theDefle,
const Standard_Boolean theInshape, const Standard_Boolean theInshape,
const Standard_Boolean theRelative, const Standard_Boolean theRelative,
const Standard_Boolean theShapetrigu) : const Standard_Boolean theShapetrigu) :
myAngle(theAngl), myDeflection(theDefle),myWithShare(theWithShare), myAngle (theAngl),
myNbLocat(0), myRelative(theRelative), myShapetrigu(theShapetrigu), myDeflection (theDefle),
myInshape(theInshape) myWithShare (theWithShare),
myInParallel (Standard_False),
myNbLocat (0),
myRelative (theRelative),
myShapetrigu (theShapetrigu),
myInshape (theInshape)
{ {
myAllocator = new NCollection_IncAllocator(64000); myAllocator = new NCollection_IncAllocator(64000);
if(myRelative) if(myRelative)
@ -143,9 +143,14 @@ BRepMesh_FastDiscret::BRepMesh_FastDiscret(const Standard_Real theDefle,
const Standard_Boolean theInshape, const Standard_Boolean theInshape,
const Standard_Boolean theRelative, const Standard_Boolean theRelative,
const Standard_Boolean theShapetrigu): const Standard_Boolean theShapetrigu):
myAngle(theAngl), myDeflection(theDefle),myWithShare(theWithShare), myAngle (theAngl),
myNbLocat(0), myRelative(theRelative), myShapetrigu(theShapetrigu), myDeflection (theDefle),
myInshape(theInshape) myWithShare (theWithShare),
myInParallel (Standard_False),
myNbLocat (0),
myRelative (theRelative),
myShapetrigu (theShapetrigu),
myInshape (theInshape)
{ {
myAllocator = new NCollection_IncAllocator(64000); myAllocator = new NCollection_IncAllocator(64000);
if(myRelative) if(myRelative)
@ -212,15 +217,23 @@ void BRepMesh_FastDiscret::Perform(const TopoDS_Shape& theShape)
Add(aF); Add(aF);
aFaces.push_back(aF); aFaces.push_back(aF);
} }
// mesh faces in parallel threads using TBB if (myInParallel)
#ifdef HAVE_TBB {
if (Standard::IsReentrant()) #ifdef HAVE_TBB
// mesh faces in parallel threads using TBB
tbb::parallel_for_each (aFaces.begin(), aFaces.end(), *this); tbb::parallel_for_each (aFaces.begin(), aFaces.end(), *this);
#else
// alternative parallelization not yet available
for (std::vector<TopoDS_Face>::iterator it(aFaces.begin()); it != aFaces.end(); it++)
Process (*it);
#endif
}
else else
#endif {
for (std::vector<TopoDS_Face>::iterator it(aFaces.begin()); it != aFaces.end(); it++) for (std::vector<TopoDS_Face>::iterator it(aFaces.begin()); it != aFaces.end(); it++)
Process (*it); Process (*it);
}
} }

View File

@ -1,19 +1,18 @@
-- File: BRepMesh_IncrementalMesh.cdl -- File: BRepMesh_IncrementalMesh.cdl
-- Created: Tue Jun 20 10:19:28 1995 -- Created: Tue Jun 20 10:19:28 1995
-- Author: Stagiaire Alain JOURDAIN -- Author: Stagiaire Alain JOURDAIN <ajo@phobox>
-- <ajo@phobox> --
---Copyright: Matra Datavision 1995 ---Copyright: Matra Datavision 1995
class IncrementalMesh from BRepMesh class IncrementalMesh from BRepMesh
inherits DiscretRoot from BRepMesh
---Purpose: Builds the mesh of a shape with respect of their
-- correctly triangulated parts
--
inherits DiscretRoot from BRepMesh
uses ---Purpose: Builds the mesh of a shape with respect of their
-- correctly triangulated parts
--
uses
Box from Bnd, Box from Bnd,
Shape from TopoDS, Shape from TopoDS,
Face from TopoDS, Face from TopoDS,
@ -21,77 +20,109 @@ uses
MapOfShape from TopTools, MapOfShape from TopTools,
IndexedDataMapOfShapeListOfShape from TopTools, IndexedDataMapOfShapeListOfShape from TopTools,
DataMapOfShapeReal from TopTools, DataMapOfShapeReal from TopTools,
FastDiscret from BRepMesh, FastDiscret from BRepMesh,
Status from BRepMesh Status from BRepMesh,
PDiscretRoot from BRepMesh
is is
Create Create
returns IncrementalMesh from BRepMesh; returns IncrementalMesh from BRepMesh;
---C++: alias "Standard_EXPORT virtual ~BRepMesh_IncrementalMesh();" ---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)
---Purpose: if the boolean <Relatif> is True, the
-- deflection used for the polygonalisation of
-- each edge will be <D> * Size of Edge.
-- the deflection used for the faces will be the maximum
-- deflection of their edges.
returns IncrementalMesh from BRepMesh;
SetRelative(me:out; Create (S : Shape from TopoDS;
theFlag : Boolean from Standard); D : Real from Standard;
Relatif : Boolean from Standard = Standard_False;
Relative(me) Ang : Real from Standard = 0.5)
returns Boolean from Standard; returns IncrementalMesh from BRepMesh;
---Purpose: If the boolean <Relatif> is True, the
Init(me:out) -- deflection used for the polygonalisation of
is redefined protected; -- each edge will be <D> * Size of Edge.
-- the deflection used for the faces will be the maximum
Perform(me:out) -- deflection of their edges.
is redefined;
SetRelative ( me : mutable;
Update(me:out; theFlag : Boolean from Standard);
S : Shape from TopoDS)
---Purpose: Builds the incremental mesh of the shape Relative (me)
is static; returns Boolean from Standard;
IsModified(me) returns Boolean from Standard Init (me : mutable)
is static; is redefined protected;
Update(me : in out; Perform (me : mutable)
E : Edge from TopoDS) is redefined;
---Purpose: Locate a correct discretisation if it exists
-- Set no one otherwise Update (me : mutable;
is static private; S : Shape from TopoDS)
is static;
Update(me : in out; ---Purpose: Builds the incremental mesh of the shape
F : Face from TopoDS)
---Purpose: if the face is not correctly triangulated, or IsModified (me)
-- if one of its edges is to be discretisated returns Boolean from Standard
-- correctly, the triangulation of this face is is static;
-- built.
is static private; Update (me : mutable;
E : Edge from TopoDS)
GetStatusFlags(me) is static private;
returns Integer from Standard ---Purpose: Locate a correct discretisation if it exists
is static; -- Set no one otherwise
Update (me : mutable;
F : Face from TopoDS)
is static private;
---Purpose: If the face is not correctly triangulated, or
-- if one of its edges is to be discretisated
-- correctly, the triangulation of this face is
-- built.
GetStatusFlags (me)
returns Integer from Standard
is static;
SetParallel ( me : mutable;
theInParallel : Boolean from Standard);
---Purpose:
-- Request algorithm to launch in multiple threads to improve performance.
IsParallel (me)
returns Boolean from Standard;
---Purpose:
-- Returns the multi-threading usage flag.
--
-- Plugin interface
--
Discret (myclass;
theShape : Shape from TopoDS;
theDeflection : Real from Standard;
theAngle : Real from Standard;
theAlgo : out PDiscretRoot from BRepMesh)
returns Integer from Standard;
---Purpose:
-- Plugin interface for the Mesh Factories.
IsParallelDefault (myclass)
returns Boolean from Standard;
---Purpose:
-- Returns multi-threading usage flag set by default in
-- Discret() static method (thus applied only to Mesh Factories).
SetParallelDefault (myclass;
theInParallel : Boolean from Standard);
---Purpose:
-- Setup multi-threading usage flag set by default in
-- Discret() static method (thus applied only to Mesh Factories).
fields fields
myRelative : Boolean from Standard is protected; myRelative : Boolean from Standard is protected;
myInParallel : Boolean from Standard is protected;
myMap : MapOfShape from TopTools is protected; myMap : MapOfShape from TopTools is protected;
myMesh : FastDiscret from BRepMesh is protected; myMesh : FastDiscret from BRepMesh is protected;
myModified : Boolean from Standard is protected; myModified : Boolean from Standard is protected;
mymapedge : DataMapOfShapeReal from TopTools is protected; mymapedge : DataMapOfShapeReal from TopTools is protected;
myancestors : IndexedDataMapOfShapeListOfShape from TopTools is protected; myancestors : IndexedDataMapOfShapeListOfShape from TopTools is protected;
mydtotale : Real from Standard is protected; mydtotale : Real from Standard is protected;
myBox : Box from Bnd is protected; myBox : Box from Bnd is protected;
myStatus : Integer from Standard is protected; myStatus : Integer from Standard is protected;
end IncrementalMesh; end IncrementalMesh;

View File

@ -10,6 +10,7 @@
#include <BRepMesh_Edge.hxx> #include <BRepMesh_Edge.hxx>
#include <BRepMesh_Triangle.hxx> #include <BRepMesh_Triangle.hxx>
#include <BRepMesh_FastDiscretFace.hxx> #include <BRepMesh_FastDiscretFace.hxx>
#include <BRepMesh_PluginMacro.hxx>
#include <Bnd_Box.hxx> #include <Bnd_Box.hxx>
#include <BRep_Builder.hxx> #include <BRep_Builder.hxx>
@ -36,24 +37,27 @@
#include <vector> #include <vector>
// NOTE: to be replaced by more correct check
// #if defined(WNT) || defined(LIN)
// #define HAVE_TBB 1
// #endif
// paralleling with Intel TBB
#ifdef HAVE_TBB #ifdef HAVE_TBB
#include <tbb/parallel_for_each.h> // paralleling using Intel TBB
#include <tbb/parallel_for_each.h>
#endif #endif
namespace
{
//! Default flag to control parallelization for BRepMesh_IncrementalMesh
//! tool returned for Mesh Factory
static Standard_Boolean IS_IN_PARALLEL = Standard_False;
};
//======================================================================= //=======================================================================
//function : BRepMesh_IncrementalMesh //function : BRepMesh_IncrementalMesh
//purpose : //purpose :
//======================================================================= //=======================================================================
BRepMesh_IncrementalMesh::BRepMesh_IncrementalMesh() BRepMesh_IncrementalMesh::BRepMesh_IncrementalMesh()
: myRelative(Standard_False), : myRelative (Standard_False),
myModified(Standard_False), myInParallel (Standard_False),
myStatus(0) myModified (Standard_False),
myStatus (0)
{ {
mymapedge.Clear(); mymapedge.Clear();
myancestors.Clear(); myancestors.Clear();
@ -63,24 +67,23 @@ BRepMesh_IncrementalMesh::BRepMesh_IncrementalMesh()
//function : BRepMesh_IncrementalMesh //function : BRepMesh_IncrementalMesh
//purpose : //purpose :
//======================================================================= //=======================================================================
BRepMesh_IncrementalMesh::BRepMesh_IncrementalMesh (const TopoDS_Shape& theShape,
BRepMesh_IncrementalMesh:: const Standard_Real theDeflection,
BRepMesh_IncrementalMesh(const TopoDS_Shape& S, const Standard_Boolean theRelative,
const Standard_Real D, const Standard_Real theAngle)
const Standard_Boolean Rel, : myRelative (theRelative),
const Standard_Real Ang) : myInParallel (Standard_False),
myRelative(Rel), myModified (Standard_False),
myModified(Standard_False), myStatus (0)
myStatus(0)
{ {
mymapedge.Clear(); mymapedge.Clear();
myancestors.Clear(); myancestors.Clear();
myDeflection = D; myDeflection = theDeflection;
myAngle = Ang; myAngle = theAngle;
myShape = S; myShape = theShape;
// //
Perform(); Perform();
} }
//======================================================================= //=======================================================================
@ -91,6 +94,24 @@ BRepMesh_IncrementalMesh::~BRepMesh_IncrementalMesh()
{ {
} }
//=======================================================================
//function : SetParallel
//purpose :
//=======================================================================
void BRepMesh_IncrementalMesh::SetParallel (const Standard_Boolean theInParallel)
{
myInParallel = theInParallel;
}
//=======================================================================
//function : IsParallel
//purpose :
//=======================================================================
Standard_Boolean BRepMesh_IncrementalMesh::IsParallel() const
{
return myInParallel;
}
//======================================================================= //=======================================================================
//function : Init //function : Init
//purpose : //purpose :
@ -173,7 +194,6 @@ Standard_Integer BRepMesh_IncrementalMesh::GetStatusFlags() const
//purpose : Builds the incremental mesh of the shape //purpose : Builds the incremental mesh of the shape
//======================================================================= //=======================================================================
void BRepMesh_IncrementalMesh::Update(const TopoDS_Shape& S) void BRepMesh_IncrementalMesh::Update(const TopoDS_Shape& S)
{ {
myModified = Standard_False; myModified = Standard_False;
TopExp_Explorer ex; TopExp_Explorer ex;
@ -209,14 +229,22 @@ void BRepMesh_IncrementalMesh::Update(const TopoDS_Shape& S)
aFaces.push_back (F); aFaces.push_back (F);
} }
// mesh faces in parallel threads using TBB if (myInParallel)
#ifdef HAVE_TBB {
if (Standard::IsReentrant()) #ifdef HAVE_TBB
// mesh faces in parallel threads using TBB
tbb::parallel_for_each (aFaces.begin(), aFaces.end(), *myMesh.operator->()); tbb::parallel_for_each (aFaces.begin(), aFaces.end(), *myMesh.operator->());
#else
// alternative parallelization not yet available
for (std::vector<TopoDS_Face>::iterator it(aFaces.begin()); it != aFaces.end(); it++)
myMesh->Process (*it);
#endif
}
else else
#endif {
for (std::vector<TopoDS_Face>::iterator it(aFaces.begin()); it != aFaces.end(); it++) for (std::vector<TopoDS_Face>::iterator it(aFaces.begin()); it != aFaces.end(); it++)
myMesh->Process (*it); myMesh->Process (*it);
}
// maillage des edges non contenues dans les faces : // maillage des edges non contenues dans les faces :
Standard_Real f, l, defedge; Standard_Real f, l, defedge;
@ -270,7 +298,8 @@ void BRepMesh_IncrementalMesh::Update(const TopoDS_Shape& S)
ex.Next(); ex.Next();
} }
} }
//======================================================================= //=======================================================================
//function : Update(edge) //function : Update(edge)
//purpose : Locate a correct discretisation if it exists //purpose : Locate a correct discretisation if it exists
@ -441,3 +470,47 @@ void BRepMesh_IncrementalMesh::Update(const TopoDS_Face& F)
} }
} }
} }
//=======================================================================
//function : Discret
//purpose :
//=======================================================================
Standard_Integer BRepMesh_IncrementalMesh::Discret (const TopoDS_Shape& theShape,
const Standard_Real theDeflection,
const Standard_Real theAngle,
BRepMesh_PDiscretRoot& theAlgo)
{
BRepMesh_IncrementalMesh* anAlgo = new BRepMesh_IncrementalMesh();
anAlgo->SetDeflection (theDeflection);
anAlgo->SetAngle (theAngle);
anAlgo->SetShape (theShape);
anAlgo->SetParallel (IS_IN_PARALLEL);
theAlgo = anAlgo;
return 0; // no error
}
//=======================================================================
//function : IsParallelDefault
//purpose :
//=======================================================================
Standard_Boolean BRepMesh_IncrementalMesh::IsParallelDefault()
{
#ifdef HAVE_TBB
return IS_IN_PARALLEL;
#else
// no alternative parallelization yet - flag has no meaning
return Standard_False;
#endif
}
//=======================================================================
//function : Discret
//purpose :
//=======================================================================
void BRepMesh_IncrementalMesh::SetParallelDefault (const Standard_Boolean theInParallel)
{
IS_IN_PARALLEL = theInParallel;
}
//! Export Mesh Plugin entry function
DISCRETPLUGIN(BRepMesh_IncrementalMesh)

View File

@ -0,0 +1,17 @@
#ifndef _BRepMesh_PluginEntryType_HeaderFile
#define _BRepMesh_PluginEntryType_HeaderFile
#ifndef _Standard_Real_HeaderFile
#include <Standard_Real.hxx>
#endif
class TopoDS_Shape;
class BRepMesh_DiscretRoot;
//! Type definition for plugin exported function
typedef Standard_Integer (*BRepMesh_PluginEntryType) (const TopoDS_Shape& theShape,
const Standard_Real theDeflection,
const Standard_Real theAngle,
BRepMesh_DiscretRoot*& theMeshAlgoInstance);
#endif //_BRepMesh_PluginEntryType_HeaderFile

View File

@ -1,3 +1,4 @@
BRepMesh_PluginEntryType.hxx
BRepMesh_PluginMacro.hxx BRepMesh_PluginMacro.hxx
BRepMesh_ClassifierPtr.hxx BRepMesh_ClassifierPtr.hxx
BRepMesh_CellFilter.hxx BRepMesh_CellFilter.hxx

View File

@ -11,6 +11,7 @@
#include <TColStd_MapIteratorOfMapOfAsciiString.hxx> #include <TColStd_MapIteratorOfMapOfAsciiString.hxx>
#include <BRepMesh_FactoryError.hxx> #include <BRepMesh_FactoryError.hxx>
#include <BRepMesh_DiscretRoot.hxx> #include <BRepMesh_DiscretRoot.hxx>
#include <BRepMesh_IncrementalMesh.hxx>
#include <Bnd_Box.hxx> #include <Bnd_Box.hxx>
#include <BRepMesh_PDiscretRoot.hxx> #include <BRepMesh_PDiscretRoot.hxx>
#include <DBRep.hxx> #include <DBRep.hxx>
@ -35,6 +36,7 @@ static Standard_Integer mpsetfunctionname (Draw_Interpretor& , Standard_Integer
static Standard_Integer mpgetfunctionname (Draw_Interpretor& , Standard_Integer , const char** ); static Standard_Integer mpgetfunctionname (Draw_Interpretor& , Standard_Integer , const char** );
static Standard_Integer mperror (Draw_Interpretor& , Standard_Integer , const char** ); static Standard_Integer mperror (Draw_Interpretor& , Standard_Integer , const char** );
static Standard_Integer mpincmesh (Draw_Interpretor& , Standard_Integer , const char** ); static Standard_Integer mpincmesh (Draw_Interpretor& , Standard_Integer , const char** );
static Standard_Integer mpparallel (Draw_Interpretor& , Standard_Integer , const char** );
static Standard_Integer triarea (Draw_Interpretor& , Standard_Integer , const char** ); static Standard_Integer triarea (Draw_Interpretor& , Standard_Integer , const char** );
static Standard_Integer tricheck (Draw_Interpretor& , Standard_Integer , const char** ); static Standard_Integer tricheck (Draw_Interpretor& , Standard_Integer , const char** );
@ -59,6 +61,8 @@ void MeshTest::PluginCommands(Draw_Interpretor& theCommands)
theCommands.Add("mpgetfunctionname", "use mpgetfunctionname", __FILE__, mpgetfunctionname , g); theCommands.Add("mpgetfunctionname", "use mpgetfunctionname", __FILE__, mpgetfunctionname , g);
theCommands.Add("mperror" , "use mperror" , __FILE__, mperror , g); theCommands.Add("mperror" , "use mperror" , __FILE__, mperror , g);
theCommands.Add("mpincmesh" , "use mpincmesh" , __FILE__, mpincmesh , g); theCommands.Add("mpincmesh" , "use mpincmesh" , __FILE__, mpincmesh , g);
theCommands.Add("mpparallel" , "mpparallel [toTurnOn] : show / set multi-threading flag for incremental mesh",
__FILE__, mpparallel, g);
theCommands.Add("triarea","shape [eps] (computes triangles and surface area)",__FILE__, triarea, g); theCommands.Add("triarea","shape [eps] (computes triangles and surface area)",__FILE__, triarea, g);
theCommands.Add("tricheck", "shape (checks triangulation of shape)", __FILE__, tricheck, g); theCommands.Add("tricheck", "shape (checks triangulation of shape)", __FILE__, tricheck, g);
@ -109,8 +113,10 @@ static Standard_Integer mpsetdefaultname (Draw_Interpretor& , Standard_Integer n
// //
aName=a[1]; aName=a[1];
// //
BRepMesh_DiscretFactory::Get().SetDefaultName(aName); if (BRepMesh_DiscretFactory::Get().SetDefaultName (aName))
printf(" *ready\n"); printf(" *ready\n");
else
printf(" *fault\n");
// //
return 0; return 0;
} }
@ -145,8 +151,10 @@ static Standard_Integer mpsetfunctionname (Draw_Interpretor& , Standard_Integer
// //
aName=a[1]; aName=a[1];
// //
BRepMesh_DiscretFactory::Get().SetFunctionName(aName); if (BRepMesh_DiscretFactory::Get().SetFunctionName (aName))
printf(" *ready\n"); printf(" *ready\n");
else
printf(" *fault\n");
// //
return 0; return 0;
} }
@ -191,11 +199,8 @@ static Standard_Integer mperror (Draw_Interpretor& , Standard_Integer n, const c
//======================================================================= //=======================================================================
static Standard_Integer mpincmesh (Draw_Interpretor& , Standard_Integer n, const char** a) static Standard_Integer mpincmesh (Draw_Interpretor& , Standard_Integer n, const char** a)
{ {
Standard_Boolean bIsDone;
Standard_Real aDeflection, aAngle; Standard_Real aDeflection, aAngle;
TopoDS_Shape aS; TopoDS_Shape aS;
BRepMesh_FactoryError aErr;
BRepMesh_PDiscretRoot pAlgo;
// //
if (n<3) { if (n<3) {
printf(" use mpincmesh s deflection [angle]\n"); printf(" use mpincmesh s deflection [angle]\n");
@ -214,23 +219,25 @@ static Standard_Integer mpincmesh (Draw_Interpretor& , Standard_Integer n, const
aAngle=atof(a[3]); aAngle=atof(a[3]);
} }
// //
pAlgo=BRepMesh_DiscretFactory::Get().Discret(aS, Handle(BRepMesh_DiscretRoot) aMeshAlgo = BRepMesh_DiscretFactory::Get().Discret (aS,
aDeflection, aDeflection,
aAngle); aAngle);
// //
aErr=BRepMesh_DiscretFactory::Get().ErrorStatus(); BRepMesh_FactoryError aErr = BRepMesh_DiscretFactory::Get().ErrorStatus();
if (aErr!=BRepMesh_FE_NOERROR) { if (aErr != BRepMesh_FE_NOERROR)
{
printf(" *Factory::Get().ErrorStatus()=%d\n", (int)aErr); printf(" *Factory::Get().ErrorStatus()=%d\n", (int)aErr);
} }
// //
if (!pAlgo) { if (aMeshAlgo.IsNull())
{
printf(" *Can not create the algo\n"); printf(" *Can not create the algo\n");
return 0; return 0;
} }
// //
pAlgo->Perform(); aMeshAlgo->Perform();
bIsDone=pAlgo->IsDone(); if (!aMeshAlgo->IsDone())
if (!bIsDone) { {
printf(" *Not done\n"); printf(" *Not done\n");
} }
// //
@ -404,3 +411,19 @@ static Standard_Integer tricheck (Draw_Interpretor& di, int n, const char ** a)
<< " Free_nodes " << nbFreeNodes << "\n"; << " Free_nodes " << nbFreeNodes << "\n";
return 0; return 0;
} }
//=======================================================================
//function : mpparallel
//purpose :
//=======================================================================
static int mpparallel (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{
if (argc == 2)
{
Standard_Boolean isParallelOn = atoi (argv[1]) == 1;
BRepMesh_IncrementalMesh::SetParallelDefault (isParallelOn);
}
std::cout << "Incremental Mesh, multi-threading "
<< (BRepMesh_IncrementalMesh::IsParallelDefault() ? "ON\n" : "OFF\n");
return 0;
}

View File

@ -12,7 +12,7 @@ is
exception Failure inherits Failure from Standard; exception Failure inherits Failure from Standard;
private class MapOfFunctions instantiates DataMap from TCollection(AsciiString from TCollection ,Function from OSD, AsciiString from TCollection); class MapOfFunctions instantiates DataMap from TCollection(AsciiString from TCollection ,Function from OSD, AsciiString from TCollection);
Load(aGUID: GUID from Standard) returns Transient from Standard Load(aGUID: GUID from Standard) returns Transient from Standard

View File

@ -316,19 +316,20 @@ void Prs3d_ShadedShape::Add(const Handle (Prs3d_Presentation)& aPresentation,
} }
} }
Standard_Real aDeflection = GetDeflection(aShape, aDrawer); Standard_Real aDeflection = GetDeflection(aShape, aDrawer);
//using of plugin
// Check if it is possible to avoid unnecessary recomputation // Check if it is possible to avoid unnecessary recomputation
// of shape triangulation // of shape triangulation
if( !BRepTools::Triangulation(aShape, aDeflection) ) if (!BRepTools::Triangulation (aShape, aDeflection))
{ {
BRepTools::Clean(aShape); BRepTools::Clean (aShape);
BRepMesh_PDiscretRoot pAlgo; // retrieve meshing tool from Factory
pAlgo=BRepMesh_DiscretFactory::Get().Discret(aShape, Handle(BRepMesh_DiscretRoot) aMeshAlgo = BRepMesh_DiscretFactory::Get().Discret (aShape,
aDeflection, aDeflection,
aDrawer->HLRAngle()); aDrawer->HLRAngle());
if (pAlgo) if (!aMeshAlgo.IsNull())
pAlgo->Perform(); aMeshAlgo->Perform();
} }
ShadeFromShape(aShape, aDeflection, Standard_True, aPresentation, aDrawer); ShadeFromShape(aShape, aDeflection, Standard_True, aPresentation, aDrawer);
} }