本文整理汇总了C++中TopTools_MapOfShape类的典型用法代码示例。如果您正苦于以下问题:C++ TopTools_MapOfShape类的具体用法?C++ TopTools_MapOfShape怎么用?C++ TopTools_MapOfShape使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TopTools_MapOfShape类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CorrectWires
//=======================================================================
//function : CorrectWires
//purpose :
//=======================================================================
Standard_Boolean GEOMAlgo_Tools::CorrectWires(const TopoDS_Shape& aShape)
{
Standard_Boolean bRet;
TopoDS_Iterator aItF;
TopExp_Explorer aExp;
TopTools_MapOfShape aMF;
GeomAdaptor_Surface aGAS;
GeomAbs_SurfaceType aTS;
TopLoc_Location aLoc;
//
bRet=Standard_False;
//
aExp.Init(aShape, TopAbs_FACE);
for (; aExp.More(); aExp.Next()) {
const TopoDS_Face& aF=*((TopoDS_Face*)&aExp.Current());
if (aMF.Add(aF)) {
const Handle(Geom_Surface)& aS=BRep_Tool::Surface(aF, aLoc);
aGAS.Load(aS);
aTS=aGAS.GetType();
if (aTS==GeomAbs_Cylinder || aTS==GeomAbs_Plane) {
aItF.Initialize(aF);
for (; aItF.More(); aItF.Next()) {
const TopoDS_Wire& aW=*((TopoDS_Wire*)&aItF.Value());
if (CorrectWire(aW, aF)) {
bRet=Standard_True;
}
}
}
}
}
return bRet;
}
示例2:
//=======================================================================
//function : FillContainers
//purpose :
//=======================================================================
void GEOMAlgo_Gluer2::FillContainers(const TopAbs_ShapeEnum aType)
{
Standard_Boolean bHasImage, bToReverse;
Standard_Integer i, aNbW;
TopoDS_Shape aWnew, aEnew;
TopoDS_Iterator aItS;
BRep_Builder aBB;
TopTools_IndexedMapOfShape aMW;
TopTools_MapOfShape aMFence;
//
myErrorStatus=0;
myWarningStatus=0;
//
TopExp::MapShapes(myArgument, aType, aMW);
//
aNbW=aMW.Extent();
for (i=1; i<=aNbW; ++i) {
const TopoDS_Shape& aW=aMW(i);
//
if (!aMFence.Add(aW)) {
continue;
}
//
bHasImage=HasImage(aW);
if (!bHasImage) {
continue;
}
//
GEOMAlgo_Tools3D::MakeContainer(aType, aWnew);
aWnew.Orientation(aW.Orientation());
//
aItS.Initialize(aW);
for (; aItS.More(); aItS.Next()) {
const TopoDS_Shape& aE=aItS.Value();
if (myOrigins.IsBound(aE)) {
aEnew=myOrigins.Find(aE);
//
bToReverse=GEOMAlgo_Tools3D::IsSplitToReverse(aEnew, aE, myContext);
if (bToReverse) {
aEnew.Reverse();
}
//
aBB.Add(aWnew, aEnew);
}
else {
aBB.Add(aWnew, aE);
}
}
//
//myImages / myOrigins
TopTools_ListOfShape aLSD;
//
aLSD.Append(aW);
myImages.Bind(aWnew, aLSD);
myOrigins.Bind(aW, aWnew);
//
}//for (i=1; i<=aNbE; ++i) {
}
示例3: MakeBRepShapes
//=======================================================================
//function : FillBRepShapes
//purpose :
//=======================================================================
void GEOMAlgo_Gluer2::FillBRepShapes(const TopAbs_ShapeEnum theType)
{
Standard_Boolean bHasImage, bIsToWork;
Standard_Integer i, aNbE;
TopoDS_Iterator aItS;
TopoDS_Shape aEnew;
TopTools_IndexedMapOfShape aME;
TopTools_MapOfShape aMFence;
TopTools_ListIteratorOfListOfShape aItLS;
//
myErrorStatus=0;
myWarningStatus=0;
//
TopExp::MapShapes(myArgument, theType, aME);
//
aNbE=aME.Extent();
for (i=1; i<=aNbE; ++i) {
const TopoDS_Shape& aE=aME(i);
//
if (!aMFence.Add(aE)) {
continue;
}
//
bIsToWork=myOriginsToWork.IsBound(aE);
bHasImage=HasImage(aE);
if (!bHasImage && !bIsToWork) {
continue;
}
//
MakeBRepShapes(aE, aEnew);
//
//myImages / myOrigins
if (bIsToWork) {
const TopoDS_Shape& aSkey=myOriginsToWork.Find(aE);
const TopTools_ListOfShape& aLSD=myImagesToWork.Find(aSkey);
//
myImages.Bind(aEnew, aLSD);
//
aItLS.Initialize(aLSD);
for (; aItLS.More(); aItLS.Next()) {
const TopoDS_Shape& aEx=aItLS.Value();
myOrigins.Bind(aEx, aEnew);
//
aMFence.Add(aEx);
}
}
else {
TopTools_ListOfShape aLSD;
//
aLSD.Append(aE);
myImages.Bind(aEnew, aLSD);
myOrigins.Bind(aE, aEnew);
}
}//for (i=1; i<=aNbF; ++i) {
}
示例4: NbAncestors
int SMESH_MesherHelper::NbAncestors(const TopoDS_Shape& shape,
const SMESH_Mesh& mesh,
TopAbs_ShapeEnum ancestorType/*=TopAbs_SHAPE*/)
{
TopTools_MapOfShape ancestors;
TopTools_ListIteratorOfListOfShape ansIt( mesh.GetAncestors(shape) );
for ( ; ansIt.More(); ansIt.Next() ) {
if ( ancestorType == TopAbs_SHAPE || ansIt.Value().ShapeType() == ancestorType )
ancestors.Add( ansIt.Value() );
}
return ancestors.Extent();
}
示例5: SuppressFacesRec
//=======================================================================
//function : SupressFaces
//purpose :
//=======================================================================
void SuppressFacesRec (const TopTools_SequenceOfShape& theShapesFaces,
const TopoDS_Shape& theOriginalShape,
TopoDS_Shape& theOutShape)
{
if ((theOriginalShape.ShapeType() != TopAbs_COMPOUND &&
theOriginalShape.ShapeType() != TopAbs_COMPSOLID))
{
ShHealOper_RemoveFace aHealer (theOriginalShape);
Standard_Boolean aResult = aHealer.Perform(theShapesFaces);
if (aResult)
theOutShape = aHealer.GetResultShape();
else
raiseNotDoneExeption(aHealer.GetErrorStatus());
}
else
{
BRep_Builder BB;
TopoDS_Compound CC;
BB.MakeCompound(CC);
TopTools_MapOfShape mapShape;
TopoDS_Iterator It (theOriginalShape, Standard_True, Standard_True);
for (; It.More(); It.Next()) {
TopoDS_Shape aShape_i = It.Value();
if (mapShape.Add(aShape_i)) {
// check, if current shape contains at least one of faces to be removed
bool isFound = false;
TopTools_IndexedMapOfShape aShapes_i;
TopExp::MapShapes(aShape_i, aShapes_i);
for (int i = 1; i <= theShapesFaces.Length() && !isFound; i++) {
const TopoDS_Shape& aFace_i = theShapesFaces.Value(i);
if (aShapes_i.Contains(aFace_i)) isFound = true;
}
if (isFound) {
TopoDS_Shape anOutSh_i;
SuppressFacesRec(theShapesFaces, aShape_i, anOutSh_i);
if ( !anOutSh_i.IsNull() )
BB.Add(CC, anOutSh_i);
}
else {
// nothing to do
BB.Add(CC, aShape_i);
}
}
}
theOutShape = CC;
}
}
示例6: MakeInternalWires
//=======================================================================
//function : MakeInternalWires
//purpose :
//=======================================================================
void MakeInternalWires(const TopTools_MapOfShape& theME,
TopTools_ListOfShape& theWires)
{
TopTools_MapIteratorOfMapOfShape aItM;
TopTools_MapOfShape aAddedMap;
TopTools_ListIteratorOfListOfShape aItE;
TopTools_IndexedDataMapOfShapeListOfShape aMVE;
BRep_Builder aBB;
//
aItM.Initialize(theME);
for (; aItM.More(); aItM.Next()) {
const TopoDS_Shape& aE=aItM.Key();
TopExp::MapShapesAndAncestors(aE, TopAbs_VERTEX, TopAbs_EDGE, aMVE);
}
//
aItM.Initialize(theME);
for (; aItM.More(); aItM.Next()) {
TopoDS_Shape aEE=aItM.Key();
if (!aAddedMap.Add(aEE)) {
continue;
}
//
// make a new shell
TopoDS_Wire aW;
aBB.MakeWire(aW);
aEE.Orientation(TopAbs_INTERNAL);
aBB.Add(aW, aEE);
//
TopoDS_Iterator aItAdded (aW);
for (; aItAdded.More(); aItAdded.Next()) {
const TopoDS_Shape& aE =aItAdded.Value();
//
TopExp_Explorer aExp(aE, TopAbs_VERTEX);
for (; aExp.More(); aExp.Next()) {
const TopoDS_Shape& aV =aExp.Current();
const TopTools_ListOfShape& aLE=aMVE.FindFromKey(aV);
aItE.Initialize(aLE);
for (; aItE.More(); aItE.Next()) {
TopoDS_Shape aEL=aItE.Value();
if (aAddedMap.Add(aEL)){
aEL.Orientation(TopAbs_INTERNAL);
aBB.Add(aW, aEL);
}
}
}
}
theWires.Append(aW);
}
}
示例7: MakeWire
void BRepOffsetAPI_MakeOffsetFix::MakeWire(TopoDS_Shape& wire)
{
// get the edges of the wire and check which of the stored edges
// serve as input of the wire
TopTools_MapOfShape aMap;
TopExp_Explorer xp(wire, TopAbs_EDGE);
while (xp.More()) {
aMap.Add(xp.Current());
xp.Next();
}
std::list<TopoDS_Edge> edgeList;
for (auto itLoc : myLocations) {
const TopTools_ListOfShape& newShapes = mkOffset.Generated(itLoc.first);
for (TopTools_ListIteratorOfListOfShape it(newShapes); it.More(); it.Next()) {
TopoDS_Shape newShape = it.Value();
if (aMap.Contains(newShape)) {
newShape.Move(itLoc.second);
edgeList.push_back(TopoDS::Edge(newShape));
}
}
}
if (!edgeList.empty()) {
BRepBuilderAPI_MakeWire mkWire;
mkWire.Add(edgeList.front());
edgeList.pop_front();
wire = mkWire.Wire();
bool found = false;
do {
found = false;
for (std::list<TopoDS_Edge>::iterator pE = edgeList.begin(); pE != edgeList.end(); ++pE) {
mkWire.Add(*pE);
if (mkWire.Error() != BRepBuilderAPI_DisconnectedWire) {
// edge added ==> remove it from list
found = true;
edgeList.erase(pE);
wire = mkWire.Wire();
break;
}
}
}
while (found);
}
}
示例8: Handle
Standard_Boolean ShHealOper_Sewing::getWires(const TopoDS_Shape& theSewShape) const
{
if(theSewShape.ShapeType() != TopAbs_COMPOUND)
return Standard_False;
Handle(TopTools_HSequenceOfShape) aSeqEdges = new TopTools_HSequenceOfShape;
TopExp_Explorer aexpEdges(theSewShape,TopAbs_EDGE,TopAbs_WIRE);
for ( ; aexpEdges.More(); aexpEdges.Next()) {
aSeqEdges->Append(aexpEdges.Current());
}
if(aSeqEdges->Length() <2)
return Standard_False;
//get manifold wires from sewed edges.
Standard_Real aTol = 0.;
Standard_Boolean aShared = Standard_True;
Handle(TopTools_HSequenceOfShape) aTmpWires = new TopTools_HSequenceOfShape;
ShapeAnalysis_FreeBounds::ConnectEdgesToWires(aSeqEdges, aTol, aShared, aTmpWires);
TopTools_MapOfShape aMapEdges;
Standard_Integer i =1;
for( ; i <= aSeqEdges->Length(); i++)
aMapEdges.Add(aSeqEdges->Value(i));
//remove free edges from result shape.
TopoDS_Compound aNewComp;
deleteFreeEdges(theSewShape,aMapEdges,aNewComp);
//add new wires in the result shape.
BRep_Builder aB;
for( i =1; i <= aTmpWires->Length(); i++) {
TopoDS_Iterator aite(aTmpWires->Value(i));
Standard_Integer nbe =0;
TopoDS_Shape aE;
for( ; aite.More() && nbe < 3; aite.Next(),nbe++)
aE = aite.Value();
if(!nbe)
continue;
else if(nbe ==1)
aB.Add(aNewComp,aE);
else
aB.Add(aNewComp,aTmpWires->Value(i));
}
myContext->Replace(theSewShape,aNewComp);
return Standard_True;
}
示例9: MapShapes
//=======================================================================
//function : MapShapes
//purpose :
//=======================================================================
void MapShapes(const TopoDS_Shape& theS,
TopTools_MapOfShape& theM)
{
theM.Add(theS);
TopoDS_Iterator anIt;
anIt.Initialize(theS);
for (; anIt.More(); anIt.Next()) {
const TopoDS_Shape& aSx=anIt.Value();
MapShapes(aSx, theM);
}
}
示例10: FillImagesCompound
//=======================================================================
//function : FillImagesCompound
//purpose :
//=======================================================================
void FillImagesCompound(const TopoDS_Shape& theS,
BRepAlgo_Image& theImages,
TopTools_MapOfShape& theMFP)
{
Standard_Boolean bInterferred;
TopAbs_ShapeEnum aTypeX;
TopAbs_Orientation aOrX;
TopoDS_Iterator aIt;
BRep_Builder aBB;
TopTools_ListIteratorOfListOfShape aItIm;
//
if (!theMFP.Add(theS)) {
return;
}
//
bInterferred=Standard_False;
aIt.Initialize(theS);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aSX=aIt.Value();
aTypeX=aSX.ShapeType();
if (aTypeX==TopAbs_COMPOUND) {
FillImagesCompound(aSX, theImages, theMFP);
}
if (theImages.HasImage(aSX)) {
bInterferred=Standard_True;
}
}
if (!bInterferred) {
return;
}
//
TopoDS_Shape aCIm;
GEOMAlgo_Tools3D::MakeContainer(TopAbs_COMPOUND, aCIm);
//
aIt.Initialize(theS);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aSX=aIt.Value();
aOrX=aSX.Orientation();
if (theImages.HasImage(aSX)) {
const TopTools_ListOfShape& aLFIm=theImages.Image(aSX);
aItIm.Initialize(aLFIm);
for (; aItIm.More(); aItIm.Next()) {
TopoDS_Shape aSXIm=aItIm.Value();
aSXIm.Orientation(aOrX);
aBB.Add(aCIm, aSXIm);
}
}
else {
aBB.Add(aCIm, aSX);
}
}
theImages.Bind(theS, aCIm);
}
示例11: CompsolidToCompound
//=======================================================================
//function : CompsolidToCompound
//purpose :
//=======================================================================
TopoDS_Shape GEOMUtils::CompsolidToCompound (const TopoDS_Shape& theCompsolid)
{
if (theCompsolid.ShapeType() != TopAbs_COMPSOLID) {
return theCompsolid;
}
TopoDS_Compound aCompound;
BRep_Builder B;
B.MakeCompound(aCompound);
TopTools_MapOfShape mapShape;
TopoDS_Iterator It (theCompsolid, Standard_True, Standard_True);
for (; It.More(); It.Next()) {
TopoDS_Shape aShape_i = It.Value();
if (mapShape.Add(aShape_i)) {
B.Add(aCompound, aShape_i);
}
}
return aCompound;
}
示例12: IsClosed
//modified by NIZNHY-PKV Thu Feb 16 12:25:16 2012f
//=======================================================================
//function : IsClosed
//purpose :
//=======================================================================
Standard_Boolean IsClosed(const TopoDS_Edge& aE,
const TopoDS_Face& aF)
{
Standard_Boolean bRet;
//
bRet=BRep_Tool::IsClosed(aE, aF);
if (bRet) {
TopTools_MapOfShape aM;
TopExp_Explorer aExp(aF, TopAbs_EDGE);
for (; aExp.More(); aExp.Next()) {
const TopoDS_Shape& aEx=aExp.Current();
//
if (aM.Add(aEx)) {
bRet=aEx.IsSame(aE);
if (bRet) {
break;
}
}
}
}
return bRet;
}
示例13: AddSimpleShapes
//=======================================================================
//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);
}
}
}
}
示例14: 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;
}
示例15: Handle
//=======================================================================
//function : Execute
//purpose :
//=======================================================================
Standard_Integer GEOMImpl_Fillet1dDriver::Execute(TFunction_Logbook& log) const
{
if (Label().IsNull()) return 0;
Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label());
GEOMImpl_IFillet1d aCI (aFunction);
Handle(GEOM_Function) aRefShape = aCI.GetShape();
TopoDS_Shape aShape = aRefShape->GetValue();
if (aShape.IsNull())
return 0;
if (aShape.ShapeType() != TopAbs_WIRE)
Standard_ConstructionError::Raise("Wrong arguments: polyline as wire must be given");
TopoDS_Wire aWire = TopoDS::Wire(aShape);
double rad = aCI.GetR();
if ( rad < Precision::Confusion())
return 0;
// collect vertices for make fillet
TopTools_ListOfShape aVertexList;
TopTools_MapOfShape mapShape;
int aLen = aCI.GetLength();
if ( aLen > 0 ) {
for (int ind = 1; ind <= aLen; ind++) {
TopoDS_Shape aShapeVertex;
if (GEOMImpl_ILocalOperations::GetSubShape
(aWire, aCI.GetVertex(ind), aShapeVertex))
if (mapShape.Add(aShapeVertex))
aVertexList.Append( aShapeVertex );
}
} else { // get all vertices from wire
TopExp_Explorer anExp( aWire, TopAbs_VERTEX );
for ( ; anExp.More(); anExp.Next() ) {
if (mapShape.Add(anExp.Current()))
aVertexList.Append( anExp.Current() );
}
}
if (aVertexList.IsEmpty())
Standard_ConstructionError::Raise("Invalid input no vertices to make fillet");
//INFO: this algorithm implemented in assumption that user can select both
// vertices of some edges to make fillet. In this case we should remember
// already modified initial edges to take care in next fillet step
TopTools_DataMapOfShapeShape anEdgeToEdgeMap;
//iterates on vertices, and make fillet on each couple of edges
//collect result fillet edges in list
TopTools_ListOfShape aListOfNewEdge;
// remember relation between initial and modified map
TopTools_IndexedDataMapOfShapeListOfShape aMapVToEdges;
TopExp::MapShapesAndAncestors( aWire, TopAbs_VERTEX, TopAbs_EDGE, aMapVToEdges );
TopTools_ListIteratorOfListOfShape anIt( aVertexList );
for ( ; anIt.More(); anIt.Next() ) {
TopoDS_Vertex aV = TopoDS::Vertex( anIt.Value() );
if ( aV.IsNull() || !aMapVToEdges.Contains( aV ) )
continue;
const TopTools_ListOfShape& aVertexEdges = aMapVToEdges.FindFromKey( aV );
if ( aVertexEdges.Extent() != 2 )
continue; // no input data to make fillet
TopoDS_Edge anEdge1 = TopoDS::Edge( aVertexEdges.First() );
TopoDS_Edge anEdge2 = TopoDS::Edge( aVertexEdges.Last() );
// check if initial edges already modified in previous fillet operation
if ( anEdgeToEdgeMap.IsBound( anEdge1 ) ) anEdge1 = TopoDS::Edge(anEdgeToEdgeMap.Find( anEdge1 ));
if ( anEdgeToEdgeMap.IsBound( anEdge2 ) ) anEdge2 = TopoDS::Edge(anEdgeToEdgeMap.Find( anEdge2 ));
if ( anEdge1.IsNull() || anEdge2.IsNull() || anEdge1.IsSame( anEdge2 ) )
continue; //no input data to make fillet
// create plane on 2 edges
gp_Pln aPlane;
if ( !takePlane(anEdge1, anEdge2, aV, aPlane) )
continue; // seems edges does not belong to same plane or parallel (fillet can not be build)
GEOMImpl_Fillet1d aFilletAlgo(anEdge1, anEdge2, aPlane);
if ( !aFilletAlgo.Perform(rad) )
continue; // can not create fillet with given radius
// take fillet result in given vertex
TopoDS_Edge aModifE1, aModifE2;
TopoDS_Edge aNewE = aFilletAlgo.Result(BRep_Tool::Pnt(aV), aModifE1, aModifE2);
if (aNewE.IsNull())
continue; // no result found
// add new created edges and take modified edges
aListOfNewEdge.Append( aNewE );
// check if face edges modified,
// if yes, than map to original edges (from vertex-edges list), because edges can be modified before
if (aModifE1.IsNull() || !anEdge1.IsSame( aModifE1 ))
addEdgeRelation( anEdgeToEdgeMap, TopoDS::Edge(aVertexEdges.First()), aModifE1 );
if (aModifE2.IsNull() || !anEdge2.IsSame( aModifE2 ))
addEdgeRelation( anEdgeToEdgeMap, TopoDS::Edge(aVertexEdges.Last()), aModifE2 );
}
//.........这里部分代码省略.........