本文整理汇总了C++中TopTools_MapOfShape::Clear方法的典型用法代码示例。如果您正苦于以下问题:C++ TopTools_MapOfShape::Clear方法的具体用法?C++ TopTools_MapOfShape::Clear怎么用?C++ TopTools_MapOfShape::Clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TopTools_MapOfShape
的用法示例。
在下文中一共展示了TopTools_MapOfShape::Clear方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FillSameDomainFaces
//=======================================================================
// function: FillSameDomainFaces
// purpose:
//=======================================================================
void GEOMAlgo_Builder::FillSameDomainFaces()
{
Standard_Boolean bIsSDF, bHasImage1, bHasImage2, bForward;
Standard_Integer i, j, aNbFF, nF1, nF2, aNbPBInOn, aNbC, aNbSE;
Standard_Integer aNbF1, aNbF2, i2s, aNbSD;
TopTools_MapOfShape aMFence;
TopTools_ListOfShape aLX1, aLX2;
TopTools_ListIteratorOfListOfShape aItF1, aItF2;
NMTTools_ListOfCoupleOfShape aLCS;
//
const NMTDS_ShapesDataStructure& aDS=*myPaveFiller->DS();
NMTTools_PaveFiller* pPF=myPaveFiller;
NMTDS_InterfPool* pIP=pPF->IP();
BOPTools_CArray1OfSSInterference& aFFs=pIP->SSInterferences();
const Handle(IntTools_Context)& aCtx= pPF->Context();
//
//
//mySameDomainShapes.Clear();
//
// 1. For each FF find among images of faces
// all pairs of same domain faces (SDF) [=> aLCS]
aNbFF=aFFs.Extent();
for (i=1; i<=aNbFF; ++i) {
BOPTools_SSInterference& aFF=aFFs(i);
aFF.Indices(nF1, nF2);
//
const TopoDS_Face& aF1=TopoDS::Face(aDS.Shape(nF1));
const TopoDS_Face& aF2=TopoDS::Face(aDS.Shape(nF2));
//
// if there are no in/on 2D split parts the faces nF1, nF2
// can not be SDF
const BOPTools_ListOfPaveBlock& aLPBInOn=aFF.PaveBlocks();
aNbPBInOn=aLPBInOn.Extent();
//
//===
const TColStd_ListOfInteger& aLSE=aFF.SharedEdges();
aNbSE=aLSE.Extent();
if (!aNbPBInOn && !aNbSE) {
continue;
}
//===
//
// if there is at least one section edge between faces nF1, nF2
// they can not be SDF
BOPTools_SequenceOfCurves& aSC=aFF.Curves();
aNbC=aSC.Length();
if (aNbC) {
continue;
}
//
// the faces are suspected to be SDF.
// Try to find SDF among images of nF1, nF2
aMFence.Clear();
//
//--------------------------------------------------------
bHasImage1=mySplitFaces.HasImage(aF1);
bHasImage2=mySplitFaces.HasImage(aF2);
//
aLX1.Clear();
if (!bHasImage1) {
aLX1.Append(aF1);
}
//
aLX2.Clear();
if (!bHasImage2) {
aLX2.Append(aF2);
}
//
const TopTools_ListOfShape& aLF1r=(bHasImage1)? mySplitFaces.Image(aF1) : aLX1;
const TopTools_ListOfShape& aLF2r=(bHasImage2)? mySplitFaces.Image(aF2) : aLX2;
//
TopTools_DataMapOfIntegerShape aMIS;
TColStd_ListIteratorOfListOfInteger aItLI;
NMTDS_BoxBndTreeSelector aSelector;
NMTDS_BoxBndTree aBBTree;
NCollection_UBTreeFiller <Standard_Integer, Bnd_Box> aTreeFiller(aBBTree);
//
aNbF1=aLF1r.Extent();
aNbF2=aLF2r.Extent();
bForward=(aNbF1<aNbF2);
//
const TopTools_ListOfShape& aLF1=bForward ? aLF1r : aLF2r;
const TopTools_ListOfShape& aLF2=bForward ? aLF2r : aLF1r;
//
// 1. aTreeFiller
aItF2.Initialize(aLF2);
for (i2s=1; aItF2.More(); aItF2.Next(), ++i2s) {
Bnd_Box aBoxF2s;
//
const TopoDS_Face& aF2s=*((TopoDS_Face*)(&aItF2.Value()));
//
BRepBndLib::Add(aF2s, aBoxF2s);
//
aMIS.Bind(i2s, aF2s);
//
aTreeFiller.Add(i2s, aBoxF2s);
//.........这里部分代码省略.........
示例2:
//=======================================================================
// function: FillIn2DParts
// purpose:
//=======================================================================
void GEOMAlgo_Builder::FillIn2DParts()
{
const NMTDS_ShapesDataStructure& aDS=*myPaveFiller->DS();
NMTTools_PaveFiller* pPF=myPaveFiller;
NMTDS_InterfPool* pIP=pPF->IP();
BOPTools_CArray1OfSSInterference& aFFs=pIP->SSInterferences();
NMTTools_CommonBlockPool& aCBP=pPF->ChangeCommonBlockPool();
//
Standard_Integer j, nSpIn, nSpSc, aNbCurves;
Standard_Integer aNbS, nF, aNbCBP, n1, n2, aNbFFs, aNbSpIn;
TopTools_MapOfShape aMFence;
TopTools_ListOfShape aLSpIn;
TopoDS_Face aF;
NMTTools_ListIteratorOfListOfCommonBlock aItCB;
BOPTools_ListIteratorOfListOfPaveBlock aItPB;
//
myInParts.Clear();
//
aNbFFs=aFFs.Extent();
aNbCBP=aCBP.Extent();
//
aNbS=aDS.NumberOfShapesOfTheObject();
for (nF=1; nF<=aNbS; ++nF) {
if (aDS.GetShapeType(nF)!=TopAbs_FACE) {
continue;
}
//
aF=TopoDS::Face(aDS.Shape(nF));
//
aMFence.Clear();
aLSpIn.Clear();
//
// 1. In Parts
BOPTools_ListOfPaveBlock aLPBIn;
//
pPF->RealSplitsInFace(nF, aLPBIn);
//
aItPB.Initialize(aLPBIn);
for (; aItPB.More(); aItPB.Next()) {
const BOPTools_PaveBlock& aPB1=aItPB.Value();
nSpIn=aPB1.Edge();
const TopoDS_Shape& aSpIn=aDS.Shape(nSpIn);
aLSpIn.Append(aSpIn);
}
//
// 2. Section Parts
for (j=1; j<=aNbFFs; ++j) {
BOPTools_SSInterference& aFF=aFFs(j);
aFF.Indices(n1, n2);
if (!(n1==nF || n2==nF)) {
continue;
}
BOPTools_SequenceOfCurves& aSC=aFF.Curves();
aNbCurves=aSC.Length();
if (!aNbCurves) {
continue;
}
//
const BOPTools_Curve& aBC=aSC(1);
const BOPTools_ListOfPaveBlock& aLPB=aBC.NewPaveBlocks();
aItPB.Initialize(aLPB);
for (; aItPB.More(); aItPB.Next()) {
const BOPTools_PaveBlock& aPBSc=aItPB.Value();
nSpSc=aPBSc.Edge();
const TopoDS_Shape& aSpSc=aDS.Shape(nSpSc);
if (aMFence.Add(aSpSc)){
aLSpIn.Append(aSpSc);
}
}
}
aNbSpIn=aLSpIn.Extent();
if (aNbSpIn) {
myInParts.Add(aF, aLSpIn);
}
}//for (nF=1; nF<=aNbS; ++nF) {
}
示例3: BuildSplitFaces
//=======================================================================
// function: BuildSplitFaces
// purpose:
//=======================================================================
void GEOMAlgo_Builder::BuildSplitFaces()
{
const NMTDS_ShapesDataStructure& aDS=*myPaveFiller->DS();
NMTTools_PaveFiller* pPF=myPaveFiller;
NMTDS_InterfPool* pIP=pPF->IP();
BOPTools_CArray1OfSSInterference& aFFs=pIP->SSInterferences();
const Handle(IntTools_Context)& aCtx= pPF->Context();
//
Standard_Boolean bToReverse, bIsClosed, bIsDegenerated;
Standard_Integer i, aNb, aNbF, nF;
TopTools_MapOfShape aMFence;
TColStd_IndexedMapOfInteger aMFP;
TopExp_Explorer anExp;
TopoDS_Face aFF;
TopoDS_Edge aSp, aEE;
TopTools_ListIteratorOfListOfShape aIt;
TopAbs_Orientation anOriF, anOriE;
//
mySplitFaces.Clear();
//
// 1. Select Faces to process (MFP)
aNb=aDS.NumberOfShapesOfTheObject();
for (i=1; i<=aNb; ++i) {
const TopoDS_Shape& aF=aDS.Shape(i);
if (aF.ShapeType()!=TopAbs_FACE) {
continue;
}
if (!aMFence.Add(aF)) {
continue;
}
//
if (myInParts.Contains(aF)) {
aMFP.Add(i);
continue;
}
//
anExp.Init(aF, TopAbs_EDGE);
for (; anExp.More(); anExp.Next()) {
const TopoDS_Shape& aE=anExp.Current();
if (myImages.HasImage(aE)) {
aMFP.Add(i);
break;
}
}
//
//===
{
Standard_Integer aNbFFs, aNbSE, j, n1, n2;
//
aNbFFs=aFFs.Extent();
for (j=1; j<=aNbFFs; ++j) {
BOPTools_SSInterference& aFFj=aFFs(j);
aFFj.Indices(n1, n2);
if (!(n1==i || n2==i)) {
continue;
}
//
const TColStd_ListOfInteger& aLSE=aFFj.SharedEdges();
aNbSE=aLSE.Extent();
if (aNbSE) {
aMFP.Add(i);
break;
}
}
}
//===
//
}// for (i=1; i<=aNb; ++i)
//
// 2. ProcessFaces
aNbF=aMFP.Extent();
for (i=1; i<=aNbF; ++i) {
nF=aMFP(i);
const TopoDS_Face& aF=TopoDS::Face(aDS.Shape(nF));
anOriF=aF.Orientation();
aFF=aF;
aFF.Orientation(TopAbs_FORWARD);
//
aMFence.Clear();
//
// 2.1. Fill WES
GEOMAlgo_WireEdgeSet aWES;
aWES.SetFace(aFF);
//
// 2.1.1. Add Split parts
anExp.Init(aFF, TopAbs_EDGE);
for (; anExp.More(); anExp.Next()) {
const TopoDS_Edge& aE=TopoDS::Edge(anExp.Current());
anOriE=aE.Orientation();
//
if (!myImages.HasImage(aE)) {
if (anOriE==TopAbs_INTERNAL) {
aEE=aE;
aEE.Orientation(TopAbs_FORWARD);
aWES.AddStartElement(aEE);
aEE.Orientation(TopAbs_REVERSED);
//.........这里部分代码省略.........
示例4: Max
bool NETGENPlugin_NETGEN_3D::Evaluate(SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape,
MapShapeNbElems& aResMap)
{
int nbtri = 0, nbqua = 0;
double fullArea = 0.0;
for (TopExp_Explorer exp(aShape, TopAbs_FACE); exp.More(); exp.Next()) {
TopoDS_Face F = TopoDS::Face( exp.Current() );
SMESH_subMesh *sm = aMesh.GetSubMesh(F);
MapShapeNbElemsItr anIt = aResMap.find(sm);
if( anIt==aResMap.end() ) {
SMESH_ComputeErrorPtr& smError = sm->GetComputeError();
smError.reset( new SMESH_ComputeError(COMPERR_ALGO_FAILED,"Submesh can not be evaluated",this));
return false;
}
std::vector<int> aVec = (*anIt).second;
nbtri += Max(aVec[SMDSEntity_Triangle],aVec[SMDSEntity_Quad_Triangle]);
nbqua += Max(aVec[SMDSEntity_Quadrangle],aVec[SMDSEntity_Quad_Quadrangle]);
GProp_GProps G;
BRepGProp::SurfaceProperties(F,G);
double anArea = G.Mass();
fullArea += anArea;
}
// collect info from edges
int nb0d_e = 0, nb1d_e = 0;
bool IsQuadratic = false;
bool IsFirst = true;
TopTools_MapOfShape tmpMap;
for (TopExp_Explorer exp(aShape, TopAbs_EDGE); exp.More(); exp.Next()) {
TopoDS_Edge E = TopoDS::Edge(exp.Current());
if( tmpMap.Contains(E) )
continue;
tmpMap.Add(E);
SMESH_subMesh *aSubMesh = aMesh.GetSubMesh(exp.Current());
MapShapeNbElemsItr anIt = aResMap.find(aSubMesh);
if( anIt==aResMap.end() ) {
SMESH_ComputeErrorPtr& smError = aSubMesh->GetComputeError();
smError.reset( new SMESH_ComputeError(COMPERR_ALGO_FAILED,
"Submesh can not be evaluated",this));
return false;
}
std::vector<int> aVec = (*anIt).second;
nb0d_e += aVec[SMDSEntity_Node];
nb1d_e += Max(aVec[SMDSEntity_Edge],aVec[SMDSEntity_Quad_Edge]);
if(IsFirst) {
IsQuadratic = (aVec[SMDSEntity_Quad_Edge] > aVec[SMDSEntity_Edge]);
IsFirst = false;
}
}
tmpMap.Clear();
double ELen_face = sqrt(2.* ( fullArea/(nbtri+nbqua*2) ) / sqrt(3.0) );
double ELen_vol = pow( 72, 1/6. ) * pow( _maxElementVolume, 1/3. );
double ELen = Min(ELen_vol,ELen_face*2);
GProp_GProps G;
BRepGProp::VolumeProperties(aShape,G);
double aVolume = G.Mass();
double tetrVol = 0.1179*ELen*ELen*ELen;
double CoeffQuality = 0.9;
int nbVols = (int)aVolume/tetrVol/CoeffQuality;
int nb1d_f = (nbtri*3 + nbqua*4 - nb1d_e) / 2;
int nb1d_in = (int) ( nbVols*6 - nb1d_e - nb1d_f ) / 5;
std::vector<int> aVec(SMDSEntity_Last);
for(int i=SMDSEntity_Node; i<SMDSEntity_Last; i++) aVec[i]=0;
if( IsQuadratic ) {
aVec[SMDSEntity_Node] = nb1d_in/6 + 1 + nb1d_in;
aVec[SMDSEntity_Quad_Tetra] = nbVols - nbqua*2;
aVec[SMDSEntity_Quad_Pyramid] = nbqua;
}
else {
aVec[SMDSEntity_Node] = nb1d_in/6 + 1;
aVec[SMDSEntity_Tetra] = nbVols - nbqua*2;
aVec[SMDSEntity_Pyramid] = nbqua;
}
SMESH_subMesh *sm = aMesh.GetSubMesh(aShape);
aResMap.insert(std::make_pair(sm,aVec));
return true;
}
示例5: GetEdgeNearPoint
//=======================================================================
//function : GetEdgeNearPoint
//purpose :
//=======================================================================
TopoDS_Shape GEOMUtils::GetEdgeNearPoint (const TopoDS_Shape& theShape,
const TopoDS_Vertex& thePoint)
{
TopoDS_Shape aResult;
// 1. Explode the shape on edges
TopTools_MapOfShape mapShape;
Standard_Integer nbEdges = 0;
TopExp_Explorer exp (theShape, TopAbs_EDGE);
for (; exp.More(); exp.Next()) {
if (mapShape.Add(exp.Current())) {
nbEdges++;
}
}
if (nbEdges == 0)
Standard_NullObject::Raise("Given shape contains no edges");
mapShape.Clear();
Standard_Integer ind = 1;
TopTools_Array1OfShape anEdges (1, nbEdges);
TColStd_Array1OfReal aDistances (1, nbEdges);
for (exp.Init(theShape, TopAbs_EDGE); exp.More(); exp.Next()) {
if (mapShape.Add(exp.Current())) {
TopoDS_Shape anEdge = exp.Current();
anEdges(ind) = anEdge;
// 2. Classify the point relatively each edge
BRepExtrema_DistShapeShape aDistTool (thePoint, anEdges(ind));
if (!aDistTool.IsDone())
Standard_ConstructionError::Raise("Cannot find a distance from the given point to one of edges");
aDistances(ind) = aDistTool.Value();
ind++;
}
}
// 3. Define edge, having minimum distance to the point
Standard_Real nearest = RealLast(), nbFound = 0;
Standard_Real prec = Precision::Confusion();
for (ind = 1; ind <= nbEdges; ind++) {
if (Abs(aDistances(ind) - nearest) < prec) {
nbFound++;
}
else if (aDistances(ind) < nearest) {
nearest = aDistances(ind);
aResult = anEdges(ind);
nbFound = 1;
}
else {
}
}
if (nbFound > 1) {
Standard_ConstructionError::Raise("Multiple edges near the given point are found");
}
else if (nbFound == 0) {
Standard_ConstructionError::Raise("There are no edges near the given point");
}
else {
}
return aResult;
}
示例6: Handle
//=======================================================================
//function : FillIn3DParts
//purpose :
//=======================================================================
void GEOMAlgo_Builder::FillIn3DParts()
{
myErrorStatus=0;
//
const NMTDS_ShapesDataStructure& aDS=*myPaveFiller->DS();
NMTTools_PaveFiller* pPF=myPaveFiller;
const Handle(IntTools_Context)& aCtx= pPF->Context();
//
Standard_Boolean bIsIN, bHasImage;
Standard_Integer aNbS, aNbSolids, i, j, aNbFaces, aNbFP, aNbFPx, aNbFIN, aNbLIF;
TopAbs_ShapeEnum aType;
TopAbs_State aState;
TopTools_IndexedMapOfShape aMSolids, aMS, aMFaces, aMFIN;
TopTools_MapOfShape aMFDone;
TopTools_IndexedDataMapOfShapeListOfShape aMEF;
TopTools_ListIteratorOfListOfShape aItS;
TopoDS_Iterator aIt, aItF;
BRep_Builder aBB;
TopoDS_Solid aSolidSp;
TopoDS_Face aFP;
//
myDraftSolids.Clear();
//
aNbS=aDS.NumberOfShapesOfTheObject();
for (i=1; i<=aNbS; ++i) {
const TopoDS_Shape& aS=aDS.Shape(i);
//
aType=aS.ShapeType();
if (aType==TopAbs_SOLID) {
// all solids from DS
aMSolids.Add(aS);
}
else if (aType==TopAbs_FACE) {
// all faces (originals from DS or theirs images)
if (myImages.HasImage(aS)) {
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);
}
}
}
else {
if (mySameDomainShapes.Contains(aS)) {
const TopoDS_Shape& aFSDx=mySameDomainShapes.FindFromKey(aS);
aMFaces.Add(aFSDx);
}
else {
aMFaces.Add(aS);
}
}
}
}
//
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)) {
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);
}
//.........这里部分代码省略.........
示例7: exp
bool StdMeshers_RadialPrism_3D::Evaluate(SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape,
MapShapeNbElems& aResMap)
{
// get 2 shells
TopoDS_Solid solid = TopoDS::Solid( aShape );
TopoDS_Shell outerShell = BRepClass3d::OuterShell( solid );
TopoDS_Shape innerShell;
int nbShells = 0;
for ( TopoDS_Iterator It (solid); It.More(); It.Next(), ++nbShells )
if ( !outerShell.IsSame( It.Value() ))
innerShell = It.Value();
if ( nbShells != 2 ) {
std::vector<int> aResVec(SMDSEntity_Last);
for(int i=SMDSEntity_Node; i<SMDSEntity_Last; i++) aResVec[i] = 0;
SMESH_subMesh * sm = aMesh.GetSubMesh(aShape);
aResMap.insert(std::make_pair(sm,aResVec));
SMESH_ComputeErrorPtr& smError = sm->GetComputeError();
smError.reset( new SMESH_ComputeError(COMPERR_ALGO_FAILED,"Submesh can not be evaluated",this));
return false;
}
// Associate sub-shapes of the shells
ProjectionUtils::TShapeShapeMap shape2ShapeMap;
if ( !ProjectionUtils::FindSubShapeAssociation( outerShell, &aMesh,
innerShell, &aMesh,
shape2ShapeMap) ) {
std::vector<int> aResVec(SMDSEntity_Last);
for(int i=SMDSEntity_Node; i<SMDSEntity_Last; i++) aResVec[i] = 0;
SMESH_subMesh * sm = aMesh.GetSubMesh(aShape);
aResMap.insert(std::make_pair(sm,aResVec));
SMESH_ComputeErrorPtr& smError = sm->GetComputeError();
smError.reset( new SMESH_ComputeError(COMPERR_ALGO_FAILED,"Submesh can not be evaluated",this));
return false;
}
// get info for outer shell
int nb0d_Out=0, nb2d_3_Out=0, nb2d_4_Out=0;
//TopTools_SequenceOfShape FacesOut;
for (TopExp_Explorer exp(outerShell, TopAbs_FACE); exp.More(); exp.Next()) {
//FacesOut.Append(exp.Current());
SMESH_subMesh *aSubMesh = aMesh.GetSubMesh(exp.Current());
MapShapeNbElemsItr anIt = aResMap.find(aSubMesh);
std::vector<int> aVec = (*anIt).second;
nb0d_Out += aVec[SMDSEntity_Node];
nb2d_3_Out += Max(aVec[SMDSEntity_Triangle],aVec[SMDSEntity_Quad_Triangle]);
nb2d_4_Out += Max(aVec[SMDSEntity_Quadrangle],aVec[SMDSEntity_Quad_Quadrangle]);
}
int nb1d_Out = 0;
TopTools_MapOfShape tmpMap;
for (TopExp_Explorer exp(outerShell, TopAbs_EDGE); exp.More(); exp.Next()) {
if( tmpMap.Contains( exp.Current() ) )
continue;
tmpMap.Add( exp.Current() );
SMESH_subMesh *aSubMesh = aMesh.GetSubMesh(exp.Current());
MapShapeNbElemsItr anIt = aResMap.find(aSubMesh);
std::vector<int> aVec = (*anIt).second;
nb0d_Out += aVec[SMDSEntity_Node];
nb1d_Out += Max(aVec[SMDSEntity_Edge],aVec[SMDSEntity_Quad_Edge]);
}
tmpMap.Clear();
for (TopExp_Explorer exp(outerShell, TopAbs_VERTEX); exp.More(); exp.Next()) {
if( tmpMap.Contains( exp.Current() ) )
continue;
tmpMap.Add( exp.Current() );
nb0d_Out++;
}
// get info for inner shell
int nb0d_In=0, nb2d_3_In=0, nb2d_4_In=0;
//TopTools_SequenceOfShape FacesIn;
for (TopExp_Explorer exp(innerShell, TopAbs_FACE); exp.More(); exp.Next()) {
//FacesIn.Append(exp.Current());
SMESH_subMesh *aSubMesh = aMesh.GetSubMesh(exp.Current());
MapShapeNbElemsItr anIt = aResMap.find(aSubMesh);
std::vector<int> aVec = (*anIt).second;
nb0d_In += aVec[SMDSEntity_Node];
nb2d_3_In += Max(aVec[SMDSEntity_Triangle],aVec[SMDSEntity_Quad_Triangle]);
nb2d_4_In += Max(aVec[SMDSEntity_Quadrangle],aVec[SMDSEntity_Quad_Quadrangle]);
}
int nb1d_In = 0;
tmpMap.Clear();
bool IsQuadratic = false;
bool IsFirst = true;
for (TopExp_Explorer exp(innerShell, TopAbs_EDGE); exp.More(); exp.Next()) {
if( tmpMap.Contains( exp.Current() ) )
continue;
tmpMap.Add( exp.Current() );
SMESH_subMesh *aSubMesh = aMesh.GetSubMesh(exp.Current());
MapShapeNbElemsItr anIt = aResMap.find(aSubMesh);
std::vector<int> aVec = (*anIt).second;
nb0d_In += aVec[SMDSEntity_Node];
nb1d_In += Max(aVec[SMDSEntity_Edge],aVec[SMDSEntity_Quad_Edge]);
if(IsFirst) {
IsQuadratic = (aVec[SMDSEntity_Quad_Edge] > aVec[SMDSEntity_Edge]);
IsFirst = false;
}
}
tmpMap.Clear();
for (TopExp_Explorer exp(innerShell, TopAbs_VERTEX); exp.More(); exp.Next()) {
//.........这里部分代码省略.........
示例8: Max
bool NETGENPlugin_NETGEN_2D_ONLY::Evaluate(SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape,
MapShapeNbElems& aResMap)
{
TopoDS_Face F = TopoDS::Face(aShape);
if(F.IsNull())
return false;
// collect info from edges
int nb0d = 0, nb1d = 0;
bool IsQuadratic = false;
bool IsFirst = true;
double fullLen = 0.0;
TopTools_MapOfShape tmpMap;
for (TopExp_Explorer exp(F, TopAbs_EDGE); exp.More(); exp.Next()) {
TopoDS_Edge E = TopoDS::Edge(exp.Current());
if( tmpMap.Contains(E) )
continue;
tmpMap.Add(E);
SMESH_subMesh *aSubMesh = aMesh.GetSubMesh(exp.Current());
MapShapeNbElemsItr anIt = aResMap.find(aSubMesh);
if( anIt==aResMap.end() ) {
SMESH_subMesh *sm = aMesh.GetSubMesh(F);
SMESH_ComputeErrorPtr& smError = sm->GetComputeError();
smError.reset( new SMESH_ComputeError(COMPERR_ALGO_FAILED,"Submesh can not be evaluated",this));
return false;
}
std::vector<int> aVec = (*anIt).second;
nb0d += aVec[SMDSEntity_Node];
nb1d += Max(aVec[SMDSEntity_Edge],aVec[SMDSEntity_Quad_Edge]);
double aLen = SMESH_Algo::EdgeLength(E);
fullLen += aLen;
if(IsFirst) {
IsQuadratic = (aVec[SMDSEntity_Quad_Edge] > aVec[SMDSEntity_Edge]);
IsFirst = false;
}
}
tmpMap.Clear();
// compute edge length
double ELen = 0;
if (_hypLengthFromEdges || (!_hypLengthFromEdges && !_hypMaxElementArea)) {
if ( nb1d > 0 )
ELen = fullLen / nb1d;
}
if ( _hypMaxElementArea ) {
double maxArea = _hypMaxElementArea->GetMaxArea();
ELen = sqrt(2. * maxArea/sqrt(3.0));
}
GProp_GProps G;
BRepGProp::SurfaceProperties(F,G);
double anArea = G.Mass();
const int hugeNb = numeric_limits<int>::max()/10;
if ( anArea / hugeNb > ELen*ELen )
{
SMESH_subMesh *sm = aMesh.GetSubMesh(F);
SMESH_ComputeErrorPtr& smError = sm->GetComputeError();
smError.reset( new SMESH_ComputeError(COMPERR_ALGO_FAILED,"Submesh can not be evaluated.\nToo small element length",this));
return false;
}
int nbFaces = (int) ( anArea / ( ELen*ELen*sqrt(3.) / 4 ) );
int nbNodes = (int) ( ( nbFaces*3 - (nb1d-1)*2 ) / 6 + 1 );
std::vector<int> aVec(SMDSEntity_Last);
for(int i=SMDSEntity_Node; i<SMDSEntity_Last; i++) aVec[i]=0;
if( IsQuadratic ) {
aVec[SMDSEntity_Node] = nbNodes;
aVec[SMDSEntity_Quad_Triangle] = nbFaces;
}
else {
aVec[SMDSEntity_Node] = nbNodes;
aVec[SMDSEntity_Triangle] = nbFaces;
}
SMESH_subMesh *sm = aMesh.GetSubMesh(F);
aResMap.insert(std::make_pair(sm,aVec));
return true;
}