geom/src/GEOMAlgo/GEOMAlgo_Builder.cxx
admin 1a19468ce8 This commit was generated by cvs2git to create tag 'StableState1'.
Sprout from BR_PartAlgo_V322 2006-09-07 08:59:07 UTC admin <salome-admin@opencascade.com> 'This commit was generated by cvs2git to create branch 'BR_PartAlgo_V322'.'
Cherrypick from BR_PartAlgo_V322 2006-10-20 07:23:31 UTC skl <skl@opencascade.com> 'Add new files for new version of PartitionAlgo.':
    src/GEOMAlgo/GEOMAlgo_Builder.cdl
    src/GEOMAlgo/GEOMAlgo_Builder.cxx
    src/GEOMAlgo/GEOMAlgo_Builder.hxx
    src/GEOMAlgo/GEOMAlgo_Builder.ixx
    src/GEOMAlgo/GEOMAlgo_Builder.jxx
    src/GEOMAlgo/GEOMAlgo_BuilderArea.cdl
    src/GEOMAlgo/GEOMAlgo_BuilderArea.cxx
    src/GEOMAlgo/GEOMAlgo_BuilderArea.hxx
    src/GEOMAlgo/GEOMAlgo_BuilderArea.ixx
    src/GEOMAlgo/GEOMAlgo_BuilderArea.jxx
    src/GEOMAlgo/GEOMAlgo_BuilderFace.cdl
    src/GEOMAlgo/GEOMAlgo_BuilderFace.cxx
    src/GEOMAlgo/GEOMAlgo_BuilderFace.hxx
    src/GEOMAlgo/GEOMAlgo_BuilderFace.ixx
    src/GEOMAlgo/GEOMAlgo_BuilderFace.jxx
    src/GEOMAlgo/GEOMAlgo_BuilderShape.cdl
    src/GEOMAlgo/GEOMAlgo_BuilderShape.cxx
    src/GEOMAlgo/GEOMAlgo_BuilderShape.hxx
    src/GEOMAlgo/GEOMAlgo_BuilderShape.ixx
    src/GEOMAlgo/GEOMAlgo_BuilderShape.jxx
    src/GEOMAlgo/GEOMAlgo_BuilderSolid.cdl
    src/GEOMAlgo/GEOMAlgo_BuilderSolid.cxx
    src/GEOMAlgo/GEOMAlgo_BuilderSolid.hxx
    src/GEOMAlgo/GEOMAlgo_BuilderSolid.ixx
    src/GEOMAlgo/GEOMAlgo_BuilderSolid.jxx
    src/GEOMAlgo/GEOMAlgo_BuilderTools.cdl
    src/GEOMAlgo/GEOMAlgo_BuilderTools.cxx
    src/GEOMAlgo/GEOMAlgo_BuilderTools.hxx
    src/GEOMAlgo/GEOMAlgo_BuilderTools.ixx
    src/GEOMAlgo/GEOMAlgo_BuilderTools.jxx
    src/GEOMAlgo/GEOMAlgo_Builder_0.cxx
    src/GEOMAlgo/GEOMAlgo_Builder_1.cxx
    src/GEOMAlgo/GEOMAlgo_Builder_2.cxx
    src/GEOMAlgo/GEOMAlgo_Builder_3.cxx
    src/GEOMAlgo/GEOMAlgo_Builder_4.cxx
    src/GEOMAlgo/GEOMAlgo_DataMapIteratorOfDataMapOfRealListOfShape.hxx
    src/GEOMAlgo/GEOMAlgo_DataMapIteratorOfDataMapOfRealListOfShape_0.cxx
    src/GEOMAlgo/GEOMAlgo_DataMapIteratorOfDataMapOfShapeReal.hxx
    src/GEOMAlgo/GEOMAlgo_DataMapIteratorOfDataMapOfShapeReal_0.cxx
    src/GEOMAlgo/GEOMAlgo_DataMapIteratorOfDataMapOfShapeShapeSet.hxx
    src/GEOMAlgo/GEOMAlgo_DataMapIteratorOfDataMapOfShapeShapeSet_0.cxx
    src/GEOMAlgo/GEOMAlgo_DataMapNodeOfDataMapOfRealListOfShape.hxx
    src/GEOMAlgo/GEOMAlgo_DataMapNodeOfDataMapOfRealListOfShape_0.cxx
    src/GEOMAlgo/GEOMAlgo_DataMapNodeOfDataMapOfShapeReal.hxx
    src/GEOMAlgo/GEOMAlgo_DataMapNodeOfDataMapOfShapeReal_0.cxx
    src/GEOMAlgo/GEOMAlgo_DataMapNodeOfDataMapOfShapeShapeSet.hxx
    src/GEOMAlgo/GEOMAlgo_DataMapNodeOfDataMapOfShapeShapeSet_0.cxx
    src/GEOMAlgo/GEOMAlgo_DataMapOfRealListOfShape.hxx
    src/GEOMAlgo/GEOMAlgo_DataMapOfRealListOfShape_0.cxx
    src/GEOMAlgo/GEOMAlgo_DataMapOfShapeReal.hxx
    src/GEOMAlgo/GEOMAlgo_DataMapOfShapeReal_0.cxx
    src/GEOMAlgo/GEOMAlgo_DataMapOfShapeShapeSet.hxx
    src/GEOMAlgo/GEOMAlgo_DataMapOfShapeShapeSet_0.cxx
    src/GEOMAlgo/GEOMAlgo_PWireEdgeSet.hxx
    src/GEOMAlgo/GEOMAlgo_ShapeSet.cdl
    src/GEOMAlgo/GEOMAlgo_ShapeSet.cxx
    src/GEOMAlgo/GEOMAlgo_ShapeSet.hxx
    src/GEOMAlgo/GEOMAlgo_ShapeSet.ixx
    src/GEOMAlgo/GEOMAlgo_ShapeSet.jxx
    src/GEOMAlgo/GEOMAlgo_Splitter.cdl
    src/GEOMAlgo/GEOMAlgo_Splitter.cxx
    src/GEOMAlgo/GEOMAlgo_Splitter.hxx
    src/GEOMAlgo/GEOMAlgo_Splitter.ixx
    src/GEOMAlgo/GEOMAlgo_Splitter.jxx
    src/GEOMAlgo/GEOMAlgo_Tools3D.cdl
    src/GEOMAlgo/GEOMAlgo_Tools3D.cxx
    src/GEOMAlgo/GEOMAlgo_Tools3D.hxx
    src/GEOMAlgo/GEOMAlgo_Tools3D.ixx
    src/GEOMAlgo/GEOMAlgo_Tools3D.jxx
    src/GEOMAlgo/GEOMAlgo_WESCorrector.cdl
    src/GEOMAlgo/GEOMAlgo_WESCorrector.cxx
    src/GEOMAlgo/GEOMAlgo_WESCorrector.hxx
    src/GEOMAlgo/GEOMAlgo_WESCorrector.ixx
    src/GEOMAlgo/GEOMAlgo_WESCorrector.jxx
    src/GEOMAlgo/GEOMAlgo_WireEdgeSet.cdl
    src/GEOMAlgo/GEOMAlgo_WireEdgeSet.cxx
    src/GEOMAlgo/GEOMAlgo_WireEdgeSet.hxx
    src/GEOMAlgo/GEOMAlgo_WireEdgeSet.ixx
    src/GEOMAlgo/GEOMAlgo_WireEdgeSet.jxx
    src/GEOMAlgo/GEOMAlgo_WireSplitter.cdl
    src/GEOMAlgo/GEOMAlgo_WireSplitter.cxx
    src/GEOMAlgo/GEOMAlgo_WireSplitter.hxx
    src/GEOMAlgo/GEOMAlgo_WireSplitter.ixx
    src/GEOMAlgo/GEOMAlgo_WireSplitter.jxx
    src/GEOMAlgo/Handle_GEOMAlgo_DataMapNodeOfDataMapOfRealListOfShape.hxx
    src/GEOMAlgo/Handle_GEOMAlgo_DataMapNodeOfDataMapOfShapeReal.hxx
    src/GEOMAlgo/Handle_GEOMAlgo_DataMapNodeOfDataMapOfShapeShapeSet.hxx
    src/NMTDS/Handle_NMTDS_ListNodeOfListOfPassKey.hxx
    src/NMTDS/Handle_NMTDS_ListNodeOfListOfPassKeyBoolean.hxx
    src/NMTDS/Handle_NMTDS_StdMapNodeOfMapOfPassKey.hxx
    src/NMTDS/Handle_NMTDS_StdMapNodeOfMapOfPassKeyBoolean.hxx
    src/NMTDS/NMTDS_Iterator.cdl
    src/NMTDS/NMTDS_Iterator.cxx
    src/NMTDS/NMTDS_Iterator.hxx
    src/NMTDS/NMTDS_Iterator.ixx
    src/NMTDS/NMTDS_Iterator.jxx
    src/NMTDS/NMTDS_ListIteratorOfListOfPassKey.hxx
    src/NMTDS/NMTDS_ListIteratorOfListOfPassKeyBoolean.hxx
    src/NMTDS/NMTDS_ListIteratorOfListOfPassKeyBoolean_0.cxx
    src/NMTDS/NMTDS_ListIteratorOfListOfPassKey_0.cxx
    src/NMTDS/NMTDS_ListNodeOfListOfPassKey.hxx
    src/NMTDS/NMTDS_ListNodeOfListOfPassKeyBoolean.hxx
    src/NMTDS/NMTDS_ListNodeOfListOfPassKeyBoolean_0.cxx
    src/NMTDS/NMTDS_ListNodeOfListOfPassKey_0.cxx
    src/NMTDS/NMTDS_ListOfPassKey.hxx
    src/NMTDS/NMTDS_ListOfPassKeyBoolean.hxx
    src/NMTDS/NMTDS_ListOfPassKeyBoolean_0.cxx
    src/NMTDS/NMTDS_ListOfPassKey_0.cxx
    src/NMTDS/NMTDS_MapIteratorOfMapOfPassKey.hxx
    src/NMTDS/NMTDS_MapIteratorOfMapOfPassKeyBoolean.hxx
    src/NMTDS/NMTDS_MapIteratorOfMapOfPassKeyBoolean_0.cxx
    src/NMTDS/NMTDS_MapIteratorOfMapOfPassKey_0.cxx
    src/NMTDS/NMTDS_MapOfPassKey.hxx
    src/NMTDS/NMTDS_MapOfPassKeyBoolean.hxx
    src/NMTDS/NMTDS_MapOfPassKeyBoolean_0.cxx
    src/NMTDS/NMTDS_MapOfPassKey_0.cxx
    src/NMTDS/NMTDS_PassKey.cdl
    src/NMTDS/NMTDS_PassKey.cxx
    src/NMTDS/NMTDS_PassKey.hxx
    src/NMTDS/NMTDS_PassKey.ixx
    src/NMTDS/NMTDS_PassKey.jxx
    src/NMTDS/NMTDS_PassKeyBoolean.cdl
    src/NMTDS/NMTDS_PassKeyBoolean.cxx
    src/NMTDS/NMTDS_PassKeyBoolean.hxx
    src/NMTDS/NMTDS_PassKeyBoolean.ixx
    src/NMTDS/NMTDS_PassKeyBoolean.jxx
    src/NMTDS/NMTDS_PassKeyMapHasher.cdl
    src/NMTDS/NMTDS_PassKeyMapHasher.cxx
    src/NMTDS/NMTDS_PassKeyMapHasher.hxx
    src/NMTDS/NMTDS_PassKeyMapHasher.ixx
    src/NMTDS/NMTDS_PassKeyMapHasher.jxx
    src/NMTDS/NMTDS_StdMapNodeOfMapOfPassKey.hxx
    src/NMTDS/NMTDS_StdMapNodeOfMapOfPassKeyBoolean.hxx
    src/NMTDS/NMTDS_StdMapNodeOfMapOfPassKeyBoolean_0.cxx
    src/NMTDS/NMTDS_StdMapNodeOfMapOfPassKey_0.cxx
    src/NMTTools/NMTDS_Iterator.hxx
