本文整理汇总了C++中TopTools_IndexedDataMapOfShapeListOfShape::FindFromKey方法的典型用法代码示例。如果您正苦于以下问题:C++ TopTools_IndexedDataMapOfShapeListOfShape::FindFromKey方法的具体用法?C++ TopTools_IndexedDataMapOfShapeListOfShape::FindFromKey怎么用?C++ TopTools_IndexedDataMapOfShapeListOfShape::FindFromKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TopTools_IndexedDataMapOfShapeListOfShape
的用法示例。
在下文中一共展示了TopTools_IndexedDataMapOfShapeListOfShape::FindFromKey方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: get_parents_virt
void OCCSurface::get_parents_virt( DLIList<TopologyBridge*>& parents )
{
if(myShell) //shell or sheet body
{
parents.append(myShell);
return;
}
OCCQueryEngine* oqe = (OCCQueryEngine*) get_geometry_query_engine();
OCCBody * body = NULL;
DLIList <OCCBody* > *bodies = oqe->BodyList;
TopTools_IndexedDataMapOfShapeListOfShape M;
for(int i = 0; i < bodies->size(); i++)
{
body = bodies->get_and_step();
TopExp::MapShapesAndAncestors(*(body->get_TopoDS_Shape()),
TopAbs_FACE, TopAbs_SHELL, M);
if(!M.Contains(*(get_TopoDS_Face())))
continue;
const TopTools_ListOfShape& ListOfShapes =
M.FindFromKey(*(get_TopoDS_Face()));
if (!ListOfShapes.IsEmpty())
{
TopTools_ListIteratorOfListOfShape it(ListOfShapes) ;
for (;it.More(); it.Next())
{
TopoDS_Shell Shell = TopoDS::Shell(it.Value());
int k = oqe->OCCMap->Find(Shell);
parents.append((OCCShell*)(oqe->OccToCGM->find(k))->second);
}
}
}
}
示例2: DocumentObjectExecReturn
App::DocumentObjectExecReturn *Chamfer::execute(void)
{
App::DocumentObject* link = Base.getValue();
if (!link)
return new App::DocumentObjectExecReturn("No object linked");
if (!link->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId()))
return new App::DocumentObjectExecReturn("Linked object is not a Part object");
Part::Feature *base = static_cast<Part::Feature*>(Base.getValue());
const Part::TopoShape& TopShape = base->Shape.getShape();
if (TopShape._Shape.IsNull())
return new App::DocumentObjectExecReturn("Cannot chamfer invalid shape");
const std::vector<std::string>& SubVals = Base.getSubValuesStartsWith("Edge");
if (SubVals.size() == 0)
return new App::DocumentObjectExecReturn("No edges specified");
double size = Size.getValue();
this->positionByBase();
// create an untransformed copy of the base shape
Part::TopoShape baseShape(TopShape);
baseShape.setTransform(Base::Matrix4D());
try {
BRepFilletAPI_MakeChamfer mkChamfer(baseShape._Shape);
TopTools_IndexedMapOfShape mapOfEdges;
TopTools_IndexedDataMapOfShapeListOfShape mapEdgeFace;
TopExp::MapShapesAndAncestors(baseShape._Shape, TopAbs_EDGE, TopAbs_FACE, mapEdgeFace);
TopExp::MapShapes(baseShape._Shape, TopAbs_EDGE, mapOfEdges);
for (std::vector<std::string>::const_iterator it=SubVals.begin(); it != SubVals.end(); ++it) {
TopoDS_Edge edge = TopoDS::Edge(baseShape.getSubShape(it->c_str()));
const TopoDS_Face& face = TopoDS::Face(mapEdgeFace.FindFromKey(edge).First());
mkChamfer.Add(size, edge, face);
}
mkChamfer.Build();
if (!mkChamfer.IsDone())
return new App::DocumentObjectExecReturn("Failed to create chamfer");
TopoDS_Shape shape = mkChamfer.Shape();
if (shape.IsNull())
return new App::DocumentObjectExecReturn("Resulting shape is null");
TopTools_ListOfShape aLarg;
aLarg.Append(baseShape._Shape);
if (!BRepAlgo::IsValid(aLarg, shape, Standard_False, Standard_False)) {
return new App::DocumentObjectExecReturn("Resulting shape is invalid");
}
this->Shape.setValue(shape);
return App::DocumentObject::StdReturn;
}
catch (Standard_Failure) {
Handle_Standard_Failure e = Standard_Failure::Caught();
return new App::DocumentObjectExecReturn(e->GetMessageString());
}
}
示例3: ASSERT
TopoDS_Edge
StdMeshers_Hexa_3D::EdgeNotInFace(SMESH_Mesh & aMesh,
const TopoDS_Shape & aShape,
const TopoDS_Face & aFace,
const TopoDS_Vertex & aVertex,
const TopTools_IndexedDataMapOfShapeListOfShape & MS)
{
//MESSAGE("StdMeshers_Hexa_3D::EdgeNotInFace");
TopTools_IndexedDataMapOfShapeListOfShape MF;
TopExp::MapShapesAndAncestors(aFace, TopAbs_VERTEX, TopAbs_EDGE, MF);
const TopTools_ListOfShape & ancestorsInSolid = MS.FindFromKey(aVertex);
const TopTools_ListOfShape & ancestorsInFace = MF.FindFromKey(aVertex);
// SCRUTE(ancestorsInSolid.Extent());
// SCRUTE(ancestorsInFace.Extent());
ASSERT(ancestorsInSolid.Extent() == 6); // 6 (edges doublees)
ASSERT(ancestorsInFace.Extent() == 2);
TopoDS_Edge E;
E.Nullify();
TopTools_ListIteratorOfListOfShape its(ancestorsInSolid);
for (; its.More(); its.Next())
{
TopoDS_Shape ancestor = its.Value();
TopTools_ListIteratorOfListOfShape itf(ancestorsInFace);
bool isInFace = false;
for (; itf.More(); itf.Next())
{
TopoDS_Shape ancestorInFace = itf.Value();
if (ancestorInFace.IsSame(ancestor))
{
isInFace = true;
break;
}
}
if (!isInFace)
{
E = TopoDS::Edge(ancestor);
break;
}
}
return E;
}
示例4: 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);
}
}
示例5: FillInternalVertices
//=======================================================================
// function: FillInternalVertices
// purpose:
//=======================================================================
void GEOMAlgo_Builder::FillInternalVertices()
{
const NMTDS_ShapesDataStructure& aDS=*myPaveFiller->DS();
NMTTools_PaveFiller* pPF=myPaveFiller;
NMTDS_InterfPool* pIP=pPF->IP();
const Handle(IntTools_Context)& aCtx= pPF->Context();
//
BOPTools_CArray1OfVSInterference& aVFs=pIP->VSInterferences();
BOPTools_CArray1OfESInterference& aEFs=pIP->ESInterferences();
const NMTTools_IndexedDataMapOfIndexedMapOfInteger& aMAV=pPF->AloneVertices();
//
Standard_Boolean bHasImage;
Standard_Integer i, j, nF, aNbS, nV, nVSD, n1, n2, iFlag;
Standard_Integer aNbVFs, aNbAVF, aNbEFs, aNbVC, aNbE, aNbV;
Standard_Real aU1, aU2, aTol;
NMTTools_IndexedDataMapOfIndexedMapOfInteger aMFMV;
TopTools_MapOfShape aMFence;
TopTools_ListIteratorOfListOfShape aIt, aItV;
BRep_Builder aBB;
//
// 1. Collect face-vertex candidates [aMFMV]
//
// 1.1. VFs
aNbVFs=aVFs.Extent();
for (i=1; i<=aNbVFs; ++i) {
const BOPTools_VSInterference& aVS=aVFs(i);
aVS.Indices(n1, n2);
nF=n2;
nV=n1;
if (aDS.Shape(n1).ShapeType()==TopAbs_FACE) {
nF=n1;
nV=n2;
}
nVSD=pPF->FindSDVertex(nV);
if (nVSD) {
nV=nVSD;
}
//
UpdateCandidates(nF, nV, aMFMV);
}
//
// 1.2 EFs
aNbEFs=aEFs.Extent();
for (i=1; i<=aNbEFs; ++i) {
const BOPTools_ESInterference& aEF=aEFs(i);
aEF.Indices(n1, n2);
nV=aEF.NewShape();
if (!nV) {
continue;
}
const TopoDS_Shape& aSnew=aDS.Shape(nV);
if (aSnew.ShapeType()!=TopAbs_VERTEX) {
continue;
}
//
nF=(aDS.Shape(n1).ShapeType()==TopAbs_FACE) ? n1 : n2;
nVSD=pPF->FindSDVertex(nV);
if (nVSD) {
nV=nVSD;
}
UpdateCandidates(nF, nV, aMFMV);
}
//
aNbS=aDS.NumberOfShapesOfTheObject();
for (nF=1; nF<=aNbS; ++nF) {
const TopoDS_Shape& aF=aDS.Shape(nF);
//
if (aF.ShapeType()!=TopAbs_FACE) {
continue;
}
if (!aMFence.Add(aF)) {
continue;
}
//
const TopoDS_Face& aFF=TopoDS::Face(aF);
aTol=BRep_Tool::Tolerance(aFF);
//
// 1.3 FFs
if (aMAV.Contains(nF)) {
const TColStd_IndexedMapOfInteger& aMAVF=aMAV.FindFromKey(nF);
aNbAVF=aMAVF.Extent();
for (j=1; j<=aNbAVF; ++j) {
nV=aMAVF(j);
nVSD=pPF->FindSDVertex(nV);
if (nVSD) {
nV=nVSD;
}
//
UpdateCandidates(nF, nV, aMFMV);
}
}
//
// 1.4 Internal vertices of the face nF
BooleanOperations_OnceExplorer aExp(aDS);
aExp.Init(nF, TopAbs_VERTEX);
for (; aExp.More(); aExp.Next()) {
//.........这里部分代码省略.........
示例6: Execute
//.........这里部分代码省略.........
{
double aD = aCI.GetD();
double anAngle = aCI.GetAngle();
if ( (anAngle > 0) && (anAngle < (M_PI/2.)) )
fill.AddDA(aD, anAngle, E, F);
}
}
}
}
}
}
else if (aType == CHAMFER_SHAPE_FACES || aType == CHAMFER_SHAPE_FACES_AD) {
// chamfer on all edges of the selected faces, with D1 on the selected face
// (on first selected face, if the edge belongs to two selected faces)
int aLen = aCI.GetLength();
int ind = 1;
TopTools_MapOfShape aMap;
TopTools_IndexedDataMapOfShapeListOfShape M;
GEOMImpl_Block6Explorer::MapShapesAndAncestors(aShapeBase, TopAbs_EDGE, TopAbs_FACE, M);
for (; ind <= aLen; ind++)
{
TopoDS_Shape aShapeFace;
if (GEOMImpl_ILocalOperations::GetSubShape(aShapeBase, aCI.GetFace(ind), aShapeFace))
{
TopoDS_Face F = TopoDS::Face(aShapeFace);
TopExp_Explorer Exp (F, TopAbs_EDGE);
for (; Exp.More(); Exp.Next()) {
if (!aMap.Contains(Exp.Current()))
{
TopoDS_Edge E = TopoDS::Edge(Exp.Current());
if (!BRepTools::IsReallyClosed(E, F) &&
!BRep_Tool::Degenerated(E) &&
M.FindFromKey(E).Extent() == 2)
{
if (aType == CHAMFER_SHAPE_FACES)
{
double aD1 = aCI.GetD1();
double aD2 = aCI.GetD2();
fill.Add(aD1, aD2, E, F);
}
else
{
double aD = aCI.GetD();
double anAngle = aCI.GetAngle();
if ( (anAngle > 0) && (anAngle < (M_PI/2.)) )
fill.AddDA(aD, anAngle, E, F);
}
}
}
}
}
}
}
else if (aType == CHAMFER_SHAPE_EDGES || aType == CHAMFER_SHAPE_EDGES_AD)
{
// chamfer on selected edges with lenght param D1 & D2.
int aLen = aCI.GetLength();
int ind = 1;
TopTools_MapOfShape aMap;
TopTools_IndexedDataMapOfShapeListOfShape M;
GEOMImpl_Block6Explorer::MapShapesAndAncestors(aShapeBase, TopAbs_EDGE, TopAbs_FACE, M);
for (; ind <= aLen; ind++)
{
TopoDS_Shape aShapeEdge;
示例7: DocumentObjectExecReturn
App::DocumentObjectExecReturn *Chamfer::execute(void)
{
// NOTE: Normally the Base property and the BaseFeature property should point to the same object.
// The only difference is that the Base property also stores the edges that are to be chamfered
Part::TopoShape TopShape;
try {
TopShape = getBaseShape();
} catch (Base::Exception& e) {
return new App::DocumentObjectExecReturn(e.what());
}
std::vector<std::string> SubNames = std::vector<std::string>(Base.getSubValues());
getContiniusEdges(TopShape, SubNames);
if (SubNames.size() == 0)
return new App::DocumentObjectExecReturn("No edges specified");
double size = Size.getValue();
if (size <= 0)
return new App::DocumentObjectExecReturn("Size must be greater than zero");
this->positionByBaseFeature();
// create an untransformed copy of the basefeature shape
Part::TopoShape baseShape(TopShape);
baseShape.setTransform(Base::Matrix4D());
try {
BRepFilletAPI_MakeChamfer mkChamfer(baseShape.getShape());
TopTools_IndexedMapOfShape mapOfEdges;
TopTools_IndexedDataMapOfShapeListOfShape mapEdgeFace;
TopExp::MapShapesAndAncestors(baseShape.getShape(), TopAbs_EDGE, TopAbs_FACE, mapEdgeFace);
TopExp::MapShapes(baseShape.getShape(), TopAbs_EDGE, mapOfEdges);
for (std::vector<std::string>::const_iterator it=SubNames.begin(); it != SubNames.end(); ++it) {
TopoDS_Edge edge = TopoDS::Edge(baseShape.getSubShape(it->c_str()));
const TopoDS_Face& face = TopoDS::Face(mapEdgeFace.FindFromKey(edge).First());
mkChamfer.Add(size, edge, face);
}
mkChamfer.Build();
if (!mkChamfer.IsDone())
return new App::DocumentObjectExecReturn("Failed to create chamfer");
TopoDS_Shape shape = mkChamfer.Shape();
if (shape.IsNull())
return new App::DocumentObjectExecReturn("Resulting shape is null");
TopTools_ListOfShape aLarg;
aLarg.Append(baseShape.getShape());
if (!BRepAlgo::IsValid(aLarg, shape, Standard_False, Standard_False)) {
ShapeFix_ShapeTolerance aSFT;
aSFT.LimitTolerance(shape, Precision::Confusion(), Precision::Confusion(), TopAbs_SHAPE);
Handle(ShapeFix_Shape) aSfs = new ShapeFix_Shape(shape);
aSfs->Perform();
shape = aSfs->Shape();
if (!BRepAlgo::IsValid(aLarg, shape, Standard_False, Standard_False)) {
return new App::DocumentObjectExecReturn("Resulting shape is invalid");
}
}
this->Shape.setValue(getSolid(shape));
return App::DocumentObject::StdReturn;
}
catch (Standard_Failure& e) {
return new App::DocumentObjectExecReturn(e.GetMessageString());
}
}
示例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: FillInternalShapes
//.........这里部分代码省略.........
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);
}
}
//
// build aux map from splits of solids
if (myImages.HasImage(aS)) {
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);
}
}
}
else {
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);
}
}
}//if (aType==TopAbs_SOLID)
}
//
aNbSd=aLSd.Extent();
//
// 3. Some shapes of aMSI can be already tied with faces of
// split solids
aItM.Initialize(aMSI);
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) {
aMSI.Remove(aSI);
}
}
}
//
// 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());
//
aItM.Initialize(aMSI);
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) {
//
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);
} //if (aState==TopAbs_IN) {
}// for (; aItM.More(); aItM.Next()) {
}//for (; aIt1.More(); aIt1.Next()) {
}
示例10: PerformLoops
//.........这里部分代码省略.........
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());
//
TopoDS_Iterator aItE(aE);
for (; aItE.More()&&bFlag; aItE.Next()) {
const TopoDS_Vertex& aV = TopoDS::Vertex(aItE.Value());
const TopTools_ListOfShape& aLE=aVEMap.FindFromKey(aV);
aIt.Initialize(aLE);
for (; aIt.More()&&bFlag; aIt.Next()) {
const TopoDS_Shape& aEx=aIt.Value();
if (aMAdded.Add(aEx)) {
aBB.Add(aW, aEx);
if(aMAdded.Extent()==aNbEA) {
bFlag=!bFlag;
}
}
}//for (; aIt.More(); aIt.Next()) {
}//for (; aItE.More(); aItE.Next()) {
}//for (; aItW.More(); aItW.Next()) {
myLoopsInternal.Append(aW);
}//for (; aItM.More(); aItM.Next()) {
}
示例11: 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());
//.........这里部分代码省略.........
示例12: aCI
//=======================================================================
//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 );
}
//.........这里部分代码省略.........
示例13: 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);
}
}
示例14: if
//=======================================================================
//function : IsInternalFace
//purpose :
//=======================================================================
Standard_Boolean GEOMAlgo_Tools3D::IsInternalFace(const TopoDS_Face& theFace,
const TopoDS_Solid& theSolid,
const TopTools_IndexedDataMapOfShapeListOfShape& theMEF,
const Standard_Real theTol,
IntTools_Context& theContext)
{
Standard_Boolean bRet;
Standard_Integer aNbF;
TopoDS_Edge aEL;
TopExp_Explorer aExp;
TopTools_ListIteratorOfListOfShape aItF;
//
bRet=Standard_False;
//
// 1 Try to find an edge from theFace in theMEF
aExp.Init(theFace, TopAbs_EDGE);
for(; aExp.More(); aExp.Next()) {
const TopoDS_Edge& aE=TopoDS::Edge(aExp.Current());
if (!theMEF.Contains(aE)) {
continue;
}
//
const TopTools_ListOfShape& aLF=theMEF.FindFromKey(aE);
aNbF=aLF.Extent();
if (!aNbF) {
return bRet; // it can not be so
}
else if (aNbF==1) {
// aE is internal edge on aLF.First()
const TopoDS_Face& aF1=TopoDS::Face(aLF.First());
bRet=GEOMAlgo_Tools3D::IsInternalFace(theFace, aE, aF1, aF1, theContext);
return bRet;
}
else if (aNbF==2) {
const TopoDS_Face& aF1=TopoDS::Face(aLF.First());
const TopoDS_Face& aF2=TopoDS::Face(aLF.Last());
//
if (aF2.IsSame(aF1) && BRep_Tool::IsClosed(aE, aF1)) {
// treat as it was for 1 face
bRet=GEOMAlgo_Tools3D::IsInternalFace(theFace, aE, aF1, aF2, theContext);
return bRet;
}
}
if (aNbF%2) {
return bRet; // it can not be so
}
else { // aNbF=2,4,6,8,...
bRet=GEOMAlgo_Tools3D::IsInternalFace(theFace, aE, aLF, theContext);
return bRet;
}
}//for(; aExp.More(); aExp.Next()) {
//
//========================================
// 2. Classify face using classifier
//
TopAbs_State aState;
TopTools_IndexedMapOfShape aBounds;
//
aState=GEOMAlgo_Tools3D::ComputeState(theFace, theSolid, theTol, aBounds, theContext);
bRet=(aState==TopAbs_IN);
//
return bRet;
}
示例15: Execute
//.........这里部分代码省略.........
{
double aD = aCI.GetD();
double anAngle = aCI.GetAngle();
if ( (anAngle > 0) && (anAngle < (Standard_PI/2)) )
fill.AddDA(aD, anAngle, E, F);
}
}
}
}
}
}
else if (aType == CHAMFER_SHAPE_FACES || aType == CHAMFER_SHAPE_FACES_AD) {
// chamfer on all edges of the selected faces, with D1 on the selected face
// (on first selected face, if the edge belongs to two selected faces)
int aLen = aCI.GetLength();
int ind = 1;
TopTools_MapOfShape aMap;
TopTools_IndexedDataMapOfShapeListOfShape M;
GEOMImpl_Block6Explorer::MapShapesAndAncestors(aShapeBase, TopAbs_EDGE, TopAbs_FACE, M);
for (; ind <= aLen; ind++)
{
TopoDS_Shape aShapeFace;
if (GEOMImpl_ILocalOperations::GetSubShape(aShapeBase, aCI.GetFace(ind), aShapeFace))
{
TopoDS_Face F = TopoDS::Face(aShapeFace);
TopExp_Explorer Exp (F, TopAbs_EDGE);
for (; Exp.More(); Exp.Next()) {
if (!aMap.Contains(Exp.Current()))
{
TopoDS_Edge E = TopoDS::Edge(Exp.Current());
if (!BRepTools::IsReallyClosed(E, F) &&
!BRep_Tool::Degenerated(E) &&
M.FindFromKey(E).Extent() == 2)
if (aType == CHAMFER_SHAPE_FACES)
{
double aD1 = aCI.GetD1();
double aD2 = aCI.GetD2();
fill.Add(aD1, aD2, E, F);
}
else
{
double aD = aCI.GetD();
double anAngle = aCI.GetAngle();
if ( (anAngle > 0) && (anAngle < (Standard_PI/2)) )
fill.AddDA(aD, anAngle, E, F);
}
}
}
}
}
}
else if (aType == CHAMFER_SHAPE_EDGES || aType == CHAMFER_SHAPE_EDGES_AD)
{
// chamfer on selected edges with lenght param D1 & D2.
int aLen = aCI.GetLength();
int ind = 1;
TopTools_MapOfShape aMap;
TopTools_IndexedDataMapOfShapeListOfShape M;
GEOMImpl_Block6Explorer::MapShapesAndAncestors(aShapeBase, TopAbs_EDGE, TopAbs_FACE, M);
for (; ind <= aLen; ind++)
{
TopoDS_Shape aShapeEdge;
if (GEOMImpl_ILocalOperations::GetSubShape(aShapeBase, aCI.GetEdge(ind), aShapeEdge))
{