1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-29 14:00:49 +03:00

0024157: Parallelization of assembly part of BO

Patch 06

I.1. class Bnd_Box2d
- method:
inline Standard_Real Bnd_Box2d::SquareExtent() const
has been added.
Purpose : The method returns the squared diagonal of the bounding box.

I.3. class BOPCol_BoxBndTree
has been added.
Purpose : The class is the instantiation of the algorithm of unbalanced binary tree
of overlapped bounding boxes 3D.

I.4. class BOPCol_Box2DBndTree
has been added.
Purpose : The class is the instantiation of the algorithm of unbalanced binary tree
of overlapped bounding boxes 2D.

I.5. class BOPAlgo_Algo
- method:
void BOPAlgo_Algo::SetRunParallel(const Standard_Boolean theFlag)
has been added.
Purpose: Set the flag of parallel processing
     if <theFlag> is true  the parallel processing is switched on
     if <theFlag> is false the parallel processing is switched off

- method:
Standard_Boolean BOPAlgo_Algo::RunParallel()const
has been added
Purpose: Returns the flag of parallel processing

II.1. class BOPAlgo_Builder
- method:
void BOPAlgo_Builder::SetRunParallel(const Standard_Boolean theFlag)
has been removed due to I.5.

- method:
Standard_Boolean BOPAlgo_Builder::RunParallel()const
has been removed due to I.5

II.2. class BOPDS_BoxBndTree
has been removed due to I.3

II.3. classes
BOPDS_Iterator,
BOPDS_IteratorSI,
BOPDS_SubIterator
BOPAlgo_PaveFiller,
BOPAlgo_Builder
the calls to BOPDS_BoxBndTree have been changed to
the calls to BOPCol_BoxBndTree
due to I.3

II.4. class BOPAlgo_BuilderFace
- method:
void BOPAlgo_BuilderFace::PerformLoops()
the changes that provide parallel run the  WireSplitter algorithm have been done.

- method:
void BOPAlgo_BuilderFace::PerformAreas()
the classification the grows and holes has been done using
the algorithm of unbalanced binary tree of overlapped bounding boxes

II.5. class BOPAlgo_WireSplitter
- method:
void BOPAlgo_WireSplitter::SplitBlock(const TopoDS_Face& myFace,
			          BOPTools_ConnexityBlock& aCB)
the method is transferred to the static, the signature of the method have been changed

- method:
void BOPAlgo_WireSplitter::MakeWires()
the changes to provide parallel run the SplitBlock algorithm have been done
This commit is contained in:
pkv
2014-01-10 08:29:02 +04:00
committed by bugmaster
parent 15cea4ef7a
commit db8e4b9aa6
24 changed files with 667 additions and 295 deletions

View File