2006-10-20 07:23:33 +00:00

390 lines
9.0 KiB
C++
Executable File

// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// File: GEOMAlgo_Builder.cxx
// Created:
// Author: Peter KURNEV
#include <GEOMAlgo_Builder.ixx>
#include <TopAbs_ShapeEnum.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Compound.hxx>
#include <TopoDS_Iterator.hxx>
#include <BRep_Builder.hxx>
#include <TopTools_MapOfShape.hxx>
#include <TopTools_ListOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <BOP_CorrectTolerances.hxx>
#include <NMTTools_DSFiller.hxx>
#include <BRepLib.hxx>
//=======================================================================
//function :
//purpose :
//=======================================================================
GEOMAlgo_Builder::GEOMAlgo_Builder()
:
GEOMAlgo_BuilderShape()
{
myNbTypes=9;
myDSFiller=NULL;
}
//=======================================================================
//function : ~
//purpose :
//=======================================================================
GEOMAlgo_Builder::~GEOMAlgo_Builder()
{
}
//=======================================================================
//function : AddCompound
//purpose :
//=======================================================================
void GEOMAlgo_Builder::AddCompound(const TopoDS_Shape& theShape)
{
TopoDS_Iterator aIt;
//
aIt.Initialize(theShape);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aS=aIt.Value();
AddShape(aS);
}
}
//=======================================================================
//function : AddShape
//purpose :
//=======================================================================
void GEOMAlgo_Builder::AddShape(const TopoDS_Shape& theShape)
{
if (myMapFence.Add(theShape)) {
myShapes.Append(theShape);
}
}
//=======================================================================
//function : Shapes
//purpose :
//=======================================================================
const TopTools_ListOfShape& GEOMAlgo_Builder::Shapes()const
{
return myShapes;
}
//=======================================================================
//function : Clear
//purpose :
//=======================================================================
void GEOMAlgo_Builder::Clear()
{
myShapes.Clear();
ClearInternals();
}
//=======================================================================
//function : ClearInternals
//purpose :
//=======================================================================
void GEOMAlgo_Builder::ClearInternals()
{
Standard_Integer i;
//
for (i=0; i<myNbTypes; ++i){
myShapes1[i].Clear();
}
myImages.Clear();
//
myInParts.Clear();
mySplitFaces.Clear();
mySameDomainShapes.Clear();
myDraftSolids.Clear();
myMapFence.Clear();
}
//=======================================================================
//function : Prepare
//purpose :
//=======================================================================
void GEOMAlgo_Builder::Prepare()
{
myErrorStatus=0;
//
Standard_Integer aNb;
BRep_Builder aBB;
TopoDS_Compound aC;
TopTools_ListIteratorOfListOfShape aIt;
//
aNb=myShapes.Extent();
if (aNb<2) {
myErrorStatus=10; // No shapes to process
return;
}
//
// 1. myShape is empty compound
aBB.MakeCompound(aC);
myShape=aC;
//
// 2. myShapes1
aIt.Initialize(myShapes);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aS=aIt.Value();
AddShape1(aS);
}
}
//=======================================================================
//function : PostTreat
//purpose :
//=======================================================================
void GEOMAlgo_Builder::PostTreat()
{
Standard_Integer aNbS;
TopoDS_Iterator aIt;
TopTools_ListOfShape aLS;
//
aIt.Initialize(myShape);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aS=aIt.Value();
aLS.Append(aS);
}
aNbS=aLS.Extent();
if (aNbS==1) {
myShape=aLS.First();
}
BRepLib::SameParameter(myShape, 1.e-7, Standard_True);
}
//=======================================================================
//function : AddShape1
//purpose :
//=======================================================================
void GEOMAlgo_Builder::AddShape1(const TopoDS_Shape& theShape)
{
Standard_Integer iType;
TopAbs_ShapeEnum aType;
TopoDS_Iterator aIt;
TopTools_MapOfShape aM;
//
aType=theShape.ShapeType();
if (aType==TopAbs_COMPOUND) {
aIt.Initialize(theShape);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aS=aIt.Value();
AddShape1(aS);
}
}
//
iType=(Standard_Integer)aType;
if (aM.Add(theShape)) {
myShapes1[iType].Append(theShape);
}
}
//=======================================================================
//function : BuildResult
//purpose :
//=======================================================================
void GEOMAlgo_Builder::BuildResult(const TopAbs_ShapeEnum theType)
{
myErrorStatus=0;
//
TopAbs_ShapeEnum aType;
BRep_Builder aBB;
TopTools_MapOfShape aM;
TopTools_ListIteratorOfListOfShape aIt, aItIm;
//
aIt.Initialize(myShapes);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aS=aIt.Value();
aType=aS.ShapeType();
if (aType==theType) {
if (myImages.HasImage(aS)){
const TopTools_ListOfShape& aLSIm=myImages.Image(aS);
aItIm.Initialize(aLSIm);
for (; aItIm.More(); aItIm.Next()) {
const TopoDS_Shape& aSIm=aItIm.Value();
if (aM.Add(aSIm)) {
aBB.Add(myShape, aSIm);
}
}
}
else {
if (aM.Add(aS)) {
aBB.Add(myShape, aS);
}
}
}
}
}
//=======================================================================
//function : Perform
//purpose :
//=======================================================================
void GEOMAlgo_Builder::Perform()
{
myErrorStatus=0;
//
BRep_Builder aBB;
TopoDS_Compound aCS;
TopTools_ListIteratorOfListOfShape aIt;
//
aBB.MakeCompound(aCS);
//
aIt.Initialize(myShapes);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aS=aIt.Value();
aBB.Add(aCS, aS);
}
//
NMTTools_DSFiller* pDSF=new NMTTools_DSFiller;
//
pDSF->SetCompositeShape(aCS);
pDSF->Perform();
//
PerformWithFiller(*pDSF);
}
//=======================================================================
//function : PerformWithFiller
//purpose :
//=======================================================================
void GEOMAlgo_Builder::PerformWithFiller(const NMTTools_DSFiller& theDSF)
{
myErrorStatus=0;
//
Standard_Boolean bIsDone;
//
// 0. myDSFiller
myDSFiller=(NMTTools_DSFiller *)&theDSF;
//
bIsDone=myDSFiller->IsDone();
if (!bIsDone) {
myErrorStatus=2; // DSFiller is failed
return;
}
//
// 1. Clear Internal fields
ClearInternals();
//
// 2. Prepare
Prepare();
if (myErrorStatus) {
return;
}
//
// 3. Fill Images
//
// 3.1 Vertices
FillImagesVertices();
if (myErrorStatus) {
return;
}
//
BuildResult(TopAbs_VERTEX);
if (myErrorStatus) {
return;
}
// 3.2 Edges
FillImagesEdges();
if (myErrorStatus) {
return;
}
BuildResult(TopAbs_EDGE);
if (myErrorStatus) {
return;
}
// 3.3 Wires
FillImagesContainers(TopAbs_WIRE);
if (myErrorStatus) {
return;
}
BuildResult(TopAbs_WIRE);
if (myErrorStatus) {
return;
}
// 3.4 Faces
FillImagesFaces();
if (myErrorStatus) {
return;
}
BuildResult(TopAbs_FACE);
if (myErrorStatus) {
return;
}
// 3.5 Shells
FillImagesContainers(TopAbs_SHELL);
if (myErrorStatus) {
return;
}
BuildResult(TopAbs_SHELL);
if (myErrorStatus) {
return;
}
// 3.6 Solids
FillImagesSolids();
if (myErrorStatus) {
return;
}
BuildResult(TopAbs_SOLID);
if (myErrorStatus) {
return;
}
// 3.7 CompSolids
FillImagesContainers(TopAbs_COMPSOLID);
if (myErrorStatus) {
return;
}
BuildResult(TopAbs_COMPSOLID);
if (myErrorStatus) {
return;
}
// 3.8 Compounds
FillImagesContainers(TopAbs_COMPOUND);
if (myErrorStatus) {
return;
}
BuildResult(TopAbs_COMPOUND);
if (myErrorStatus) {
return;
}
//
// 4.History
PrepareHistory();
//
// 5 Post-treatment
PostTreat();
}
//
// myErrorStatus
//
// 0 - Ok
// 1 - The object is just initialized
// 2 - DSFiller is failed
// 10 - No shapes to process
// 30 - SolidBuilder failed