本文整理汇总了C++中TopoDS_Iterator类的典型用法代码示例。如果您正苦于以下问题:C++ TopoDS_Iterator类的具体用法?C++ TopoDS_Iterator怎么用?C++ TopoDS_Iterator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TopoDS_Iterator类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: It
//=======================================================================
//function : AddSimpleShapes
//purpose :
//=======================================================================
void GEOMUtils::AddSimpleShapes (const TopoDS_Shape& theShape, TopTools_ListOfShape& theList)
{
if (theShape.ShapeType() != TopAbs_COMPOUND &&
theShape.ShapeType() != TopAbs_COMPSOLID) {
theList.Append(theShape);
return;
}
TopTools_MapOfShape mapShape;
TopoDS_Iterator It (theShape, Standard_True, Standard_True);
for (; It.More(); It.Next()) {
TopoDS_Shape aShape_i = It.Value();
if (mapShape.Add(aShape_i)) {
if (aShape_i.ShapeType() == TopAbs_COMPOUND ||
aShape_i.ShapeType() == TopAbs_COMPSOLID) {
AddSimpleShapes(aShape_i, theList);
} else {
theList.Append(aShape_i);
}
}
}
}
示例2: isGoodForChamfer
//=======================================================================
//function : isGoodForChamfer
//purpose :
//=======================================================================
static Standard_Boolean isGoodForChamfer (const TopoDS_Shape& theShape)
{
if (theShape.ShapeType() == TopAbs_SHELL ||
theShape.ShapeType() == TopAbs_SOLID ||
theShape.ShapeType() == TopAbs_COMPSOLID) {
return Standard_True;
}
if (theShape.ShapeType() == TopAbs_COMPOUND) {
TopTools_MapOfShape mapShape;
TopoDS_Iterator It (theShape, Standard_False, Standard_False);
for (; It.More(); It.Next()) {
if (mapShape.Add(It.Value())) {
if (!isGoodForChamfer(It.Value())) {
return Standard_False;
}
}
}
return Standard_True;
}
return Standard_False;
}
示例3: FillImagesContainers
//=======================================================================
// function: FillImagesContainers
// purpose:
//=======================================================================
void GEOMAlgo_Builder::FillImagesContainers(const TopAbs_ShapeEnum theType)
{
myErrorStatus=0;
//
Standard_Boolean bInterferred, bToReverse;
Standard_Integer i, aNbS;
TopAbs_ShapeEnum aType;
BRep_Builder aBB;
TopoDS_Iterator aIt;
TopTools_ListIteratorOfListOfShape aItIm;
TopTools_MapOfShape aMS;
TopTools_MapIteratorOfMapOfShape aItS;
//
const NMTDS_ShapesDataStructure& aDS=*myPaveFiller->DS();
NMTTools_PaveFiller* pPF=myPaveFiller;
const Handle(IntTools_Context)& aCtx= pPF->Context();
//
aNbS=aDS.NumberOfShapesOfTheObject();
for (i=1; i<=aNbS; ++i) {
const TopoDS_Shape& aC=aDS.Shape(i);
aType=aC.ShapeType();
if (aType==theType) {
aMS.Add(aC);
}
}
//
if (theType==TopAbs_COMPOUND) {
FillImagesCompounds(aMS, myImages);
return;
}
//
aItS.Initialize(aMS);
for (; aItS.More(); aItS.Next()) {
const TopoDS_Shape& aC=aItS.Key();
// whether the shape has image
bInterferred=Standard_False;
aIt.Initialize(aC);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aF=aIt.Value();
if (myImages.HasImage(aF)) {
bInterferred=!bInterferred;
break;
}
}
if (!bInterferred) {
continue;
}
//
TopoDS_Shape aCIm;
GEOMAlgo_Tools3D::MakeContainer(theType, aCIm);
//
aIt.Initialize(aC);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aF=aIt.Value();
if (myImages.HasImage(aF)) {
const TopTools_ListOfShape& aLFIm=myImages.Image(aF);
aItIm.Initialize(aLFIm);
for (; aItIm.More(); aItIm.Next()) {
TopoDS_Shape aFIm=aItIm.Value();
//
bToReverse=GEOMAlgo_Tools3D::IsSplitToReverse(aFIm, aF, aCtx);
if (bToReverse) {
aFIm.Reverse();
}
aBB.Add(aCIm, aFIm);
}
}
else {
aBB.Add(aCIm, aF);
}
}
myImages.Bind(aC, aCIm);
}// for (; aItS.More(); aItS.Next()) {
}
示例4: BRepBuilderAPI_MakeVertex
//=======================================================================
//function : MakeScaledPrism
//purpose :
//=======================================================================
TopoDS_Shape GEOMImpl_PrismDriver::MakeScaledPrism (const TopoDS_Shape& theShapeBase,
const gp_Vec& theVector,
const Standard_Real theScaleFactor,
const gp_Pnt& theCDG,
bool isCDG)
{
TopoDS_Shape aShape;
BRep_Builder B;
// 1. aCDG = geompy.MakeCDG(theBase)
gp_Pnt aCDG = theCDG;
if (!isCDG) {
gp_Ax3 aPos = GEOMImpl_IMeasureOperations::GetPosition(theShapeBase);
aCDG = aPos.Location();
}
TopoDS_Shape aShapeCDG_1 = BRepBuilderAPI_MakeVertex(aCDG).Shape();
// Process case of several given shapes
if (theShapeBase.ShapeType() == TopAbs_COMPOUND ||
theShapeBase.ShapeType() == TopAbs_SHELL) {
int nbSub = 0;
TopoDS_Shape aShapeI;
TopoDS_Compound aCompound;
B.MakeCompound(aCompound);
TopoDS_Iterator It (theShapeBase, Standard_True, Standard_True);
for (; It.More(); It.Next()) {
nbSub++;
aShapeI = MakeScaledPrism(It.Value(), theVector, theScaleFactor, aCDG, true);
B.Add(aCompound, aShapeI);
}
if (nbSub == 1)
aShape = aShapeI;
else if (nbSub > 1)
aShape = GEOMImpl_GlueDriver::GlueFaces(aCompound, Precision::Confusion(), Standard_True);
return aShape;
}
// 2. Scale = geompy.MakeScaleTransform(theBase, aCDG, theScaleFactor)
// Bug 6839: Check for standalone (not included in faces) degenerated edges
TopTools_IndexedDataMapOfShapeListOfShape aEFMap;
TopExp::MapShapesAndAncestors(theShapeBase, TopAbs_EDGE, TopAbs_FACE, aEFMap);
Standard_Integer i, nbE = aEFMap.Extent();
for (i = 1; i <= nbE; i++) {
TopoDS_Shape anEdgeSh = aEFMap.FindKey(i);
if (BRep_Tool::Degenerated(TopoDS::Edge(anEdgeSh))) {
const TopTools_ListOfShape& aFaces = aEFMap.FindFromIndex(i);
if (aFaces.IsEmpty())
Standard_ConstructionError::Raise
("Scaling aborted : cannot scale standalone degenerated edge");
}
}
// Perform Scaling
gp_Trsf aTrsf;
aTrsf.SetScale(aCDG, theScaleFactor);
BRepBuilderAPI_Transform aBRepTrsf (theShapeBase, aTrsf, Standard_False);
TopoDS_Shape aScale = aBRepTrsf.Shape();
// 3. aBase2 = geompy.MakeTranslationVectorDistance(Scale, theVec, theH)
gp_Trsf aTrsf3;
aTrsf3.SetTranslation(theVector);
TopLoc_Location aLocOrig = aScale.Location();
gp_Trsf aTrsfOrig = aLocOrig.Transformation();
TopLoc_Location aLocRes (aTrsf3 * aTrsfOrig);
TopoDS_Shape aBase2 = aScale.Located(aLocRes);
// 4. aCDG_2 = geompy.MakeTranslationVectorDistance(aCDG, theVec, theH)
gp_Pnt aCDG_2 = aCDG.Translated(theVector);
TopoDS_Shape aShapeCDG_2 = BRepBuilderAPI_MakeVertex(aCDG_2).Shape();
// 5. Vector = geompy.MakeVector(aCDG, aCDG_2)
TopoDS_Shape aShapeVec = BRepBuilderAPI_MakeEdge(aCDG, aCDG_2).Shape();
TopoDS_Edge anEdge = TopoDS::Edge(aShapeVec);
TopoDS_Wire aWirePath = BRepBuilderAPI_MakeWire(anEdge);
// 6. aPrism = geompy.MakePipeWithDifferentSections([theBase, aBase2], [aCDG, aCDG_2], Vector, False, False)
Handle(TopTools_HSequenceOfShape) aBases = new TopTools_HSequenceOfShape;
aBases->Append(theShapeBase);
aBases->Append(aBase2);
Handle(TopTools_HSequenceOfShape) aLocs = new TopTools_HSequenceOfShape;
aLocs->Append(aShapeCDG_1);
aLocs->Append(aShapeCDG_2);
aShape = GEOMImpl_PipeDriver::CreatePipeWithDifferentSections(aWirePath, aBases, aLocs, false, false);
// 7. Make a solid, if possible
if (theShapeBase.ShapeType() == TopAbs_FACE) {
BRepBuilderAPI_Sewing aSewing (Precision::Confusion()*10.0);
TopExp_Explorer expF (aShape, TopAbs_FACE);
Standard_Integer ifa = 0;
for (; expF.More(); expF.Next()) {
aSewing.Add(expF.Current());
ifa++;
}
//.........这里部分代码省略.........
示例5: Init
//===========================================================================
//function : Init
//purpose :
//===========================================================================
void NMTDS_ShapesDataStructure::Init()
{
Standard_Integer i, j, aNbSx, aNbS, aShift, aNbRanges;
Standard_Integer iFirst, iLast;
NMTDS_ListOfIndexedDataMapOfShapeAncestorsSuccessors aLx;
NMTDS_ListIteratorOfListOfIndexedDataMapOfShapeAncestorsSuccessors aLit;
TopoDS_Iterator anIt;
BooleanOperations_IndexedDataMapOfShapeAncestorsSuccessors aMSA;
//
anIt.Initialize(myCompositeShape);
for (; anIt.More(); anIt.Next()) {
const TopoDS_Shape& aSx=anIt.Value();
BooleanOperations_IndexedDataMapOfShapeAncestorsSuccessors aMS;
//
if (!aMSA.Contains(aSx)) {
FillMap(aSx, aMSA, aMS);
aLx.Append(aMS);
}
}
aNbS=aMSA.Extent();
//
// Fill myRanges
i=aLx.Extent();
myRanges.Resize(i);
aLit.Initialize(aLx);
for (i=1; aLit.More(); aLit.Next(), ++i) {
const BooleanOperations_IndexedDataMapOfShapeAncestorsSuccessors& aMSx=aLit.Value();
aNbSx=aMSx.Extent();
if (i==1) {
iFirst=1;
iLast=aNbSx;
myRanges(i).SetFirst(iFirst);
myRanges(i).SetLast(iLast);
continue;
}
iFirst=myRanges(i-1).Last()+1;
iLast=iFirst+aNbSx-1;
myRanges(i).SetFirst(iFirst);
myRanges(i).SetLast(iLast);
}
//
myNumberOfShapesOfTheObject=aNbS;
myNumberOfShapesOfTheTool=0;
myLength=2*aNbS;
//
// Allocate the whole Table
myListOfShapeAndInterferences = (BooleanOperations_PShapeAndInterferences)
Standard::Allocate(myLength*sizeof(BooleanOperations_ShapeAndInterferences));
//
// Fill the table
aShift=0;
for (j=1; j<=aNbS; ++j) {
const TopoDS_Shape& aSx=aMSA.FindKey(j);
const BooleanOperations_AncestorsSeqAndSuccessorsSeq& aASx=aMSA.FindFromIndex(j);
InsertShapeAndAncestorsSuccessors(aSx, aASx, aShift);
}
// myShapeIndexMap
myShapeIndexMap.Clear();
//
//modified by NIZNHY-PKV Mon Dec 12 09:01:53 2011f
aNbRanges=myRanges.Extent();
for (i=1; i<=aNbRanges; ++i){
const NMTDS_IndexRange& aR=myRanges(i);
iFirst=aR.First();
iLast =aR.Last();
for (j=iFirst; j<=iLast; ++j) {
const TopoDS_Shape& aS=Shape(j);
myShapeIndexMap.Bind(aS, j);
}
}
//modified by NIZNHY-PKV Mon Dec 12 09:02:00 2011t
//
// myRefEdges
iLast=myNumberOfShapesOfTheObject+myNumberOfShapesOfTheTool;
myRefEdges.Resize(iLast);
for (i=1; i<=iLast; ++i) {
const TopoDS_Shape& aS=Shape(i);
myRefEdges(i)=0;
if (aS.ShapeType()==TopAbs_EDGE) {
myNbEdges++;
myRefEdges(i)=myNbEdges;
}
}
}
示例6: Handle
//=======================================================================
//function :FillInternalShapes
//purpose :
//=======================================================================
void GEOMAlgo_Builder::FillInternalShapes()
{
myErrorStatus=0;
//
const NMTDS_ShapesDataStructure& aDS=*myPaveFiller->DS();
NMTTools_PaveFiller* pPF=myPaveFiller;
const Handle(IntTools_Context)& aCtx= pPF->Context();
//
//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
//
// 1.1 Shapes from pure arguments aMSI
// 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)) {
aLSI.Append(aS);
}
}
}
// 1.1.2 wire
{
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()) {
const TopoDS_Shape& aE=aItS.Value();
if (aMFence.Add(aE)) {
aLSI.Append(aE);
}
}
}
}
// 1.1.3 theirs images/sources
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()) {
const TopoDS_Shape& aSI=aIt.Value();
aMSI.Add(aSI);
}
}
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) {
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 {
//.........这里部分代码省略.........
示例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: SMESH_MesherHelper
bool StdMeshers_RadialPrism_3D::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape)
{
TopExp_Explorer exp;
SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
myHelper = new SMESH_MesherHelper( aMesh );
myHelper->IsQuadraticSubMesh( aShape );
// to delete helper at exit from Compute()
std::auto_ptr<SMESH_MesherHelper> helperDeleter( myHelper );
// 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 )
return error(COMPERR_BAD_SHAPE, SMESH_Comment("Must be 2 shells but not ")<<nbShells);
// ----------------------------------
// Associate sub-shapes of the shells
// ----------------------------------
ProjectionUtils::TShapeShapeMap shape2ShapeMaps[2];
bool mapOk1 = ProjectionUtils::FindSubShapeAssociation( innerShell, &aMesh,
outerShell, &aMesh,
shape2ShapeMaps[0]);
bool mapOk2 = ProjectionUtils::FindSubShapeAssociation( innerShell.Reversed(), &aMesh,
outerShell, &aMesh,
shape2ShapeMaps[1]);
if ( !mapOk1 && !mapOk2 )
return error(COMPERR_BAD_SHAPE,"Topology of inner and outer shells seems different" );
int iMap;
if ( shape2ShapeMaps[0].Extent() == shape2ShapeMaps[1].Extent() )
{
// choose an assiciation by shortest distance between VERTEXes
double dist1 = 0, dist2 = 0;
TopTools_DataMapIteratorOfDataMapOfShapeShape ssIt( shape2ShapeMaps[0]._map1to2 );
for (; ssIt.More(); ssIt.Next() )
{
if ( ssIt.Key().ShapeType() != TopAbs_VERTEX ) continue;
gp_Pnt pIn = BRep_Tool::Pnt( TopoDS::Vertex( ssIt.Key() ));
gp_Pnt pOut1 = BRep_Tool::Pnt( TopoDS::Vertex( ssIt.Value() ));
gp_Pnt pOut2 = BRep_Tool::Pnt( TopoDS::Vertex( shape2ShapeMaps[1]( ssIt.Key() )));
dist1 += pIn.SquareDistance( pOut1 );
dist2 += pIn.SquareDistance( pOut2 );
}
iMap = ( dist1 < dist2 ) ? 0 : 1;
}
else
{
iMap = ( shape2ShapeMaps[0].Extent() > shape2ShapeMaps[1].Extent() ) ? 0 : 1;
}
ProjectionUtils::TShapeShapeMap& shape2ShapeMap = shape2ShapeMaps[iMap];
// ------------------
// Make mesh
// ------------------
TNode2ColumnMap node2columnMap;
myLayerPositions.clear();
for ( exp.Init( outerShell, TopAbs_FACE ); exp.More(); exp.Next() )
{
// Corresponding sub-shapes
TopoDS_Face outFace = TopoDS::Face( exp.Current() );
TopoDS_Face inFace;
if ( !shape2ShapeMap.IsBound( outFace, /*isOut=*/true )) {
return error(SMESH_Comment("Corresponding inner face not found for face #" )
<< meshDS->ShapeToIndex( outFace ));
} else {
inFace = TopoDS::Face( shape2ShapeMap( outFace, /*isOut=*/true ));
}
// Find matching nodes of in and out faces
ProjectionUtils::TNodeNodeMap nodeIn2OutMap;
if ( ! ProjectionUtils::FindMatchingNodesOnFaces( inFace, &aMesh, outFace, &aMesh,
shape2ShapeMap, nodeIn2OutMap ))
return error(COMPERR_BAD_INPUT_MESH,SMESH_Comment("Mesh on faces #")
<< meshDS->ShapeToIndex( outFace ) << " and "
<< meshDS->ShapeToIndex( inFace ) << " seems different" );
// Create volumes
SMDS_ElemIteratorPtr faceIt = meshDS->MeshElements( inFace )->GetElements();
while ( faceIt->more() ) // loop on faces on inFace
{
const SMDS_MeshElement* face = faceIt->next();
if ( !face || face->GetType() != SMDSAbs_Face )
continue;
int nbNodes = face->NbNodes();
if ( face->IsQuadratic() )
nbNodes /= 2;
// find node columns for each node
vector< const TNodeColumn* > columns( nbNodes );
for ( int i = 0; i < nbNodes; ++i )
//.........这里部分代码省略.........
示例9: SMESH_MesherHelper
bool StdMeshers_RadialPrism_3D::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape)
{
TopExp_Explorer exp;
SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
myHelper = new SMESH_MesherHelper( aMesh );
myHelper->IsQuadraticSubMesh( aShape );
// to delete helper at exit from Compute()
std::auto_ptr<SMESH_MesherHelper> helperDeleter( myHelper );
// 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 )
return error(COMPERR_BAD_SHAPE, SMESH_Comment("Must be 2 shells but not ")<<nbShells);
// ----------------------------------
// Associate subshapes of the shells
// ----------------------------------
TAssocTool::TShapeShapeMap shape2ShapeMap;
if ( !TAssocTool::FindSubShapeAssociation( outerShell, &aMesh,
innerShell, &aMesh,
shape2ShapeMap) )
return error(COMPERR_BAD_SHAPE,"Topology of inner and outer shells seems different" );
// ------------------
// Make mesh
// ------------------
TNode2ColumnMap node2columnMap;
myLayerPositions.clear();
for ( exp.Init( outerShell, TopAbs_FACE ); exp.More(); exp.Next() )
{
// Corresponding subshapes
TopoDS_Face outFace = TopoDS::Face( exp.Current() );
TopoDS_Face inFace;
if ( !shape2ShapeMap.IsBound( outFace )) {
return error(SMESH_Comment("Corresponding inner face not found for face #" )
<< meshDS->ShapeToIndex( outFace ));
} else {
inFace = TopoDS::Face( shape2ShapeMap( outFace ));
}
// Find matching nodes of in and out faces
TNodeNodeMap nodeIn2OutMap;
if ( ! TAssocTool::FindMatchingNodesOnFaces( inFace, &aMesh, outFace, &aMesh,
shape2ShapeMap, nodeIn2OutMap ))
return error(COMPERR_BAD_INPUT_MESH,SMESH_Comment("Mesh on faces #")
<< meshDS->ShapeToIndex( outFace ) << " and "
<< meshDS->ShapeToIndex( inFace ) << " seems different" );
// Create volumes
SMDS_ElemIteratorPtr faceIt = meshDS->MeshElements( inFace )->GetElements();
while ( faceIt->more() ) // loop on faces on inFace
{
const SMDS_MeshElement* face = faceIt->next();
if ( !face || face->GetType() != SMDSAbs_Face )
continue;
int nbNodes = face->NbNodes();
if ( face->IsQuadratic() )
nbNodes /= 2;
// find node columns for each node
vector< const TNodeColumn* > columns( nbNodes );
for ( int i = 0; i < nbNodes; ++i )
{
const SMDS_MeshNode* nIn = face->GetNode( i );
TNode2ColumnMap::iterator n_col = node2columnMap.find( nIn );
if ( n_col != node2columnMap.end() ) {
columns[ i ] = & n_col->second;
}
else {
TNodeNodeMap::iterator nInOut = nodeIn2OutMap.find( nIn );
if ( nInOut == nodeIn2OutMap.end() )
RETURN_BAD_RESULT("No matching node for "<< nIn->GetID() <<
" in face "<< face->GetID());
columns[ i ] = makeNodeColumn( node2columnMap, nIn, nInOut->second );
}
}
StdMeshers_Prism_3D::AddPrisms( columns, myHelper );
}
} // loop on faces of out shell
return true;
}
示例10: ImportSTEP
STEPIMPORT_EXPORT
TopoDS_Shape ImportSTEP (const TCollection_AsciiString& theFileName,
const TCollection_AsciiString& /*theFormatName*/,
TCollection_AsciiString& theError,
const TDF_Label& theShapeLabel)
{
MESSAGE("Import STEP model from file " << theFileName.ToCString());
// Set "C" numeric locale to save numbers correctly
//Kernel_Utils::Localizer loc;
TopoDS_Shape aResShape;
//VRV: OCC 4.0 migration
STEPControl_Reader aReader;
//VSR: 16/09/09: Convert to METERS
Interface_Static::SetCVal("xstep.cascade.unit","M");
Interface_Static::SetIVal("read.step.ideas", 1);
Interface_Static::SetIVal("read.step.nonmanifold", 1);
//VRV: OCC 4.0 migration
TopoDS_Compound compound;
BRep_Builder B;
B.MakeCompound(compound);
try {
#if OCC_VERSION_LARGE > 0x06010000
OCC_CATCH_SIGNALS;
#endif
IFSelect_ReturnStatus status = aReader.ReadFile(theFileName.ToCString());
if (status == IFSelect_RetDone) {
Standard_Boolean failsonly = Standard_False;
aReader.PrintCheckLoad(failsonly, IFSelect_ItemsByEntity);
/* Root transfers */
Standard_Integer nbr = aReader.NbRootsForTransfer();
aReader.PrintCheckTransfer(failsonly, IFSelect_ItemsByEntity);
for (Standard_Integer n = 1; n <= nbr; n++) {
Standard_Boolean ok = aReader.TransferRoot(n);
/* Collecting resulting entities */
Standard_Integer nbs = aReader.NbShapes();
if (!ok || nbs == 0)
{
// THROW_SALOME_CORBA_EXCEPTION("Exception catched in GEOM_Gen_i::ImportStep", SALOME::BAD_PARAM);
continue; // skip empty root
}
/* For a single entity */
else if (nbr == 1 && nbs == 1) {
aResShape = aReader.Shape(1);
// ATTENTION: this is a workaround for mantis issue 0020442 remark 0010776
// It should be removed after patching OCCT for bug OCC22436
// (fix for OCCT is expected in service pack next to OCCT6.3sp12)
if (aResShape.ShapeType() == TopAbs_COMPOUND) {
int nbSub1 = 0;
TopoDS_Shape currShape;
TopoDS_Iterator It (aResShape, Standard_True, Standard_True);
for (; It.More(); It.Next()) {
nbSub1++;
currShape = It.Value();
}
if (nbSub1 == 1)
aResShape = currShape;
}
// END workaround
break;
}
for (Standard_Integer i = 1; i <= nbs; i++) {
TopoDS_Shape aShape = aReader.Shape(i);
if (aShape.IsNull()) {
// THROW_SALOME_CORBA_EXCEPTION("Null shape in GEOM_Gen_i::ImportStep", SALOME::BAD_PARAM) ;
//return aResShape;
continue;
}
else {
B.Add(compound, aShape);
}
}
}
if (aResShape.IsNull())
aResShape = compound;
// BEGIN: Store names of sub-shapes from file
TopTools_IndexedMapOfShape anIndices;
TopExp::MapShapes(aResShape, anIndices);
Handle(Interface_InterfaceModel) Model = aReader.WS()->Model();
Handle(XSControl_TransferReader) TR = aReader.WS()->TransferReader();
if (!TR.IsNull()) {
Handle(Transfer_TransientProcess) TP = TR->TransientProcess();
Handle(Standard_Type) tPD = STANDARD_TYPE(StepBasic_ProductDefinition);
Handle(Standard_Type) tShape = STANDARD_TYPE(StepShape_TopologicalRepresentationItem);
Handle(Standard_Type) tGeom = STANDARD_TYPE(StepGeom_GeometricRepresentationItem);
Standard_Integer nb = Model->NbEntities();
for (Standard_Integer ie = 1; ie <= nb; ie++) {
Handle(Standard_Transient) enti = Model->Value(ie);
Handle(TCollection_HAsciiString) aName;
if ( enti->IsKind( tShape ) || enti->IsKind(tGeom))
{
aName = Handle(StepRepr_RepresentationItem)::DownCast(enti)->Name();
}
else if (enti->DynamicType() == tPD)
{
//.........这里部分代码省略.........
示例11: CheckGProps
//=======================================================================
//function : CheckGProps
//purpose :
//=======================================================================
void GEOMAlgo_GetInPlace::CheckGProps(const TopoDS_Shape& aS1)
{
Standard_Boolean bOnlyClosed;
Standard_Integer iDim, aNbS2;
Standard_Real aMass1, aMass2, aD2, aTolCG2, dM;
TopAbs_ShapeEnum aType1;
gp_Pnt aCG1, aCG2;
TopoDS_Iterator aIt;
TopoDS_Compound aC2;
BRep_Builder aBB;
TopTools_ListIteratorOfListOfShape aItLS;
//
myErrorStatus=0;
//
aType1=aS1.ShapeType();
if (aType1==TopAbs_COMPOUND) {
aIt.Initialize(aS1);
for(; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aS1x=aIt.Value();
CheckGProps(aS1x);
if (!myFound) {
return;
}
}
}
//
iDim=Dimension(aType1);
//
if (!myImages.IsBound(aS1)) {
// it should not be.
return;
}
const TopTools_ListOfShape& aLS2=myImages.Find(aS1);
aNbS2=aLS2.Extent();
if (!aNbS2) {
// it should not be.
return;
}
//
aBB.MakeCompound(aC2);
aItLS.Initialize(aLS2);
for (; aItLS.More(); aItLS.Next()) {
const TopoDS_Shape& aS2x=aItLS.Value();
aBB.Add(aC2, aS2x);
}
//-------------------------
GProp_GProps aG1, aG2;
//
aTolCG2=myTolCG*myTolCG;
bOnlyClosed=Standard_False;
//
if (iDim==0) {
PointProperties(aS1, aG1);
PointProperties(aC2, aG2);
}
else if (iDim==1) {
BRepGProp::LinearProperties(aS1, aG1);
BRepGProp::LinearProperties(aC2, aG2);
}
else if (iDim==2) {
BRepGProp::SurfaceProperties(aS1, aG1);
BRepGProp::SurfaceProperties(aC2, aG2);
}
else if (iDim==3) {
BRepGProp::VolumeProperties(aS1, aG1, bOnlyClosed);
BRepGProp::VolumeProperties(aC2, aG2, bOnlyClosed);
}
//
aMass1=aG1.Mass();
aMass2=aG2.Mass();
aCG1=aG1.CentreOfMass();
aCG2=aG2.CentreOfMass();
//
dM=fabs(aMass1-aMass2);
if (aMass1 > myTolMass) {
dM=dM/aMass1;
}
//
aD2=aCG1.SquareDistance(aCG2);
//
if ((dM > myTolMass) || (aD2 > aTolCG2)) {
myFound=Standard_False;
return;
}
myFound=Standard_True;
}
示例12: itr
Standard_Boolean ShHealOper_ChangeOrientation::Perform()
{
BRep_Builder B;
if (myInitShape.ShapeType() == TopAbs_SHELL) {
myResultShape = myInitShape.EmptyCopied();
TopoDS_Iterator itr (myInitShape);
while (itr.More()) {
B.Add(myResultShape,itr.Value().Reversed());
itr.Next();
}
}
else if (myInitShape.ShapeType() == TopAbs_FACE) {
myResultShape = myInitShape.EmptyCopied();
TopoDS_Iterator itr (myInitShape);
while (itr.More()) {
B.Add(myResultShape,itr.Value());
itr.Next();
}
myResultShape.Reverse();
}
else if ( myInitShape.ShapeType() == TopAbs_WIRE || myInitShape.ShapeType() == TopAbs_EDGE) {
myResultShape = myInitShape.EmptyCopied();
TopoDS_Iterator itr (myInitShape);
while (itr.More()) {
B.Add(myResultShape,itr.Value());
itr.Next();
}
myResultShape.Reverse();
}
else {
BRepBuilderAPI_Copy Copy (myInitShape);
if (!Copy.IsDone()) return false;
myResultShape = Copy.Shape();
if (myResultShape.IsNull()) return false;
if (myResultShape.Orientation() == TopAbs_FORWARD)
myResultShape.Orientation(TopAbs_REVERSED);
else
myResultShape.Orientation(TopAbs_FORWARD);
}
return true;
}
示例13: PerformInternalShapes
//=======================================================================
//function : PerformInternalShapes
//purpose :
//=======================================================================
void GEOMAlgo_BuilderFace::PerformInternalShapes()
{
myErrorStatus=0;
//
Standard_Integer aNbWI=myLoopsInternal.Extent();
if (!aNbWI) {// nothing to do
return;
}
//
//Standard_Real aTol;
BRep_Builder aBB;
TopTools_ListIteratorOfListOfShape aIt1, aIt2;
TopoDS_Iterator aIt;
TopTools_MapOfShape aME, aMEP;
TopTools_MapIteratorOfMapOfShape aItME;
TopTools_IndexedDataMapOfShapeListOfShape aMVE;
TopTools_ListOfShape aLSI;
//
// 1. All internal edges
aIt1.Initialize(myLoopsInternal);
for (; aIt1.More(); aIt1.Next()) {
const TopoDS_Shape& aWire=aIt1.Value();
aIt.Initialize(aWire);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aE=aIt.Value();
aME.Add(aE);
}
}
aNbWI=aME.Extent();
//
// 2 Process faces
aIt2.Initialize(myAreas);
for ( ; aIt2.More(); aIt2.Next()) {
TopoDS_Face& aF=TopoDS::Face(aIt2.Value());
//
aMVE.Clear();
TopExp::MapShapesAndAncestors(aF, TopAbs_VERTEX, TopAbs_EDGE, aMVE);
//
// 2.1 Separate faces to process aMEP
aMEP.Clear();
aItME.Initialize(aME);
for (; aItME.More(); aItME.Next()) {
const TopoDS_Edge& aE=TopoDS::Edge(aItME.Key());
if (IsInside(aE, aF, myContext)) {
aMEP.Add(aE);
}
}
//
// 2.2 Make Internal Wires
aLSI.Clear();
MakeInternalWires(aMEP, aLSI);
//
// 2.3 Add them to aF
aIt1.Initialize(aLSI);
for (; aIt1.More(); aIt1.Next()) {
const TopoDS_Shape& aSI=aIt1.Value();
aBB.Add (aF, aSI);
}
//
// 2.4 Remove faces aMFP from aMF
aItME.Initialize(aMEP);
for (; aItME.More(); aItME.Next()) {
const TopoDS_Shape& aE=aItME.Key();
aME.Remove(aE);
}
//
aNbWI=aME.Extent();
if (!aNbWI) {
break;
}
} //for ( ; aIt2.More(); aIt2.Next()) {
}
示例14: aItE
//=======================================================================
//function : PerformLoops
//purpose :
//=======================================================================
void GEOMAlgo_BuilderFace::PerformLoops()
{
myErrorStatus=0;
//
Standard_Boolean bFlag;
Standard_Integer aNbEA;
TopTools_ListIteratorOfListOfShape aIt;
TopTools_MapIteratorOfMapOfOrientedShape aItM;
TopTools_IndexedDataMapOfShapeListOfShape aVEMap;
TopTools_MapOfOrientedShape aMAdded;
TopoDS_Iterator aItW;
BRep_Builder aBB;
GEOMAlgo_WireEdgeSet aWES;
GEOMAlgo_WESCorrector aWESCor;
//
// 1. Usual Wires
myLoops.Clear();
aWES.SetFace(myFace);
//
aIt.Initialize (myShapes);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aE=aIt.Value();
if (!myShapesToAvoid.Contains(aE)) {
aWES.AddStartElement(aE);
}
}
//
aWESCor.SetWES(aWES);
aWESCor.Perform();
//
GEOMAlgo_WireEdgeSet& aWESN=aWESCor.NewWES();
const TopTools_ListOfShape& aLW=aWESN.Shapes();
//
aIt.Initialize (aLW);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aW=aIt.Value();
myLoops.Append(aW);
}
//modified by NIZNHY-PKV Tue Aug 5 15:09:29 2008f
// Post Treatment
TopTools_MapOfOrientedShape aMEP;
//
// a. collect all edges that are in loops
aIt.Initialize (myLoops);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aW=aIt.Value();
aItW.Initialize(aW);
for (; aItW.More(); aItW.Next()) {
const TopoDS_Shape& aE=aItW.Value();
aMEP.Add(aE);
}
}
//
// b. collect all edges that are to avoid
aItM.Initialize(myShapesToAvoid);
for (; aItM.More(); aItM.Next()) {
const TopoDS_Shape& aE=aItM.Key();
aMEP.Add(aE);
}
//
// c. add all edges that are not processed to myShapesToAvoid
aIt.Initialize (myShapes);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aE=aIt.Value();
if (!aMEP.Contains(aE)) {
myShapesToAvoid.Add(aE);
}
}
//modified by NIZNHY-PKV Tue Aug 5 15:09:35 2008t
//
// 2. Internal Wires
myLoopsInternal.Clear();
//
aNbEA=myShapesToAvoid.Extent();
aItM.Initialize(myShapesToAvoid);
for (; aItM.More(); aItM.Next()) {
const TopoDS_Shape& aEE=aItM.Key();
TopExp::MapShapesAndAncestors(aEE, TopAbs_VERTEX, TopAbs_EDGE, aVEMap);
}
//
bFlag=Standard_True;
aItM.Initialize(myShapesToAvoid);
for (; aItM.More()&&bFlag; aItM.Next()) {
const TopoDS_Shape& aEE=aItM.Key();
if (!aMAdded.Add(aEE)) {
continue;
}
//
// make new wire
TopoDS_Wire aW;
aBB.MakeWire(aW);
aBB.Add(aW, aEE);
//
aItW.Initialize(aW);
for (; aItW.More()&&bFlag; aItW.Next()) {
const TopoDS_Edge& aE=TopoDS::Edge(aItW.Value());
//.........这里部分代码省略.........