本文整理汇总了C++中TopTools_IndexedMapOfShape::Contains方法的典型用法代码示例。如果您正苦于以下问题:C++ TopTools_IndexedMapOfShape::Contains方法的具体用法?C++ TopTools_IndexedMapOfShape::Contains怎么用?C++ TopTools_IndexedMapOfShape::Contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TopTools_IndexedMapOfShape
的用法示例。
在下文中一共展示了TopTools_IndexedMapOfShape::Contains方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
int StdMeshers_Hexa_3D::GetFaceIndex(SMESH_Mesh & aMesh,
const TopoDS_Shape & aShape,
const vector < SMESH_subMesh * >&meshFaces,
const TopoDS_Vertex & V0,
const TopoDS_Vertex & V1,
const TopoDS_Vertex & V2, const TopoDS_Vertex & V3)
{
//MESSAGE("StdMeshers_Hexa_3D::GetFaceIndex");
int faceIndex = -1;
for (int i = 1; i < 6; i++)
{
const TopoDS_Shape & aFace = meshFaces[i]->GetSubShape();
//const TopoDS_Face& F = TopoDS::Face(aFace);
TopTools_IndexedMapOfShape M;
TopExp::MapShapes(aFace, TopAbs_VERTEX, M);
bool verticesInShape = false;
if (M.Contains(V0))
if (M.Contains(V1))
if (M.Contains(V2))
if (M.Contains(V3))
verticesInShape = true;
if (verticesInShape)
{
faceIndex = i;
break;
}
}
//IPAL21120 ASSERT(faceIndex > 0);
//SCRUTE(faceIndex);
return faceIndex;
}
示例2: TopoDS_Vertex
TopoDS_Vertex StdMeshers_Hexa_3D::OppositeVertex(const TopoDS_Vertex& aVertex,
const TopTools_IndexedMapOfShape& aQuads0Vertices,
FaceQuadStruct* aQuads[6])
{
int i, j;
for ( i = 1; i < 6; ++i )
{
TopoDS_Vertex VV[] = { aQuads[i]->side[0]->FirstVertex(),
aQuads[i]->side[0]->LastVertex() ,
aQuads[i]->side[2]->LastVertex() ,
aQuads[i]->side[2]->FirstVertex() };
for ( j = 0; j < 4; ++j )
if ( aVertex.IsSame( VV[ j ]))
break;
if ( j < 4 ) {
int jPrev = j ? j - 1 : 3;
int jNext = (j + 1) % 4;
if ( aQuads0Vertices.Contains( VV[ jPrev ] ))
return VV[ jNext ];
else
return VV[ jPrev ];
}
}
return TopoDS_Vertex();
}
示例3: validate
PyObject* TopoShapeFacePy::validate(PyObject *args)
{
if (!PyArg_ParseTuple(args, ""))
return 0;
try {
const TopoDS_Face& face = TopoDS::Face(getTopoShapePtr()->getShape());
BRepCheck_Analyzer aChecker(face);
if (!aChecker.IsValid()) {
TopoDS_Wire outerwire = ShapeAnalysis::OuterWire(face);
TopTools_IndexedMapOfShape myMap;
myMap.Add(outerwire);
TopExp_Explorer xp(face,TopAbs_WIRE);
ShapeFix_Wire fix;
fix.SetFace(face);
fix.Load(outerwire);
fix.Perform();
BRepBuilderAPI_MakeFace mkFace(fix.WireAPIMake());
while (xp.More()) {
if (!myMap.Contains(xp.Current())) {
fix.Load(TopoDS::Wire(xp.Current()));
fix.Perform();
mkFace.Add(fix.WireAPIMake());
}
xp.Next();
}
aChecker.Init(mkFace.Face());
if (!aChecker.IsValid()) {
ShapeFix_Shape fix(mkFace.Face());
fix.SetPrecision(Precision::Confusion());
fix.SetMaxTolerance(Precision::Confusion());
fix.SetMaxTolerance(Precision::Confusion());
fix.Perform();
fix.FixWireTool()->Perform();
fix.FixFaceTool()->Perform();
getTopoShapePtr()->setShape(fix.Shape());
}
else {
getTopoShapePtr()->setShape(mkFace.Face());
}
}
Py_Return;
}
catch (Standard_Failure) {
Handle_Standard_Failure e = Standard_Failure::Caught();
PyErr_SetString(PartExceptionOCCError, e->GetMessageString());
return 0;
}
}
示例4: IsGrowthWire
//=======================================================================
//function : IsGrowthWire
//purpose :
//=======================================================================
Standard_Boolean IsGrowthWire(const TopoDS_Shape& theWire,
const TopTools_IndexedMapOfShape& theMHE)
{
Standard_Boolean bRet;
TopoDS_Iterator aIt;
//
bRet=Standard_False;
if (theMHE.Extent()) {
aIt.Initialize(theWire);
for(; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aE=aIt.Value();
if (theMHE.Contains(aE)) {
return !bRet;
}
}
}
return bRet;
}
示例5: validateFace
TopoDS_Face FaceMakerCheese::validateFace(const TopoDS_Face& face)
{
BRepCheck_Analyzer aChecker(face);
if (!aChecker.IsValid()) {
TopoDS_Wire outerwire = ShapeAnalysis::OuterWire(face);
TopTools_IndexedMapOfShape myMap;
myMap.Add(outerwire);
TopExp_Explorer xp(face,TopAbs_WIRE);
ShapeFix_Wire fix;
fix.SetFace(face);
fix.Load(outerwire);
fix.Perform();
BRepBuilderAPI_MakeFace mkFace(fix.WireAPIMake());
while (xp.More()) {
if (!myMap.Contains(xp.Current())) {
fix.Load(TopoDS::Wire(xp.Current()));
fix.Perform();
mkFace.Add(fix.WireAPIMake());
}
xp.Next();
}
aChecker.Init(mkFace.Face());
if (!aChecker.IsValid()) {
ShapeFix_Shape fix(mkFace.Face());
fix.SetPrecision(Precision::Confusion());
fix.SetMaxTolerance(Precision::Confusion());
fix.SetMaxTolerance(Precision::Confusion());
fix.Perform();
fix.FixWireTool()->Perform();
fix.FixFaceTool()->Perform();
TopoDS_Face fixedFace = TopoDS::Face(fix.Shape());
aChecker.Init(fixedFace);
if (!aChecker.IsValid())
Standard_Failure::Raise("Failed to validate broken face");
return fixedFace;
}
return mkFace.Face();
}
return face;
}
示例6:
//=======================================================================
// function: ComputeState
// purpose:
//=======================================================================
TopAbs_State GEOMAlgo_Tools3D::ComputeState(const TopoDS_Face& theF,
const TopoDS_Solid& theRef,
const Standard_Real theTol,
const TopTools_IndexedMapOfShape& theBounds,
IntTools_Context& theCtx)
{
TopAbs_State aState;
TopExp_Explorer aExp;
TopoDS_Edge aE1;
gp_Pnt2d aP2D;
gp_Pnt aP3D;
//
aState=TopAbs_UNKNOWN;
//
aExp.Init(theF, TopAbs_EDGE);
for (; aExp.More(); aExp.Next()) {
const TopoDS_Edge& aSE=TopoDS::Edge(aExp.Current());
if (BRep_Tool::Degenerated(aSE)) {
continue;
}
//
if (!theBounds.Contains(aSE)) {
const TopoDS_Edge& aE=TopoDS::Edge(aSE);
aState= GEOMAlgo_Tools3D::ComputeState(aE, theRef, theTol, theCtx);
return aState;
}
if (aE1.IsNull()) {
aE1=TopoDS::Edge(aSE);
}
}
// !!<- process edges that are all on theRef
if (!aE1.IsNull()) {
BOPTools_Tools3D::PointNearEdge(aE1, theF, aP2D, aP3D);
aState=GEOMAlgo_Tools3D::ComputeState(aP3D, theRef, theTol, theCtx);
}
//
return aState;
}
示例7: SimpleBoxWithNaming
TopoShape SimpleBoxWithNaming(){
// We'll do this like freecad, first create TopoDS_Shape
const TopoDS_Shape& Box = BRepPrimAPI_MakeBox(10., 10., 10.);
// create Base Shape that gets passed to FilletFeature
TopoShape BaseShape(Box);
//std::clog << "Dumping deep TDF tree\n";
//std::clog << BaseShape.DeepDeepDumpTopoHistory();
// create blank TopoShape in FilletFeature and add Base Shape
TopoShape BoxShape;
BoxShape.addShape(Box);
// Finaly, 'Select' the edge
std::cout << "Trying to select the first time" << std::endl;
std::string selectionLabel = BoxShape.selectEdge(3);
//std::cout << "Trying to select a second time" << std::endl;
//std::string selectionLabel2 = BoxShape.selectEdge(3);
//std::clog << "Dumping tree" << std::endl;
//std::clog << BoxShape.DumpTopoHistory();
//std::clog << "|____________________|" << std::endl;
// And fillet the box
std::clog << "Running makeTopoShape" << std::endl;
BoxShape.makeTopoShapeFillet(2., 2., selectionLabel);
//std::clog << "-------------------------" << std::endl;
std::clog << "------------ REBUILDING ----------" << std::endl;
//std::clog << "-------------------------" << std::endl;
// make box taller
const TopoDS_Shape& Box2 = BRepPrimAPI_MakeBox(10., 20., 20.);
BoxShape.modifyShape("0:2", Box2);
std::clog << BoxShape.DumpTopoHistory();
// try re-building the box
TopoDS_Edge recoveredEdge = TopoDS::Edge(BoxShape.getSelectedEdge(selectionLabel));
//TopoDS_Shape recoveredBase = BoxShape.getSelectedBaseShape(selectionLabel);
//TopoDS_Shape recoveredBase = BoxShape.getNodeShape("0:4");
TopoDS_Shape recoveredBase = BoxShape.getTipShape();
//if (recoveredBase.IsNull()){
//std::cout << "BaseShape is NULL....\n";
//}
//else{
//std::cout << "BaseShape is not NULL!!!!\n";
//}
//if (recoveredEdge.IsNull()){
//std::cout << "recoveredEdge is Nul..." << std::endl;
//}
//else{
//std::cout << "recoveredEdge is NOT NULL!!!!" << std::endl;
//}
TopTools_IndexedMapOfShape edges;
TopExp::MapShapes(recoveredBase, TopAbs_EDGE, edges);
if (edges.Contains(recoveredEdge)){
std::cout << "Yes the Edge is in the box...\n";
}
else{
std::cout << "No, the Edge is not in the Box...\n";
}
//BoxShape.makeTopoShapeFillet(2., 2., selectionLabel);
return BoxShape;
}
示例8: chamfer
int OCCWire::chamfer(std::vector<OCCVertex *> vertices, std::vector<double> distances) {
int vertices_size = vertices.size();
int distances_size = distances.size();
BRepFilletAPI_MakeFillet2d MF;
try {
if (this->getShape().IsNull()) {
StdFail_NotDone::Raise("Shapes is Null");
}
MF.Init(BRepBuilderAPI_MakeFace(this->getWire()));
// creat map of vertices
TopTools_IndexedMapOfShape vertMap;
for (unsigned i=0; i<vertices.size(); i++)
vertMap.Add(vertices[i]->getShape());
bool first = true;
TopoDS_Edge firstEdge, nextEdge;
TopoDS_Vertex vertex;
BRepTools_WireExplorer Ex1;
for (Ex1.Init(this->getWire()); Ex1.More(); ) {
if(first == true) {
firstEdge = Ex1.Current();
first = false;
}
Ex1.Next();
//if the number of edges is odd don't proceed
if(Ex1.More() == Standard_False)
break;
nextEdge = Ex1.Current();
//get the common vertex of the two edges
if (!TopExp::CommonVertex(firstEdge, nextEdge, vertex)) {
// disconnected wire
first = true;
continue;
}
if (vertMap.Contains(vertex)) {
int i = vertMap.FindIndex(vertex) - 1;
if (distances_size == 1) {
// single distance
MF.AddChamfer(firstEdge, nextEdge, distances[0], distances[0]);
} else if (distances_size == vertices_size) {
// distance given for each vertex
MF.AddChamfer(firstEdge, nextEdge, distances[i], distances[i]);
} else {
StdFail_NotDone::Raise("distances argument has wrong size");
}
}
firstEdge = nextEdge;
}
// special case for closed wire
if (isClosed()) {
// find seam vertex
TopoDS_Vertex aV1;
TopExp::Vertices(this->getWire(), vertex, aV1);
// check if seam vertex has chamfer value
if (vertMap.Contains(vertex)) {
int i = vertMap.FindIndex(vertex) - 1;
// map vertices to edges to find edge pair
TopTools_IndexedDataMapOfShapeListOfShape mapVertexEdge;
TopExp::MapShapesAndAncestors(this->getWire(), TopAbs_VERTEX, TopAbs_EDGE, mapVertexEdge);
const TopTools_ListOfShape& edges = mapVertexEdge.FindFromKey(vertex);
firstEdge = TopoDS::Edge(edges.First());
nextEdge = TopoDS::Edge(edges.Last());
if (distances_size == 1) {
// single distance
MF.AddChamfer(firstEdge, nextEdge, distances[0], distances[0]);
} else if (distances_size == vertices_size) {
// distance given for each vertex
MF.AddChamfer(firstEdge, nextEdge, distances[i], distances[i]);
} else {
StdFail_NotDone::Raise("distances argument has wrong size");
}
}
}
if(MF.Status() != ChFi2d_IsDone)
StdFail_NotDone::Raise("chamfer operation failed");
TopTools_IndexedMapOfShape aMap;
TopExp::MapShapes(MF.Shape(), TopAbs_WIRE, aMap);
if(aMap.Extent() != 1)
StdFail_NotDone::Raise("chamfer result did not result in single wire");;
//add edges to the wire
//.........这里部分代码省略.........
示例9: Perform
TopoDS_Shape BlockFix_UnionEdges::Perform(const TopoDS_Shape& Shape,
const Standard_Real Tol)
{
myContext = new ShapeBuild_ReShape;
myTolerance = Tol;
TopoDS_Shape aResult = myContext->Apply(Shape);
// processing each solid
TopAbs_ShapeEnum aType = TopAbs_SOLID;
TopExp_Explorer exps (Shape, aType);
if (!exps.More()) {
aType = TopAbs_SHELL;
exps.Init(Shape, aType);
}
for (; exps.More(); exps.Next()) {
//TopoDS_Solid aSolid = TopoDS::Solid(exps.Current());
TopoDS_Shape aSolid = exps.Current();
TopTools_IndexedMapOfShape ChangedFaces;
// creating map of edge faces
TopTools_IndexedDataMapOfShapeListOfShape aMapEdgeFaces;
TopExp::MapShapesAndAncestors(aSolid, TopAbs_EDGE, TopAbs_FACE, aMapEdgeFaces);
Handle(ShapeBuild_ReShape) aContext = new ShapeBuild_ReShape;
TopoDS_Shape aRes = aSolid;
aRes = aContext->Apply(aSolid);
// processing each face
TopExp_Explorer exp;
for (exp.Init(aRes, TopAbs_FACE); exp.More(); exp.Next()) {
TopoDS_Face aFace =
TopoDS::Face(aContext->Apply(exp.Current().Oriented(TopAbs_FORWARD)));
TopTools_IndexedDataMapOfShapeListOfShape aMapFacesEdges;
for (TopExp_Explorer expe(aFace,TopAbs_EDGE); expe.More(); expe.Next()) {
TopoDS_Edge edge = TopoDS::Edge(expe.Current());
if (!aMapEdgeFaces.Contains(edge)) continue;
const TopTools_ListOfShape& aList = aMapEdgeFaces.FindFromKey(edge);
TopTools_ListIteratorOfListOfShape anIter(aList);
for ( ; anIter.More(); anIter.Next()) {
TopoDS_Face face = TopoDS::Face(anIter.Value());
TopoDS_Face face1 = TopoDS::Face(aContext->Apply(anIter.Value()));
if (face1.IsSame(aFace)) continue;
if (aMapFacesEdges.Contains(face)) {
aMapFacesEdges.ChangeFromKey(face).Append(edge);
}
else {
TopTools_ListOfShape ListEdges;
ListEdges.Append(edge);
aMapFacesEdges.Add(face,ListEdges);
}
}
}
for (Standard_Integer i=1; i<=aMapFacesEdges.Extent(); i++) {
const TopTools_ListOfShape& ListEdges = aMapFacesEdges.FindFromIndex(i);
TopTools_SequenceOfShape SeqEdges;
TopTools_ListIteratorOfListOfShape anIter(ListEdges);
for ( ; anIter.More(); anIter.Next()) {
SeqEdges.Append(anIter.Value());
}
if (SeqEdges.Length()==1) continue;
TopoDS_Edge E;
if ( MergeEdges(SeqEdges,aFace,Tol,E) ) {
// now we have only one edge - aChain.Value(1)
// we have to replace old ListEdges with this new edge
aContext->Replace(SeqEdges(1),E);
for (Standard_Integer j=2; j<=SeqEdges.Length(); j++) {
aContext->Remove(SeqEdges(j));
}
TopoDS_Face tmpF = TopoDS::Face(exp.Current());
if ( !ChangedFaces.Contains(tmpF) )
ChangedFaces.Add(tmpF);
tmpF = TopoDS::Face(aMapFacesEdges.FindKey(i));
if ( !ChangedFaces.Contains(tmpF) )
ChangedFaces.Add(tmpF);
}
}
} // end processing each face
// fix changed faces and replace them in the local context
for (Standard_Integer i=1; i<=ChangedFaces.Extent(); i++) {
TopoDS_Face aFace = TopoDS::Face(aContext->Apply(ChangedFaces.FindKey(i)));
Handle(ShapeFix_Face) sff = new ShapeFix_Face(aFace);
sff->SetContext(myContext);
sff->SetPrecision(myTolerance);
sff->SetMinTolerance(myTolerance);
sff->SetMaxTolerance(Max(1.,myTolerance*1000.));
sff->Perform();
aContext->Replace(aFace,sff->Face());
}
if (ChangedFaces.Extent() > 0) {
// fix changed shell and replace it in the local context
TopoDS_Shape aRes1 = aContext->Apply(aRes);
TopExp_Explorer expsh;
for (expsh.Init(aRes1, TopAbs_SHELL); expsh.More(); expsh.Next()) {
TopoDS_Shell aShell = TopoDS::Shell(expsh.Current());
//.........这里部分代码省略.........
示例10: PerformEF
//
//=======================================================================
// function: PerformEF
// purpose:
//=======================================================================
void NMTTools_PaveFiller::PerformEF()
{
Standard_Boolean bJustAdd;
Standard_Integer n1, n2, anIndexIn, nE, nF, aNbEFs, aBlockLength;
Standard_Integer aDiscretize;
Standard_Real aTolE, aTolF, aDeflection;
BooleanOperations_IndexedDataMapOfShapeInteger aMapVI;
BOPTools_IDMapOfPaveBlockIMapOfInteger aMapCB;
BOPTools_IMapOfPaveBlock aIMPBx;
//
myIsDone=Standard_False;
aDeflection=0.01;
aDiscretize=35;
//
BOPTools_CArray1OfESInterference& aEFs=myIP->ESInterferences();
//
myDSIt->Initialize(TopAbs_EDGE, TopAbs_FACE);
//
// BlockLength correction
aNbEFs=myDSIt->BlockLength();
aBlockLength=aEFs.BlockLength();
if (aNbEFs > aBlockLength) {
aEFs.SetBlockLength(aNbEFs);
}
//
for (; myDSIt->More(); myDSIt->Next()) {
myDSIt->Current(n1, n2, bJustAdd);
//
if(bJustAdd) {
continue;
}
//
anIndexIn = 0;
//
nE=n1;
nF=n2;
if (myDS->GetShapeType(n2)==TopAbs_EDGE) {
nE=n2;
nF=n1;
}
//
// all Common Blocks for face nF
NMTTools_ListOfCommonBlock aLCBF;
CommonBlocksFace(nF, aLCBF);
NMTTools_CommonBlockAPI aCBAPIF(aLCBF);
//
// Edge
const TopoDS_Edge aE=TopoDS::Edge(myDS->Shape(nE));
if (BRep_Tool::Degenerated(aE)){
continue;
}
//
// Face
const TopoDS_Face aF=TopoDS::Face(myDS->Shape(nF));
//
TopTools_IndexedMapOfShape aME;
TopExp::MapShapes(aF, TopAbs_EDGE, aME);
if (aME.Contains(aE)) {
continue;
}
//
aTolF=BRep_Tool::Tolerance(aF);
aTolE=BRep_Tool::Tolerance(aE);
const Bnd_Box& aBBF=myDS->GetBoundingBox(nF);
//
// Process each PaveBlock on edge nE
BOPTools_ListOfPaveBlock& aLPB=mySplitShapesPool(myDS->RefEdge(nE));
//
BOPTools_ListIteratorOfListOfPaveBlock anIt(aLPB);
for (; anIt.More(); anIt.Next()) {
BOPTools_PaveBlock& aPB=anIt.Value();
if (aCBAPIF.IsCommonBlock(aPB)) {
continue;
}
//
const IntTools_ShrunkRange& aShrunkRange=aPB.ShrunkRange();
const IntTools_Range& aSR =aShrunkRange.ShrunkRange();
const Bnd_Box& aBBE=aShrunkRange.BndBox();
//
if (aBBF.IsOut (aBBE)) {
continue;
}
//
// EF
IntTools_EdgeFace aEF;
aEF.SetEdge (aE);
aEF.SetFace (aF);
aEF.SetTolE (aTolE);
aEF.SetTolF (aTolF);
aEF.SetDiscretize (aDiscretize);
aEF.SetDeflection (aDeflection);
//
aEF.SetContext((IntTools_PContext)&myContext);
//
//.........这里部分代码省略.........
示例11: while
//=======================================================================
// function: MakeConnexityBlock.
// purpose:
//=======================================================================
void GEOMAlgo_Tools3D::MakeConnexityBlock (const TopTools_ListOfShape& theLFIn,
const TopTools_IndexedMapOfShape& theMEAvoid,
TopTools_ListOfShape& theLCB)
{
Standard_Integer aNbF, aNbAdd1;
TopExp_Explorer aExp;
TopTools_IndexedDataMapOfShapeListOfShape aMEF;
TopTools_MapIteratorOfMapOfShape aItM, aItM1;
TopTools_MapOfShape aMCB, aMAdd, aMAdd1;
TopTools_ListIteratorOfListOfShape aIt;
//
// 1. aMEF
aNbF=theLFIn.Extent();
aIt.Initialize(theLFIn);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aF=aIt.Value();
TopExp::MapShapesAndAncestors(aF, TopAbs_EDGE, TopAbs_FACE, aMEF);
}
//
// 2. aMCB
const TopoDS_Shape& aF1=theLFIn.First();
aMAdd.Add(aF1);
//
while(1) {
aMAdd1.Clear();
aItM.Initialize(aMAdd);
for (; aItM.More(); aItM.Next()) {
const TopoDS_Shape& aF=aItM.Key();
//
//aMAdd1.Clear();
aExp.Init(aF, TopAbs_EDGE);
for (; aExp.More(); aExp.Next()) {
const TopoDS_Shape& aE=aExp.Current();
if (theMEAvoid.Contains(aE)){
continue;
}
//
const TopTools_ListOfShape& aLF=aMEF.FindFromKey(aE);
aIt.Initialize(aLF);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aFx=aIt.Value();
if (aFx.IsSame(aF)) {
continue;
}
if (aMCB.Contains(aFx)) {
continue;
}
aMAdd1.Add(aFx);
}
}//for (; aExp.More(); aExp.Next()){
aMCB.Add(aF);
}// for (; aItM.More(); aItM.Next()) {
//
aNbAdd1=aMAdd1.Extent();
if (!aNbAdd1) {
break;
}
//
aMAdd.Clear();
aItM1.Initialize(aMAdd1);
for (; aItM1.More(); aItM1.Next()) {
const TopoDS_Shape& aFAdd=aItM1.Key();
aMAdd.Add(aFAdd);
}
//
}//while(1) {
//
aNbF=aMCB.Extent();
aItM.Initialize(aMCB);
for (; aItM.More(); aItM.Next()) {
const TopoDS_Shape& aF=aItM.Key();
theLCB.Append(aF);
}
}