@@ -1,16 +1,21 @@
// Created by: Peter KURNEV
// Copyright (c) 1999-2014 OPEN CASCADE SAS
// Copyright (c) 1999-2012 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
// The content of this file is subject to the Open CASCADE Technology Public
// License Version 6.5 (the "License"). You may not use the content of this file
// except in compliance with the License. Please obtain a copy of the License
// at http://www.opencascade.org and read it completely before using this file.
//
// This library is free software; you can redistribute it and / or modify it
// under the terms of the GNU Lesser General Public version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
// The Original Code and all software distributed under the License is
// distributed on an "AS IS" basis, without warranty of any kind, and the
// Initial Developer hereby disclaims all such warranties, including without
// limitation, any warranties of merchantability, fitness for a particular
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
#include <BOPAlgo_WireSplitter.ixx>
@@ -27,6 +32,8 @@
#include <BOPCol_IndexedMapOfShape.hxx>
#include <BOPCol_MapOfShape.hxx>
#include <BOPCol_IndexedDataMapOfShapeListOfShape.hxx>
#include <BOPCol_TBB.hxx>
#include <BOPCol_NCVector.hxx>
#include <BOPTools.hxx>
@@ -35,7 +42,7 @@
//function :
//purpose :
//=======================================================================
BOPAlgo_WireSplitter::BOPAlgo_WireSplitter()
BOPAlgo_WireSplitter::BOPAlgo_WireSplitter()
:
BOPAlgo_Algo(),
myWES(NULL),
@@ -46,7 +53,8 @@
//function :
//purpose :
//=======================================================================
BOPAlgo_WireSplitter::BOPAlgo_WireSplitter(const Handle(NCollection_BaseAllocator)& theAllocator)
BOPAlgo_WireSplitter::BOPAlgo_WireSplitter
(const Handle(NCollection_BaseAllocator)& theAllocator)
:
BOPAlgo_Algo(theAllocator),
myWES(NULL),
@@ -57,14 +65,14 @@
//function : ~
//purpose :
//=======================================================================
BOPAlgo_WireSplitter::~BOPAlgo_WireSplitter()
BOPAlgo_WireSplitter::~BOPAlgo_WireSplitter()
{
}
//=======================================================================
//function : SetWES
//purpose :
//=======================================================================
void BOPAlgo_WireSplitter::SetWES(const BOPAlgo_WireEdgeSet& theWES)
void BOPAlgo_WireSplitter::SetWES(const BOPAlgo_WireEdgeSet& theWES)
{
myWES=(BOPAlgo_WireEdgeSet*)&theWES;
}
@@ -72,7 +80,7 @@
//function : WES
//purpose :
//=======================================================================
BOPAlgo_WireEdgeSet& BOPAlgo_WireSplitter::WES()
BOPAlgo_WireEdgeSet& BOPAlgo_WireSplitter::WES()
{
return *myWES;
}
@@ -80,7 +88,7 @@
// function: CheckData
// purpose:
//=======================================================================
void BOPAlgo_WireSplitter::CheckData()
void BOPAlgo_WireSplitter::CheckData()
{
myErrorStatus=0;
if (!myWES) {
@@ -92,7 +100,7 @@
//function : Perform
//purpose :
//=======================================================================
void BOPAlgo_WireSplitter::Perform()
void BOPAlgo_WireSplitter::Perform()
{
myErrorStatus=0;
//
@@ -104,43 +112,12 @@
MakeConnexityBlocks();
MakeWires();
}
//=======================================================================
//function : MakeWires
//purpose :
//=======================================================================
void BOPAlgo_WireSplitter::MakeWires()
{
Standard_Boolean bIsRegular;
TopoDS_Wire aW;
BOPTools_ListIteratorOfListOfConnexityBlock aItCB;
BOPCol_ListIteratorOfListOfShape aIt;
//
aItCB.Initialize(myLCB);
for (; aItCB.More(); aItCB.Next()) {
BOPTools_ConnexityBlock& aCB=aItCB.ChangeValue();
bIsRegular=aCB.IsRegular();
if (bIsRegular) {
BOPCol_ListOfShape& aLE=aCB.ChangeShapes();
BOPAlgo_WireSplitter::MakeWire(aLE, aW);
myWES->AddShape(aW);
}
else {
SplitBlock(aCB);
//
const BOPCol_ListOfShape& aLW=aCB.Loops();
aIt.Initialize(aLW);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aWx=aIt.Value();
myWES->AddShape(aWx);
}
}
}
}
//=======================================================================
//function : MakeConnexityBlocks
//purpose :
//=======================================================================
void BOPAlgo_WireSplitter::MakeConnexityBlocks()
void BOPAlgo_WireSplitter::MakeConnexityBlocks()
{
Standard_Boolean bRegular, bClosed;
Standard_Integer i, j, aNbV, aNbVS, aNbVP, k;
@@ -280,3 +257,105 @@
myLCB.Append(aCB);
}
}
/////////////////////////////////////////////////////////////////////////
typedef BOPCol_NCVector<BOPTools_ConnexityBlock> \
BOPTools_VectorOfConnexityBlock;
//=======================================================================
//class : WireSplitterFunctor
//purpose :
//=======================================================================
class BOPAlgo_WireSplitterFunctor {
protected:
TopoDS_Face myFace;
BOPTools_VectorOfConnexityBlock* myPVCB;
//
public:
//
BOPAlgo_WireSplitterFunctor(const TopoDS_Face& aF,
BOPTools_VectorOfConnexityBlock& aVCB)
: myFace(aF), myPVCB(&aVCB) {
}
//
void operator()( const flexible_range<Standard_Size>& aBR ) const{
Standard_Size i, iBeg, iEnd;
//
BOPTools_VectorOfConnexityBlock& aVCB=*myPVCB;
//
iBeg=aBR.begin();
iEnd=aBR.end();
for(i=iBeg; i!=iEnd; ++i) {
BOPTools_ConnexityBlock& aCB=aVCB((Standard_Integer)i);
//
BOPAlgo_WireSplitter::SplitBlock(myFace, aCB);
}
}
};
//=======================================================================
//class : BOPAlgo_WireSplitterCnt
//purpose :
//=======================================================================
class BOPAlgo_WireSplitterCnt {
public:
//-------------------------------
// Perform
Standard_EXPORT
static void Perform(const Standard_Boolean bRunParallel,
const TopoDS_Face& aF,
BOPTools_VectorOfConnexityBlock& aVCB) {
//
BOPAlgo_WireSplitterFunctor aWSF(aF, aVCB);
Standard_Size aNbVCB=aVCB.Extent();
//
if (bRunParallel) {
flexible_for(flexible_range<Standard_Size>(0,aNbVCB), aWSF);
}
else {
aWSF.operator()(flexible_range<Standard_Size>(0,aNbVCB));
}
}
//
};
//=======================================================================
//function : MakeWires
//purpose :
//=======================================================================
void BOPAlgo_WireSplitter::MakeWires()
{
Standard_Boolean bIsRegular;
Standard_Integer aNbVCB, k;
TopoDS_Wire aW;
BOPTools_ListIteratorOfListOfConnexityBlock aItCB;
BOPCol_ListIteratorOfListOfShape aIt;
BOPTools_VectorOfConnexityBlock aVCB;
//
aItCB.Initialize(myLCB);
for (; aItCB.More(); aItCB.Next()) {
BOPTools_ConnexityBlock& aCB=aItCB.ChangeValue();
bIsRegular=aCB.IsRegular();
if (bIsRegular) {
BOPCol_ListOfShape& aLE=aCB.ChangeShapes();
BOPAlgo_WireSplitter::MakeWire(aLE, aW);
myWES->AddShape(aW);
}
else {
aVCB.Append(aCB);
}
}
//
aNbVCB=aVCB.Extent();
const TopoDS_Face& aF=myWES->Face();
//===================================================
BOPAlgo_WireSplitterCnt::Perform(myRunParallel, aF, aVCB);
//===================================================
for (k=0; k<aNbVCB; ++k) {
const BOPTools_ConnexityBlock& aCB=aVCB(k);
const BOPCol_ListOfShape& aLW=aCB.Loops();
aIt.Initialize(aLW);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aWx=aIt.Value();
myWES->AddShape(aWx);
}
}
}