2012-08-09 13:58:02 +06:00
|
|
|
// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
|
2008-03-07 12:45:34 +05:00
|
|
|
//
|
2012-08-09 13:58:02 +06:00
|
|
|
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
|
|
|
|
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
|
2008-03-07 12:45:34 +05:00
|
|
|
//
|
2012-08-09 13:58:02 +06:00
|
|
|
// 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.
|
2009-02-13 17:16:39 +05:00
|
|
|
//
|
2012-08-09 13:58:02 +06:00
|
|
|
// 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.
|
2009-02-13 17:16:39 +05:00
|
|
|
//
|
2012-08-09 13:58:02 +06:00
|
|
|
// 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
|
2009-02-13 17:16:39 +05:00
|
|
|
//
|
2012-08-09 13:58:02 +06:00
|
|
|
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
2009-02-13 17:16:39 +05:00
|
|
|
//
|
2012-08-09 13:58:02 +06:00
|
|
|
// File : GEOMAlgo_Builder_3.cxx
|
|
|
|
// Created :
|
|
|
|
// Author : Peter KURNEV
|
|
|
|
|
2008-03-07 12:45:34 +05:00
|
|
|
#include <GEOMAlgo_Builder.hxx>
|
|
|
|
|
|
|
|
#include <TopAbs_State.hxx>
|
|
|
|
|
|
|
|
#include <TopoDS.hxx>
|
|
|
|
#include <TopoDS_Iterator.hxx>
|
|
|
|
#include <TopoDS_Solid.hxx>
|
|
|
|
#include <TopoDS_Shape.hxx>
|
|
|
|
#include <TopoDS_Face.hxx>
|
|
|
|
#include <TopoDS_Solid.hxx>
|
|
|
|
#include <TopoDS_Iterator.hxx>
|
|
|
|
#include <TopoDS_Shell.hxx>
|
|
|
|
#include <TopoDS_Compound.hxx>
|
|
|
|
|
|
|
|
#include <TopExp.hxx>
|
|
|
|
#include <TopExp_Explorer.hxx>
|
|
|
|
|
|
|
|
#include <BRep_Builder.hxx>
|
|
|
|
#include <BRepTools.hxx>
|
|
|
|
#include <BRepClass3d_SolidClassifier.hxx>
|
|
|
|
|
|
|
|
#include <TopTools_ListOfShape.hxx>
|
|
|
|
#include <TopTools_IndexedMapOfShape.hxx>
|
|
|
|
#include <TopTools_ListIteratorOfListOfShape.hxx>
|
|
|
|
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
|
|
|
|
#include <TopTools_IndexedMapOfShape.hxx>
|
|
|
|
#include <TopTools_MapIteratorOfMapOfShape.hxx>
|
|
|
|
#include <TopTools_DataMapOfShapeShape.hxx>
|
|
|
|
#include <TopTools_DataMapOfShapeInteger.hxx>
|
|
|
|
#include <TopTools_DataMapIteratorOfDataMapOfShapeInteger.hxx>
|
|
|
|
#include <TopTools_MapOfShape.hxx>
|
|
|
|
|
|
|
|
#include <IntTools_Context.hxx>
|
|
|
|
|
|
|
|
#include <NMTDS_ShapesDataStructure.hxx>
|
|
|
|
#include <NMTTools_PaveFiller.hxx>
|
|
|
|
|
|
|
|
#include <GEOMAlgo_Tools3D.hxx>
|
|
|
|
#include <GEOMAlgo_BuilderSolid.hxx>
|
|
|
|
#include <GEOMAlgo_ShapeSet.hxx>
|
|
|
|
#include <GEOMAlgo_DataMapOfShapeShapeSet.hxx>
|
|
|
|
#include <GEOMAlgo_DataMapIteratorOfDataMapOfShapeShapeSet.hxx>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static
|
|
|
|
void OwnInternalShapes(const TopoDS_Shape& ,
|
2012-08-09 13:58:02 +06:00
|
|
|
TopTools_IndexedMapOfShape& );
|
2008-03-07 12:45:34 +05:00
|
|
|
|
|
|
|
//=======================================================================
|
|
|
|
//function : FillImagesSolids
|
2012-08-09 13:58:02 +06:00
|
|
|
//purpose :
|
2008-03-07 12:45:34 +05:00
|
|
|
//=======================================================================
|
|
|
|
void GEOMAlgo_Builder::FillImagesSolids()
|
|
|
|
{
|
|
|
|
myErrorStatus=0;
|
|
|
|
//
|
|
|
|
FillIn3DParts();
|
|
|
|
BuildSplitSolids();
|
|
|
|
FillInternalShapes();
|
|
|
|
}
|
|
|
|
//=======================================================================
|
|
|
|
//function : BuildDraftSolid
|
2012-08-09 13:58:02 +06:00
|
|
|
//purpose :
|
2008-03-07 12:45:34 +05:00
|
|
|
//=======================================================================
|
2012-08-09 13:58:02 +06:00
|
|
|
void GEOMAlgo_Builder::BuildDraftSolid (const TopoDS_Shape& theSolid,
|
|
|
|
TopoDS_Shape& theDraftSolid,
|
|
|
|
TopTools_ListOfShape& theLIF)
|
2008-03-07 12:45:34 +05:00
|
|
|
{
|
|
|
|
myErrorStatus=0;
|
|
|
|
//
|
|
|
|
NMTTools_PaveFiller* pPF=myPaveFiller;
|
2012-08-09 13:58:02 +06:00
|
|
|
const Handle(IntTools_Context)& aCtx= pPF->Context();
|
2008-03-07 12:45:34 +05:00
|
|
|
//
|
|
|
|
Standard_Boolean bToReverse;
|
|
|
|
Standard_Integer iFlag;
|
|
|
|
TopAbs_Orientation aOrF, aOrSh, aOrSd;
|
|
|
|
TopoDS_Iterator aIt1, aIt2;
|
2012-08-09 13:58:02 +06:00
|
|
|
TopTools_ListIteratorOfListOfShape aItS;
|
2008-03-07 12:45:34 +05:00
|
|
|
BRep_Builder aBB;
|
|
|
|
TopoDS_Shell aShD;
|
|
|
|
TopoDS_Shape aFSDx, aFx;
|
|
|
|
//
|
|
|
|
aOrSd=theSolid.Orientation();
|
|
|
|
theDraftSolid.Orientation(aOrSd);
|
|
|
|
//
|
|
|
|
aIt1.Initialize(theSolid);
|
|
|
|
for (; aIt1.More(); aIt1.Next()) {
|
|
|
|
const TopoDS_Shape& aSh=aIt1.Value();
|
|
|
|
if(aSh.ShapeType()!=TopAbs_SHELL) {
|
|
|
|
continue; // mb internal edges,vertices
|
|
|
|
}
|
|
|
|
//
|
|
|
|
aOrSh=aSh.Orientation();
|
|
|
|
aBB.MakeShell(aShD);
|
|
|
|
aShD.Orientation(aOrSh);
|
|
|
|
iFlag=0;
|
|
|
|
//
|
|
|
|
aIt2.Initialize(aSh);
|
|
|
|
for (; aIt2.More(); aIt2.Next()) {
|
|
|
|
const TopoDS_Shape& aF=aIt2.Value();
|
|
|
|
aOrF=aF.Orientation();
|
|
|
|
//
|
|
|
|
if (myImages.HasImage(aF)) {
|
2012-08-09 13:58:02 +06:00
|
|
|
const TopTools_ListOfShape& aLSp=myImages.Image(aF);
|
|
|
|
aItS.Initialize(aLSp);
|
|
|
|
for (; aItS.More(); aItS.Next()) {
|
|
|
|
aFx=aItS.Value();
|
|
|
|
//
|
|
|
|
if (mySameDomainShapes.Contains(aFx)) {
|
|
|
|
aFSDx=mySameDomainShapes.FindFromKey(aFx);
|
|
|
|
//
|
|
|
|
if (aOrF==TopAbs_INTERNAL) {
|
|
|
|
aFSDx.Orientation(aOrF);
|
|
|
|
theLIF.Append(aFSDx);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
bToReverse=GEOMAlgo_Tools3D::IsSplitToReverse(aFSDx, aF, aCtx);
|
|
|
|
if (bToReverse) {
|
|
|
|
aFSDx.Reverse();
|
|
|
|
}
|
|
|
|
//
|
|
|
|
iFlag=1;
|
|
|
|
aBB.Add(aShD, aFSDx);
|
|
|
|
}
|
|
|
|
}// if (mySameDomainShapes.Contains(aFx)) {
|
|
|
|
else {
|
|
|
|
aFx.Orientation(aOrF);
|
|
|
|
if (aOrF==TopAbs_INTERNAL) {
|
|
|
|
theLIF.Append(aFx);
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
iFlag=1;
|
|
|
|
aBB.Add(aShD, aFx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-03-07 12:45:34 +05:00
|
|
|
} //if (myImages.HasImage(aF)) {
|
|
|
|
//
|
|
|
|
else {
|
2012-08-09 13:58:02 +06:00
|
|
|
if (aOrF==TopAbs_INTERNAL) {
|
|
|
|
theLIF.Append(aF);
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
iFlag=1;
|
|
|
|
aBB.Add(aShD, aF);
|
|
|
|
}
|
2008-03-07 12:45:34 +05:00
|
|
|
}
|
|
|
|
} //for (; aIt2.More(); aIt2.Next()) {
|
|
|
|
//
|
|
|
|
if (iFlag) {
|
|
|
|
aBB.Add(theDraftSolid, aShD);
|
|
|
|
}
|
|
|
|
} //for (; aIt1.More(); aIt1.Next()) {
|
|
|
|
}
|
|
|
|
//=======================================================================
|
|
|
|
//function : FillIn3DParts
|
2012-08-09 13:58:02 +06:00
|
|
|
//purpose :
|
2008-03-07 12:45:34 +05:00
|
|
|
//=======================================================================
|
|
|
|
void GEOMAlgo_Builder::FillIn3DParts()
|
|
|
|
{
|
|
|
|
myErrorStatus=0;
|
|
|
|
//
|
|
|
|
const NMTDS_ShapesDataStructure& aDS=*myPaveFiller->DS();
|
|
|
|
NMTTools_PaveFiller* pPF=myPaveFiller;
|
2012-08-09 13:58:02 +06:00
|
|
|
const Handle(IntTools_Context)& aCtx= pPF->Context();
|
2008-03-07 12:45:34 +05:00
|
|
|
//
|
|
|
|
Standard_Boolean bIsIN, bHasImage;
|
2012-08-09 13:58:02 +06:00
|
|
|
Standard_Integer aNbS, aNbSolids, i, j, aNbFaces, aNbFP, aNbFPx, aNbFIN, aNbLIF;
|
|
|
|
TopAbs_ShapeEnum aType;
|
2008-03-07 12:45:34 +05:00
|
|
|
TopAbs_State aState;
|
|
|
|
TopTools_IndexedMapOfShape aMSolids, aMS, aMFaces, aMFIN;
|
|
|
|
TopTools_MapOfShape aMFDone;
|
|
|
|
TopTools_IndexedDataMapOfShapeListOfShape aMEF;
|
2012-08-09 13:58:02 +06:00
|
|
|
TopTools_ListIteratorOfListOfShape aItS;
|
2008-03-07 12:45:34 +05:00
|
|
|
TopoDS_Iterator aIt, aItF;
|
|
|
|
BRep_Builder aBB;
|
2012-08-09 13:58:02 +06:00
|
|
|
TopoDS_Solid aSolidSp;
|
2008-03-07 12:45:34 +05:00
|
|
|
TopoDS_Face aFP;
|
|
|
|
//
|
|
|
|
myDraftSolids.Clear();
|
|
|
|
//
|
|
|
|
aNbS=aDS.NumberOfShapesOfTheObject();
|
|
|
|
for (i=1; i<=aNbS; ++i) {
|
|
|
|
const TopoDS_Shape& aS=aDS.Shape(i);
|
|
|
|
//
|
|
|
|
aType=aS.ShapeType();
|
2012-08-09 13:58:02 +06:00
|
|
|
if (aType==TopAbs_SOLID) {
|
2008-03-07 12:45:34 +05:00
|
|
|
// all solids from DS
|
|
|
|
aMSolids.Add(aS);
|
|
|
|
}
|
|
|
|
else if (aType==TopAbs_FACE) {
|
|
|
|
// all faces (originals from DS or theirs images)
|
|
|
|
if (myImages.HasImage(aS)) {
|
2012-08-09 13:58:02 +06:00
|
|
|
const TopTools_ListOfShape& aLS=myImages.Image(aS);
|
|
|
|
aItS.Initialize(aLS);
|
|
|
|
for (; aItS.More(); aItS.Next()) {
|
|
|
|
const TopoDS_Shape& aFx=aItS.Value();
|
|
|
|
//
|
|
|
|
if (mySameDomainShapes.Contains(aFx)) {
|
|
|
|
const TopoDS_Shape& aFSDx=mySameDomainShapes.FindFromKey(aFx);
|
|
|
|
aMFaces.Add(aFSDx);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
aMFaces.Add(aFx);
|
|
|
|
}
|
|
|
|
}
|
2008-03-07 12:45:34 +05:00
|
|
|
}
|
|
|
|
else {
|
2012-08-09 13:58:02 +06:00
|
|
|
if (mySameDomainShapes.Contains(aS)) {
|
|
|
|
const TopoDS_Shape& aFSDx=mySameDomainShapes.FindFromKey(aS);
|
|
|
|
aMFaces.Add(aFSDx);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
aMFaces.Add(aS);
|
|
|
|
}
|
2008-03-07 12:45:34 +05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//
|
|
|
|
aNbFaces=aMFaces.Extent();
|
|
|
|
aNbSolids=aMSolids.Extent();
|
|
|
|
//
|
|
|
|
for (i=1; i<=aNbSolids; ++i) {
|
|
|
|
const TopoDS_Solid& aSolid=TopoDS::Solid(aMSolids(i));
|
|
|
|
aMFDone.Clear();
|
|
|
|
aMFIN.Clear();
|
|
|
|
aMEF.Clear();
|
|
|
|
//
|
|
|
|
aBB.MakeSolid(aSolidSp);
|
|
|
|
//
|
|
|
|
TopTools_ListOfShape aLIF;
|
|
|
|
//
|
|
|
|
BuildDraftSolid(aSolid, aSolidSp, aLIF);
|
|
|
|
aNbLIF=aLIF.Extent();
|
|
|
|
//
|
|
|
|
// 1 all faces/edges from aSolid [ aMS ]
|
|
|
|
bHasImage=Standard_False;
|
|
|
|
aMS.Clear();
|
|
|
|
aIt.Initialize(aSolid);
|
|
|
|
for (; aIt.More(); aIt.Next()) {
|
|
|
|
const TopoDS_Shape& aShell=aIt.Value();
|
|
|
|
//
|
|
|
|
if (myImages.HasImage(aShell)) {
|
2012-08-09 13:58:02 +06:00
|
|
|
bHasImage=Standard_True;
|
|
|
|
//
|
|
|
|
const TopTools_ListOfShape& aLS=myImages.Image(aShell);
|
|
|
|
aItS.Initialize(aLS);
|
|
|
|
for (; aItS.More(); aItS.Next()) {
|
|
|
|
const TopoDS_Shape& aSx=aItS.Value();
|
|
|
|
aMS.Add(aSx);
|
|
|
|
TopExp::MapShapes(aSx, TopAbs_FACE, aMS);
|
|
|
|
TopExp::MapShapes(aSx, TopAbs_EDGE, aMS);
|
|
|
|
TopExp::MapShapesAndAncestors(aSx, TopAbs_EDGE, TopAbs_FACE, aMEF);
|
|
|
|
}
|
2008-03-07 12:45:34 +05:00
|
|
|
}
|
|
|
|
else {
|
2012-08-09 13:58:02 +06:00
|
|
|
//aMS.Add(aShell);
|
|
|
|
TopExp::MapShapes(aShell, TopAbs_FACE, aMS);
|
|
|
|
//modified by NIZNHY-PKV Fri Dec 03 11:18:45 2010f
|
|
|
|
TopExp::MapShapes(aShell, TopAbs_EDGE, aMS);
|
|
|
|
//modified by NIZNHY-PKV Fri Dec 03 11:18:51 2010t
|
|
|
|
TopExp::MapShapesAndAncestors(aShell, TopAbs_EDGE, TopAbs_FACE, aMEF);
|
2008-03-07 12:45:34 +05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
//
|
|
|
|
// 2 all faces that are not from aSolid [ aLFP1 ]
|
|
|
|
Standard_Integer aNbEFP;
|
|
|
|
TopTools_IndexedDataMapOfShapeListOfShape aMEFP;
|
|
|
|
TopTools_ListIteratorOfListOfShape aItFP, aItEx;
|
|
|
|
TopTools_MapOfShape aMFence;
|
|
|
|
TopTools_ListOfShape aLFP1, aLFP2, aLFP, aLCBF, aLFIN, aLEx;//*pLFP,
|
|
|
|
//
|
|
|
|
// for all non-solid faces build EF map [ aMEFP ]
|
|
|
|
for (j=1; j<=aNbFaces; ++j) {
|
|
|
|
const TopoDS_Shape& aFace=aMFaces(j);
|
|
|
|
if (!aMS.Contains(aFace)) {
|
2012-08-09 13:58:02 +06:00
|
|
|
TopExp::MapShapesAndAncestors(aFace, TopAbs_EDGE, TopAbs_FACE, aMEFP);
|
2008-03-07 12:45:34 +05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
//
|
|
|
|
// among all faces from aMEFP select these that have same edges
|
2012-08-09 13:58:02 +06:00
|
|
|
// with the solid (i.e aMEF). These faces will be treated first
|
2008-03-07 12:45:34 +05:00
|
|
|
// to prevent the usage of 3D classifier.
|
2012-08-09 13:58:02 +06:00
|
|
|
// The full list of faces to process is aLFP1.
|
2008-03-07 12:45:34 +05:00
|
|
|
aNbEFP=aMEFP.Extent();
|
|
|
|
for (j=1; j<=aNbEFP; ++j) {
|
|
|
|
const TopoDS_Shape& aE=aMEFP.FindKey(j);
|
|
|
|
//
|
|
|
|
if (aMEF.Contains(aE)) { // !!
|
2012-08-09 13:58:02 +06:00
|
|
|
const TopTools_ListOfShape& aLF=aMEFP(j);
|
|
|
|
aItFP.Initialize(aLF);
|
|
|
|
for (; aItFP.More(); aItFP.Next()) {
|
|
|
|
const TopoDS_Shape& aF=aItFP.Value();
|
|
|
|
if (aMFence.Add(aF)) {
|
|
|
|
aLFP1.Append(aF);
|
|
|
|
}
|
|
|
|
}
|
2008-03-07 12:45:34 +05:00
|
|
|
}
|
|
|
|
else {
|
2012-08-09 13:58:02 +06:00
|
|
|
aLEx.Append(aE);
|
2008-03-07 12:45:34 +05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
//
|
|
|
|
aItEx.Initialize(aLEx);
|
|
|
|
for (; aItEx.More(); aItEx.Next()) {
|
|
|
|
const TopoDS_Shape& aE=aItEx.Value();
|
|
|
|
const TopTools_ListOfShape& aLF=aMEFP.FindFromKey(aE);
|
|
|
|
aItFP.Initialize(aLF);
|
|
|
|
for (; aItFP.More(); aItFP.Next()) {
|
2012-08-09 13:58:02 +06:00
|
|
|
const TopoDS_Shape& aF=aItFP.Value();
|
|
|
|
if (aMFence.Add(aF)) {
|
|
|
|
aLFP2.Append(aF);
|
|
|
|
}
|
2008-03-07 12:45:34 +05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
aLFP1.Append(aLFP2);
|
|
|
|
//==========
|
|
|
|
//
|
|
|
|
// 3 Process faces aLFP1
|
|
|
|
aNbFP=aLFP1.Extent();
|
|
|
|
aItFP.Initialize(aLFP1);
|
|
|
|
for (; aItFP.More(); aItFP.Next()) {
|
|
|
|
const TopoDS_Shape& aSP=aItFP.Value();
|
|
|
|
if (!aMFDone.Add(aSP)) {
|
2012-08-09 13:58:02 +06:00
|
|
|
continue;
|
2008-03-07 12:45:34 +05:00
|
|
|
}
|
2012-08-09 13:58:02 +06:00
|
|
|
|
2008-03-07 12:45:34 +05:00
|
|
|
//
|
|
|
|
// first face to process
|
|
|
|
aFP=TopoDS::Face(aSP);
|
|
|
|
bIsIN= GEOMAlgo_Tools3D::IsInternalFace(aFP, aSolidSp, aMEF, 1.e-14, aCtx);
|
|
|
|
aState=(bIsIN) ? TopAbs_IN : TopAbs_OUT;
|
|
|
|
//
|
|
|
|
// collect faces to process [ aFP is the first ]
|
|
|
|
aLFP.Clear();
|
|
|
|
aLFP.Append(aFP);
|
|
|
|
aItS.Initialize(aLFP1);
|
|
|
|
for (; aItS.More(); aItS.Next()) {
|
2012-08-09 13:58:02 +06:00
|
|
|
const TopoDS_Shape& aSk=aItS.Value();
|
|
|
|
if (!aMFDone.Contains(aSk)) {
|
|
|
|
aLFP.Append(aSk);
|
|
|
|
}
|
2008-03-07 12:45:34 +05:00
|
|
|
}
|
|
|
|
//
|
2012-08-09 13:58:02 +06:00
|
|
|
// Connexity Block that spreads from aFP the Bound
|
2008-03-07 12:45:34 +05:00
|
|
|
// or till the end of the block itself
|
|
|
|
aLCBF.Clear();
|
|
|
|
GEOMAlgo_Tools3D::MakeConnexityBlock(aLFP, aMS, aLCBF);
|
|
|
|
//
|
2012-08-09 13:58:02 +06:00
|
|
|
// fill states for the Connexity Block
|
2008-03-07 12:45:34 +05:00
|
|
|
aItS.Initialize(aLCBF);
|
|
|
|
for (; aItS.More(); aItS.Next()) {
|
2012-08-09 13:58:02 +06:00
|
|
|
const TopoDS_Shape& aSx=aItS.Value();
|
|
|
|
aMFDone.Add(aSx);
|
|
|
|
if (aState==TopAbs_IN) {
|
|
|
|
aMFIN.Add(aSx);
|
|
|
|
}
|
2008-03-07 12:45:34 +05:00
|
|
|
}
|
|
|
|
//
|
|
|
|
aNbFPx=aMFDone.Extent();
|
|
|
|
if (aNbFPx==aNbFP) {
|
2012-08-09 13:58:02 +06:00
|
|
|
break;
|
2008-03-07 12:45:34 +05:00
|
|
|
}
|
|
|
|
}//for (; aItFP.More(); aItFP.Next())
|
|
|
|
//
|
|
|
|
// faces Inside aSolid
|
|
|
|
aLFIN.Clear();
|
|
|
|
aNbFIN=aMFIN.Extent();
|
|
|
|
if (aNbFIN || aNbLIF) {
|
|
|
|
for (j=1; j<=aNbFIN; ++j) {
|
2012-08-09 13:58:02 +06:00
|
|
|
const TopoDS_Shape& aFIN=aMFIN(j);
|
|
|
|
aLFIN.Append(aFIN);
|
2008-03-07 12:45:34 +05:00
|
|
|
}
|
|
|
|
//
|
|
|
|
aItS.Initialize(aLIF);
|
|
|
|
for (; aItS.More(); aItS.Next()) {
|
2012-08-09 13:58:02 +06:00
|
|
|
const TopoDS_Shape& aFIN=aItS.Value();
|
|
|
|
aLFIN.Append(aFIN);
|
2008-03-07 12:45:34 +05:00
|
|
|
}
|
|
|
|
//
|
|
|
|
myInParts.Add(aSolid, aLFIN);
|
|
|
|
}
|
|
|
|
if (aNbFIN || bHasImage) {
|
|
|
|
myDraftSolids.Add(aSolid, aSolidSp);
|
|
|
|
}
|
|
|
|
}//for (i=1; i<=aNbSolids; ++i) { // next solid
|
|
|
|
}
|
|
|
|
//=======================================================================
|
|
|
|
//function : BuildSplitSolids
|
2012-08-09 13:58:02 +06:00
|
|
|
//purpose :
|
2008-03-07 12:45:34 +05:00
|
|
|
//=======================================================================
|
|
|
|
void GEOMAlgo_Builder::BuildSplitSolids()
|
|
|
|
{
|
|
|
|
myErrorStatus=0;
|
2012-08-09 13:58:02 +06:00
|
|
|
//
|
2008-03-07 12:45:34 +05:00
|
|
|
const NMTDS_ShapesDataStructure& aDS=*myPaveFiller->DS();
|
|
|
|
NMTTools_PaveFiller* pPF=myPaveFiller;
|
2012-08-09 13:58:02 +06:00
|
|
|
const Handle(IntTools_Context)& aCtx= pPF->Context();
|
2008-03-07 12:45:34 +05:00
|
|
|
//
|
|
|
|
Standard_Integer i, aNbS, iErr;
|
|
|
|
TopExp_Explorer aExp;
|
|
|
|
TopTools_ListOfShape aSFS, aLSEmpty;
|
|
|
|
TopTools_MapOfShape aMFence;
|
|
|
|
TopTools_ListIteratorOfListOfShape aIt;
|
|
|
|
GEOMAlgo_BuilderSolid aSB;
|
|
|
|
GEOMAlgo_DataMapIteratorOfDataMapOfShapeShapeSet aItSS;
|
|
|
|
GEOMAlgo_DataMapOfShapeShapeSet aMSS;
|
|
|
|
GEOMAlgo_ShapeSet aSSi;
|
|
|
|
//
|
|
|
|
// 0. Find same domain solids for non-interferred solids
|
|
|
|
aNbS=aDS.NumberOfShapesOfTheObject();
|
|
|
|
for (i=1; i<=aNbS; ++i) {
|
|
|
|
const TopoDS_Shape& aS=aDS.Shape(i);
|
|
|
|
if (aS.ShapeType()!=TopAbs_SOLID) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (!aMFence.Add(aS)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if(myDraftSolids.Contains(aS)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
//
|
|
|
|
aSSi.Clear();
|
|
|
|
aSSi.Add(aS, TopAbs_FACE);
|
|
|
|
//
|
|
|
|
aMSS.Bind(aS, aSSi);
|
2012-08-09 13:58:02 +06:00
|
|
|
} //for (i=1; i<=aNbS; ++i)
|
2008-03-07 12:45:34 +05:00
|
|
|
//
|
|
|
|
// 1. Build solids for interferred source solids
|
|
|
|
aSB.SetContext(aCtx);
|
2012-08-09 13:58:02 +06:00
|
|
|
aSB.ComputeInternalShapes(myComputeInternalShapes);
|
2008-03-07 12:45:34 +05:00
|
|
|
aNbS=myDraftSolids.Extent();
|
|
|
|
for (i=1; i<=aNbS; ++i) {
|
|
|
|
const TopoDS_Shape& aS =myDraftSolids.FindKey(i);
|
|
|
|
const TopoDS_Shape& aSD=myDraftSolids.FindFromIndex(i);
|
|
|
|
const TopTools_ListOfShape& aLFIN=
|
|
|
|
(myInParts.Contains(aS)) ? myInParts.FindFromKey(aS) : aLSEmpty;
|
|
|
|
//
|
|
|
|
// 1.1 Fill Shell Faces Set
|
|
|
|
aSFS.Clear();
|
2012-08-09 13:58:02 +06:00
|
|
|
|
2008-03-07 12:45:34 +05:00
|
|
|
aExp.Init(aSD, TopAbs_FACE);
|
|
|
|
for (; aExp.More(); aExp.Next()) {
|
|
|
|
const TopoDS_Shape& aF=aExp.Current();
|
|
|
|
aSFS.Append(aF);
|
|
|
|
}
|
|
|
|
//
|
|
|
|
aIt.Initialize(aLFIN);
|
|
|
|
for (; aIt.More(); aIt.Next()) {
|
|
|
|
TopoDS_Shape aF=aIt.Value();
|
|
|
|
//
|
|
|
|
aF.Orientation(TopAbs_FORWARD);
|
|
|
|
aSFS.Append(aF);
|
|
|
|
aF.Orientation(TopAbs_REVERSED);
|
|
|
|
aSFS.Append(aF);
|
|
|
|
}
|
|
|
|
//
|
|
|
|
Standard_Integer aNbSFS;
|
|
|
|
aNbSFS=aSFS.Extent();
|
|
|
|
//
|
|
|
|
// 1.2
|
2012-08-09 13:58:02 +06:00
|
|
|
// Check whether aSFS contains a subsets of faces
|
|
|
|
// of solids that have been already built.
|
2008-03-07 12:45:34 +05:00
|
|
|
// If yes, shrink aSFS by these subsets.
|
|
|
|
aSSi.Clear();
|
|
|
|
aSSi.Add(aSFS);
|
|
|
|
//
|
|
|
|
aItSS.Initialize(aMSS);
|
|
|
|
for (; aItSS.More(); aItSS.Next()) {
|
2012-08-09 13:58:02 +06:00
|
|
|
const TopoDS_Shape& aSR=aItSS.Key();
|
2008-03-07 12:45:34 +05:00
|
|
|
const GEOMAlgo_ShapeSet& aSSR=aItSS.Value();
|
|
|
|
if (aSSi.Contains(aSSR)) {
|
2012-08-09 13:58:02 +06:00
|
|
|
// the aSR is SD solid for aS
|
|
|
|
aSSi.Subtract(aSSR);
|
|
|
|
// update images
|
|
|
|
if(myImages.HasImage(aS)) {
|
|
|
|
myImages.Add(aS, aSR);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
myImages.Bind(aS, aSR);
|
|
|
|
}
|
|
|
|
//
|
|
|
|
// update SD Shapes
|
|
|
|
mySameDomainShapes.Add(aSR, aSR);
|
2008-03-07 12:45:34 +05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
const TopTools_ListOfShape& aSFS1=aSSi.GetSet();
|
|
|
|
aNbSFS=aSFS1.Extent();
|
2012-08-09 13:58:02 +06:00
|
|
|
//modified by NIZNHY-PKV Wed Oct 27 09:53:15 2010f
|
|
|
|
if (!aNbSFS) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
//modified by NIZNHY-PKV Wed Oct 27 09:53:18 2010t
|
2008-03-07 12:45:34 +05:00
|
|
|
//
|
|
|
|
// 1.3 Build new solids
|
2012-08-09 13:58:02 +06:00
|
|
|
aSB.SetContext(aCtx);
|
2008-03-07 12:45:34 +05:00
|
|
|
aSB.SetShapes(aSFS1);
|
|
|
|
aSB.Perform();
|
|
|
|
iErr=aSB.ErrorStatus();
|
|
|
|
if (iErr) {
|
|
|
|
myErrorStatus=30; // SolidBuilder failed
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
//
|
|
|
|
const TopTools_ListOfShape& aLSR=aSB.Areas();
|
|
|
|
//
|
2012-08-09 13:58:02 +06:00
|
|
|
// 1.4 Collect resulting solids and theirs set of faces
|
2008-03-07 12:45:34 +05:00
|
|
|
aIt.Initialize(aLSR);
|
|
|
|
for (; aIt.More(); aIt.Next()) {
|
|
|
|
const TopoDS_Shape& aSR=aIt.Value();
|
|
|
|
//
|
|
|
|
aSSi.Clear();
|
|
|
|
aExp.Init(aSR, TopAbs_FACE);
|
|
|
|
for (; aExp.More(); aExp.Next()) {
|
2012-08-09 13:58:02 +06:00
|
|
|
const TopoDS_Shape& aF=aExp.Current();
|
|
|
|
aSSi.Add(aF);
|
2008-03-07 12:45:34 +05:00
|
|
|
}
|
|
|
|
aMSS.Bind(aSR, aSSi);
|
|
|
|
}
|
|
|
|
//
|
|
|
|
// Update images
|
|
|
|
if (myImages.HasImage(aS)) {
|
|
|
|
myImages.Add(aS, aLSR);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
myImages.Bind(aS, aLSR);
|
|
|
|
}
|
|
|
|
} // for (i=1; i<=aNbS; ++i) {
|
|
|
|
}
|
|
|
|
//=======================================================================
|
2012-08-09 13:58:02 +06:00
|
|
|
//function :FillInternalShapes
|
|
|
|
//purpose :
|
2008-03-07 12:45:34 +05:00
|
|
|
//=======================================================================
|
|
|
|
void GEOMAlgo_Builder::FillInternalShapes()
|
|
|
|
{
|
|
|
|
myErrorStatus=0;
|
|
|
|
//
|
|
|
|
const NMTDS_ShapesDataStructure& aDS=*myPaveFiller->DS();
|
|
|
|
NMTTools_PaveFiller* pPF=myPaveFiller;
|
2012-08-09 13:58:02 +06:00
|
|
|
const Handle(IntTools_Context)& aCtx= pPF->Context();
|
2008-03-07 12:45:34 +05:00
|
|
|
//
|
|
|
|
//Standard_Boolean bHasImage;
|
|
|
|
Standard_Integer i, j, jT, aNbS, aNbSI, aNbSx, aNbSd;
|
|
|
|
TopAbs_ShapeEnum aType, aT[]={ TopAbs_VERTEX, TopAbs_EDGE };
|
|
|
|
TopAbs_State aState;
|
|
|
|
TopTools_ListIteratorOfListOfShape aIt, aIt1;
|
|
|
|
TopTools_IndexedDataMapOfShapeListOfShape aMSx;
|
|
|
|
TopTools_IndexedMapOfShape aMx;
|
|
|
|
TopTools_MapOfShape aMSI, aMFence, aMSOr;
|
|
|
|
TopTools_MapIteratorOfMapOfShape aItM;
|
|
|
|
TopTools_ListOfShape aLSI, aLSd;
|
|
|
|
TopoDS_Iterator aItS;
|
|
|
|
BRep_Builder aBB;
|
|
|
|
//
|
|
|
|
// 1. Shapes to process
|
|
|
|
//
|
2012-08-09 13:58:02 +06:00
|
|
|
// 1.1 Shapes from pure arguments aMSI
|
2008-03-07 12:45:34 +05:00
|
|
|
// 1.1.1 vertex, edge
|
|
|
|
for (i=0; i<2; ++i) {
|
|
|
|
jT=(Standard_Integer)aT[i];
|
|
|
|
const TopTools_ListOfShape &aLS=myShapes1[jT];
|
|
|
|
aIt.Initialize(aLS);
|
|
|
|
for (; aIt.More(); aIt.Next()) {
|
|
|
|
const TopoDS_Shape& aS=aIt.Value();
|
|
|
|
if (aMFence.Add(aS)) {
|
2012-08-09 13:58:02 +06:00
|
|
|
aLSI.Append(aS);
|
2008-03-07 12:45:34 +05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// 1.1.2 wire
|
2012-08-09 13:58:02 +06:00
|
|
|
{
|
2008-03-07 12:45:34 +05:00
|
|
|
jT=(Standard_Integer)TopAbs_WIRE;
|
|
|
|
const TopTools_ListOfShape &aLW=myShapes1[jT];
|
|
|
|
aIt.Initialize(aLW);
|
|
|
|
for (; aIt.More(); aIt.Next()) {
|
|
|
|
const TopoDS_Shape& aW=aIt.Value();
|
|
|
|
aItS.Initialize(aW);
|
|
|
|
for (; aItS.More(); aItS.Next()) {
|
2012-08-09 13:58:02 +06:00
|
|
|
const TopoDS_Shape& aE=aItS.Value();
|
|
|
|
if (aMFence.Add(aE)) {
|
|
|
|
aLSI.Append(aE);
|
|
|
|
}
|
2008-03-07 12:45:34 +05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-08-09 13:58:02 +06:00
|
|
|
// 1.1.3 theirs images/sources
|
2008-03-07 12:45:34 +05:00
|
|
|
aIt1.Initialize(aLSI);
|
|
|
|
for (; aIt1.More(); aIt1.Next()) {
|
|
|
|
const TopoDS_Shape& aS=aIt1.Value();
|
|
|
|
if (myImages.HasImage(aS)) {
|
|
|
|
const TopTools_ListOfShape &aLSp=myImages.Image(aS);
|
|
|
|
aIt.Initialize(aLSp);
|
|
|
|
for (; aIt.More(); aIt.Next()) {
|
2012-08-09 13:58:02 +06:00
|
|
|
const TopoDS_Shape& aSI=aIt.Value();
|
|
|
|
aMSI.Add(aSI);
|
2008-03-07 12:45:34 +05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
aMSI.Add(aS);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
aLSI.Clear();
|
|
|
|
aNbSI=aMSI.Extent();
|
|
|
|
//
|
|
|
|
// 2. Internal vertices, edges from source solids
|
|
|
|
aMFence.Clear();
|
|
|
|
aLSd.Clear();
|
|
|
|
//
|
|
|
|
aNbS=aDS.NumberOfShapesOfTheObject();
|
|
|
|
for (i=1; i<=aNbS; ++i) {
|
|
|
|
const TopoDS_Shape& aS=aDS.Shape(i);
|
|
|
|
aType=aS.ShapeType();
|
|
|
|
if (aType==TopAbs_SOLID) {
|
|
|
|
//
|
|
|
|
aMx.Clear();
|
|
|
|
OwnInternalShapes(aS, aMx);
|
|
|
|
//
|
|
|
|
aNbSx=aMx.Extent();
|
|
|
|
for (j=1; j<=aNbSx; ++j) {
|
2012-08-09 13:58:02 +06:00
|
|
|
const TopoDS_Shape& aSI=aMx(j);
|
|
|
|
if (myImages.HasImage(aSI)) {
|
|
|
|
const TopTools_ListOfShape &aLSp=myImages.Image(aSI);
|
|
|
|
aIt.Initialize(aLSp);
|
|
|
|
for (; aIt.More(); aIt.Next()) {
|
|
|
|
const TopoDS_Shape& aSp=aIt.Value();
|
|
|
|
aMSI.Add(aSp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
aMSI.Add(aSI);
|
|
|
|
}
|
2008-03-07 12:45:34 +05:00
|
|
|
}
|
|
|
|
//
|
|
|
|
// build aux map from splits of solids
|
|
|
|
if (myImages.HasImage(aS)) {
|
2012-08-09 13:58:02 +06:00
|
|
|
const TopTools_ListOfShape &aLSp=myImages.Image(aS);
|
|
|
|
aIt.Initialize(aLSp);
|
|
|
|
for (; aIt.More(); aIt.Next()) {
|
|
|
|
const TopoDS_Shape& aSp=aIt.Value();
|
|
|
|
if (aMFence.Add(aSp)) {
|
|
|
|
TopExp::MapShapesAndAncestors(aSp, TopAbs_VERTEX, TopAbs_EDGE, aMSx);
|
|
|
|
TopExp::MapShapesAndAncestors(aSp, TopAbs_VERTEX, TopAbs_FACE, aMSx);
|
|
|
|
TopExp::MapShapesAndAncestors(aSp, TopAbs_EDGE , TopAbs_FACE, aMSx);
|
|
|
|
aLSd.Append(aSp);
|
|
|
|
}
|
|
|
|
}
|
2008-03-07 12:45:34 +05:00
|
|
|
}
|
|
|
|
else {
|
2012-08-09 13:58:02 +06:00
|
|
|
if (aMFence.Add(aS)) {
|
|
|
|
TopExp::MapShapesAndAncestors(aS, TopAbs_VERTEX, TopAbs_EDGE, aMSx);
|
|
|
|
TopExp::MapShapesAndAncestors(aS, TopAbs_VERTEX, TopAbs_FACE, aMSx);
|
|
|
|
TopExp::MapShapesAndAncestors(aS, TopAbs_EDGE , TopAbs_FACE, aMSx);
|
|
|
|
aLSd.Append(aS);
|
|
|
|
aMSOr.Add(aS);
|
|
|
|
}
|
2008-03-07 12:45:34 +05:00
|
|
|
}
|
|
|
|
}//if (aType==TopAbs_SOLID)
|
|
|
|
}
|
|
|
|
//
|
|
|
|
aNbSd=aLSd.Extent();
|
|
|
|
//
|
2012-08-09 13:58:02 +06:00
|
|
|
// 3. Some shapes of aMSI can be already tied with faces of
|
2008-03-07 12:45:34 +05:00
|
|
|
// split solids
|
2012-08-09 13:58:02 +06:00
|
|
|
aItM.Initialize(aMSI);
|
2008-03-07 12:45:34 +05:00
|
|
|
for (; aItM.More(); aItM.Next()) {
|
|
|
|
const TopoDS_Shape& aSI=aItM.Key();
|
|
|
|
if (aMSx.Contains(aSI)) {
|
|
|
|
const TopTools_ListOfShape &aLSx=aMSx.FindFromKey(aSI);
|
|
|
|
aNbSx=aLSx.Extent();
|
|
|
|
if (aNbSx) {
|
2012-08-09 13:58:02 +06:00
|
|
|
aMSI.Remove(aSI);
|
2008-03-07 12:45:34 +05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//
|
|
|
|
// 4. Just check it
|
|
|
|
aNbSI=aMSI.Extent();
|
|
|
|
if (!aNbSI) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
//
|
|
|
|
// 5 Settle internal vertices and edges into solids
|
|
|
|
aMx.Clear();
|
|
|
|
aIt.Initialize(aLSd);
|
|
|
|
for (; aIt.More(); aIt.Next()) {
|
|
|
|
TopoDS_Solid aSd=TopoDS::Solid(aIt.Value());
|
|
|
|
//
|
2012-08-09 13:58:02 +06:00
|
|
|
aItM.Initialize(aMSI);
|
2008-03-07 12:45:34 +05:00
|
|
|
for (; aItM.More(); aItM.Next()) {
|
|
|
|
TopoDS_Shape aSI=aItM.Key();
|
|
|
|
aSI.Orientation(TopAbs_INTERNAL);
|
|
|
|
//
|
|
|
|
aState=GEOMAlgo_Tools3D::ComputeStateByOnePoint(aSI, aSd, 1.e-11, aCtx);
|
|
|
|
if (aState==TopAbs_IN) {
|
2012-08-09 13:58:02 +06:00
|
|
|
//
|
|
|
|
if(aMSOr.Contains(aSd)) {
|
|
|
|
//
|
|
|
|
TopoDS_Solid aSdx;
|
|
|
|
//
|
|
|
|
aBB.MakeSolid(aSdx);
|
|
|
|
aItS.Initialize(aSd);
|
|
|
|
for (; aItS.More(); aItS.Next()) {
|
|
|
|
const TopoDS_Shape& aSh=aItS.Value();
|
|
|
|
aBB.Add(aSdx, aSh);
|
|
|
|
}
|
|
|
|
//
|
|
|
|
aBB.Add(aSdx, aSI);
|
|
|
|
//
|
|
|
|
myImages.Bind(aSd, aSdx);
|
|
|
|
aMSOr.Remove(aSd);
|
|
|
|
aSd=aSdx;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
aBB.Add(aSd, aSI);
|
|
|
|
}
|
|
|
|
//
|
|
|
|
aMSI.Remove(aSI);
|
2008-03-07 12:45:34 +05:00
|
|
|
} //if (aState==TopAbs_IN) {
|
|
|
|
}// for (; aItM.More(); aItM.Next()) {
|
|
|
|
}//for (; aIt1.More(); aIt1.Next()) {
|
|
|
|
}
|
|
|
|
//=======================================================================
|
|
|
|
//function : OwnInternalShapes
|
2012-08-09 13:58:02 +06:00
|
|
|
//purpose :
|
2008-03-07 12:45:34 +05:00
|
|
|
//=======================================================================
|
|
|
|
void OwnInternalShapes(const TopoDS_Shape& theS,
|
2012-08-09 13:58:02 +06:00
|
|
|
TopTools_IndexedMapOfShape& theMx)
|
2008-03-07 12:45:34 +05:00
|
|
|
{
|
|
|
|
TopoDS_Iterator aIt;
|
|
|
|
//
|
|
|
|
aIt.Initialize(theS);
|
|
|
|
for (; aIt.More(); aIt.Next()) {
|
|
|
|
const TopoDS_Shape& aSx=aIt.Value();
|
|
|
|
if (aSx.ShapeType()!=TopAbs_SHELL) {
|
|
|
|
theMx.Add(aSx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//
|
|
|
|
// ErrorStatus
|
|
|
|
// 30 - SolidBuilder failed
|