当前位置: 首页>>代码示例>>C++>>正文


C++ TopTools_IndexedDataMapOfShapeListOfShape类代码示例

本文整理汇总了C++中TopTools_IndexedDataMapOfShapeListOfShape的典型用法代码示例。如果您正苦于以下问题:C++ TopTools_IndexedDataMapOfShapeListOfShape类的具体用法?C++ TopTools_IndexedDataMapOfShapeListOfShape怎么用?C++ TopTools_IndexedDataMapOfShapeListOfShape使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了TopTools_IndexedDataMapOfShapeListOfShape类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: get_geometry_query_engine

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);
         }
     }
  }
}
开发者ID:tenpercent,项目名称:cp-sandbox,代码行数:34,代码来源:OCCSurface.cpp

示例2: baseShape

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());
    }
}
开发者ID:Claude59,项目名称:FreeCAD,代码行数:58,代码来源:FeatureChamfer.cpp

示例3: 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);
  }
}
开发者ID:dbarbier,项目名称:pythonocc,代码行数:53,代码来源:GEOMAlgo_BuilderFace.cpp

示例4: 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;
}
开发者ID:Daedalus12,项目名称:FreeCAD_sf_master,代码行数:42,代码来源:StdMeshers_Hexa_3D.cpp

示例5: get_bodies

CubitStatus OCCSurface::get_bodies(DLIList<OCCBody*>& bodies)
{
   TopoDS_Face* topo_face = this->get_TopoDS_Face();
   OCCQueryEngine* oqe = OCCQueryEngine::instance();
   DLIList <OCCBody* > *all_bodies = oqe->BodyList;
   TopTools_IndexedDataMapOfShapeListOfShape M;
   OCCBody * body = NULL;
   for(int j = 0; j <  all_bodies->size(); j++)
   {
     body = all_bodies->get_and_step();
     TopExp_Explorer Ex;
     TopoDS_Face the_face;
     TopoDS_Shape ashape = *(body->get_TopoDS_Shape());
     M.Clear();
     TopExp::MapShapesAndAncestors(ashape, TopAbs_FACE, TopAbs_COMPSOLID, M);
     if(!M.Contains(*topo_face))
       continue;
     bodies.append_unique(body);
  }
  return CUBIT_SUCCESS;
}
开发者ID:tenpercent,项目名称:cp-sandbox,代码行数:21,代码来源:OCCSurface.cpp

示例6: BRepPrimAPI_MakeBox

void occQt::makeChamfer()
{
    gp_Ax2 anAxis;
    anAxis.SetLocation(gp_Pnt(8.0, 50.0, 0.0));

    TopoDS_Shape aTopoBox = BRepPrimAPI_MakeBox(anAxis, 3.0, 4.0, 5.0);
    BRepFilletAPI_MakeChamfer MC(aTopoBox);
    TopTools_IndexedDataMapOfShapeListOfShape aEdgeFaceMap;

    TopExp::MapShapesAndAncestors(aTopoBox, TopAbs_EDGE, TopAbs_FACE, aEdgeFaceMap);

    for (Standard_Integer i = 1; i <= aEdgeFaceMap.Extent(); ++i)
    {
        TopoDS_Edge anEdge = TopoDS::Edge(aEdgeFaceMap.FindKey(i));
        TopoDS_Face aFace = TopoDS::Face(aEdgeFaceMap.FindFromIndex(i).First());

        MC.Add(0.6, 0.6, anEdge, aFace);
    }

    Handle_AIS_Shape anAisShape = new AIS_Shape(MC.Shape());
    anAisShape->SetColor(Quantity_NOC_TOMATO);

    mContext->Display(anAisShape);
}
开发者ID:ruisebastiao,项目名称:occQt,代码行数:24,代码来源:occQt.cpp

示例7: Handle

//=======================================================================
//function : Execute
//purpose  :
//=======================================================================
Standard_Integer GEOMImpl_ChamferDriver::Execute(TFunction_Logbook& log) const
{
  if (Label().IsNull()) return 0;
  Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label());

  GEOMImpl_IChamfer aCI (aFunction);
  Standard_Integer aType = aFunction->GetType();

  TopoDS_Shape aShape;

  Handle(GEOM_Function) aRefShape = aCI.GetShape();
  TopoDS_Shape aShapeBase = aRefShape->GetValue();

  // Check the shape type. It have to be shell
  // or solid, or compsolid, or compound of these shapes.
  if (!isGoodForChamfer(aShapeBase)) {
    StdFail_NotDone::Raise
      ("Wrong shape. Must be shell or solid, or compsolid or compound of these shapes");
  }

  BRepFilletAPI_MakeChamfer fill (aShapeBase);

  if (aType == CHAMFER_SHAPE_ALL) {
    // symmetric chamfer on all edges
    double aD = aCI.GetD();
    TopTools_IndexedDataMapOfShapeListOfShape M;
    GEOMImpl_Block6Explorer::MapShapesAndAncestors(aShapeBase, TopAbs_EDGE, TopAbs_FACE, M);
    for (int i = 1; i <= M.Extent(); i++) {
      TopoDS_Edge E = TopoDS::Edge(M.FindKey(i));
      TopoDS_Face F = TopoDS::Face(M.FindFromIndex(i).First());
      if (!BRepTools::IsReallyClosed(E, F) &&
          !BRep_Tool::Degenerated(E) &&
          M.FindFromIndex(i).Extent() == 2)
        fill.Add(aD, E, F);
    }
  }
  else if (aType == CHAMFER_SHAPE_EDGE || aType == CHAMFER_SHAPE_EDGE_AD) {
    // chamfer on edges, common to two faces, with D1 on the first face

    TopoDS_Shape aFace1, aFace2;
    if (GEOMImpl_ILocalOperations::GetSubShape(aShapeBase, aCI.GetFace1(), aFace1) &&
        GEOMImpl_ILocalOperations::GetSubShape(aShapeBase, aCI.GetFace2(), aFace2))
    {
      TopoDS_Face F = TopoDS::Face(aFace1);

      // fill map of edges of the second face
      TopTools_MapOfShape aMap;
      TopExp_Explorer Exp2 (aFace2, TopAbs_EDGE);
      for (; Exp2.More(); Exp2.Next()) {
        aMap.Add(Exp2.Current());
      }

      // find edges of the first face, common with the second face
      TopExp_Explorer Exp (aFace1, 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))
          {
            if ( aType == CHAMFER_SHAPE_EDGE )
            {
              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_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()))
          {
//.........这里部分代码省略.........
开发者ID:triggerfish1,项目名称:pythonocc,代码行数:101,代码来源:GEOMImpl_ChamferDriver.cpp

示例8: 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++;
    }
//.........这里部分代码省略.........
开发者ID:dbarbier,项目名称:pythonocc,代码行数:101,代码来源:GEOMImpl_PrismDriver.cpp

示例9: PerformLoops

//=======================================================================
//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());
//.........这里部分代码省略.........
开发者ID:dbarbier,项目名称:pythonocc,代码行数:101,代码来源:GEOMAlgo_BuilderFace.cpp

示例10: getBaseShape

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());
    }
}
开发者ID:AjinkyaDahale,项目名称:FreeCAD,代码行数:67,代码来源:FeatureChamfer.cpp

示例11: if

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
//.........这里部分代码省略.........
开发者ID:Felipeasg,项目名称:occmodel,代码行数:101,代码来源:OCCWire.cpp

示例12: 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()) {
}
开发者ID:dbarbier,项目名称:pythonocc,代码行数:76,代码来源:GEOMAlgo_BuilderFace.cpp

示例13: Handle

//=======================================================================
//function : FillIn3DParts
//purpose  :
//=======================================================================
  void GEOMAlgo_Builder::FillIn3DParts()
{
  myErrorStatus=0;
  //
  const NMTDS_ShapesDataStructure& aDS=*myPaveFiller->DS();
  NMTTools_PaveFiller* pPF=myPaveFiller;
  const Handle(IntTools_Context)& aCtx= pPF->Context();
  //
  Standard_Boolean bIsIN, bHasImage;
  Standard_Integer aNbS, aNbSolids, i, j, aNbFaces, aNbFP, aNbFPx, aNbFIN, aNbLIF;
  TopAbs_ShapeEnum aType;
  TopAbs_State aState;
  TopTools_IndexedMapOfShape aMSolids, aMS, aMFaces, aMFIN;
  TopTools_MapOfShape aMFDone;
  TopTools_IndexedDataMapOfShapeListOfShape aMEF;
  TopTools_ListIteratorOfListOfShape aItS;
  TopoDS_Iterator aIt, aItF;
  BRep_Builder aBB;
  TopoDS_Solid aSolidSp;
  TopoDS_Face aFP;
  //
  myDraftSolids.Clear();
  //
  aNbS=aDS.NumberOfShapesOfTheObject();
  for (i=1; i<=aNbS; ++i) {
    const TopoDS_Shape& aS=aDS.Shape(i);
    //
    aType=aS.ShapeType();
    if (aType==TopAbs_SOLID) {
      // all solids from DS
      aMSolids.Add(aS);
    }
    else if (aType==TopAbs_FACE) {
      // all faces (originals from DS or theirs images)
      if (myImages.HasImage(aS)) {
        const TopTools_ListOfShape& aLS=myImages.Image(aS);
        aItS.Initialize(aLS);
        for (; aItS.More(); aItS.Next()) {
          const TopoDS_Shape& aFx=aItS.Value();
          //
          if (mySameDomainShapes.Contains(aFx)) {
            const TopoDS_Shape& aFSDx=mySameDomainShapes.FindFromKey(aFx);
            aMFaces.Add(aFSDx);
          }
          else {
            aMFaces.Add(aFx);
          }
        }
      }
      else {
        if (mySameDomainShapes.Contains(aS)) {
          const TopoDS_Shape& aFSDx=mySameDomainShapes.FindFromKey(aS);
          aMFaces.Add(aFSDx);
        }
        else {
          aMFaces.Add(aS);
        }
      }
    }
  }
  //
  aNbFaces=aMFaces.Extent();
  aNbSolids=aMSolids.Extent();
  //
  for (i=1; i<=aNbSolids; ++i) {
    const TopoDS_Solid& aSolid=TopoDS::Solid(aMSolids(i));
    aMFDone.Clear();
    aMFIN.Clear();
    aMEF.Clear();
    //
    aBB.MakeSolid(aSolidSp);
    //
    TopTools_ListOfShape aLIF;
    //
    BuildDraftSolid(aSolid, aSolidSp, aLIF);
    aNbLIF=aLIF.Extent();
    //
    // 1 all faces/edges from aSolid [ aMS ]
    bHasImage=Standard_False;
    aMS.Clear();
    aIt.Initialize(aSolid);
    for (; aIt.More(); aIt.Next()) {
      const TopoDS_Shape& aShell=aIt.Value();
      //
      if (myImages.HasImage(aShell)) {
        bHasImage=Standard_True;
        //
        const TopTools_ListOfShape& aLS=myImages.Image(aShell);
        aItS.Initialize(aLS);
        for (; aItS.More(); aItS.Next()) {
          const TopoDS_Shape& aSx=aItS.Value();
          aMS.Add(aSx);
          TopExp::MapShapes(aSx, TopAbs_FACE, aMS);
          TopExp::MapShapes(aSx, TopAbs_EDGE, aMS);
          TopExp::MapShapesAndAncestors(aSx, TopAbs_EDGE, TopAbs_FACE, aMEF);
        }
//.........这里部分代码省略.........
开发者ID:triggerfish1,项目名称:pythonocc,代码行数:101,代码来源:GEOMAlgo_Builder_3.cpp

示例14: DetectSolids

//=======================================================================
//function : DetectSolids
//purpose  :
//=======================================================================
  void GEOMAlgo_GlueAnalyser::DetectSolids()
{
  myErrorStatus=0;
  //
  Standard_Integer i, aNbF, aNbS, aNbC, aNbX;
  TopoDS_Compound aCmp;
  BRep_Builder aBB;
  TopTools_IndexedDataMapOfShapeListOfShape aMFS;
  TopTools_IndexedMapOfShape aMx, aMS;
  TopTools_DataMapIteratorOfDataMapOfShapeListOfShape aItIm;
  GEOMAlgo_CoupleOfShapes aCS;
  //
  GEOMAlgo_IndexedDataMapOfPassKeyShapeListOfShape aMPKLS;
  GEOMAlgo_PassKeyShape aPKSx;
  //
  aBB.MakeCompound(aCmp);
  //
  TopExp::MapShapesAndAncestors(myShape, TopAbs_FACE, TopAbs_SOLID, aMFS);
  //
  aItIm.Initialize(myImages);
  for (; aItIm.More(); aItIm.Next()) {
    const TopoDS_Shape& aIm=aItIm.Key();
    if (aIm.ShapeType()!=TopAbs_FACE) {
      continue;
    }
    //
    const TopTools_ListOfShape& aLF=aItIm.Value();
    aNbF=aLF.Extent();
    if (aNbF!=2) {
      continue;
    }
    //
    TopoDS_Shape aSx[2], aFx[2];
    //
    aFx[0]=aLF.First();
    aFx[1]=aLF.Last();
    for (i=0; i<2; ++i) {
      if (!aMFS.Contains(aFx[i])) {
        continue;// it must not be so
      }
      //
      const TopTools_ListOfShape& aLS=aMFS.FindFromKey(aFx[i]);
      aNbS=aLS.Extent();
      if (aNbS!=1) {
        continue;
      }
      aSx[i]=aLS.First();
    }
    //
    if (aSx[0].IsNull() || aSx[1].IsNull()) {
      continue;
    }
    //
    //aPKSx.Clear();//qft
    //qf
    //aPKSx.SetIds(aSx[0], aSx[1]);
    aPKSx.SetShapes(aSx[0], aSx[1]);
    //qt
    //
    if (!aMPKLS.Contains(aPKSx)) {
      TopTools_ListOfShape aLSx;
      //
      aLSx.Append(aSx[0]);
      aLSx.Append(aSx[1]);
      //
      aMPKLS.Add(aPKSx, aLSx);
    }
  }
  //
  mySolidsToGlue.Clear();
  mySolidsAlone.Clear();

  //
  aNbC=aMPKLS.Extent();
  if (!aNbC) {
    return;
  }
  //
  for (i=1; i<=aNbC; ++i) {
    const TopTools_ListOfShape& aLSx=aMPKLS(i);
    const TopoDS_Shape& aSx1=aLSx.First();
    const TopoDS_Shape& aSx2=aLSx.Last();
    aCS.SetShape1(aSx1);
    aCS.SetShape2(aSx2);
    mySolidsToGlue.Append(aCS);
    //
    if (!aMx.Contains(aSx1)) {
      aBB.Add(aCmp, aSx1);
      aMx.Add(aSx1);
    }
    if (!aMx.Contains(aSx2)) {
      aBB.Add(aCmp, aSx2);
      aMx.Add(aSx2);
    }
  }
  myResult=aCmp;
//.........这里部分代码省略.........
开发者ID:triggerfish1,项目名称:pythonocc,代码行数:101,代码来源:GEOMAlgo_GlueAnalyser.cpp

示例15: PerformShapesToAvoid

//=======================================================================
//function :PerformShapesToAvoid
//purpose  : 
//=======================================================================
  void GEOMAlgo_BuilderFace::PerformShapesToAvoid()
{
  Standard_Boolean bFound;
  Standard_Integer i, iCnt, aNbV, aNbE;
  TopTools_IndexedDataMapOfShapeListOfShape aMVE;
  TopTools_ListIteratorOfListOfShape aIt;
  //
  myShapesToAvoid.Clear();
  //
  iCnt=0;
  while (1) {
    ++iCnt;
    bFound=Standard_False;
    //
    // 1. MEF
    aMVE.Clear();
    aIt.Initialize (myShapes);
    for (; aIt.More(); aIt.Next()) {
      const TopoDS_Shape& aE=aIt.Value();
      if (!myShapesToAvoid.Contains(aE)) {
	TopExp::MapShapesAndAncestors(aE, TopAbs_VERTEX, TopAbs_EDGE, aMVE);
      }
//       else {
//         int a=0;
//       }
    }
    aNbV=aMVE.Extent();
    //
    // 2. myEdgesToAvoid
    for (i=1; i<=aNbV; ++i) {
      const TopoDS_Vertex& aV=TopoDS::Vertex(aMVE.FindKey(i));
      //
      TopTools_ListOfShape& aLE=aMVE.ChangeFromKey(aV);
      aNbE=aLE.Extent();
      if (!aNbE) {
	continue;
      }
      //
      const TopoDS_Edge& aE1=TopoDS::Edge(aLE.First());
      if (aNbE==1) {
	if (BRep_Tool::Degenerated(aE1)) {
	  continue;
	}
	if (aV.Orientation()==TopAbs_INTERNAL) {
	  continue;
	}
	bFound=Standard_True;
	myShapesToAvoid.Add(aE1);
      }
      else if (aNbE==2) {
	const TopoDS_Edge& aE2=TopoDS::Edge(aLE.Last());
	if (aE2.IsSame(aE1)) {
	  TopoDS_Vertex aV1x, aV2x;
	  //
	  TopExp::Vertices(aE1, aV1x, aV2x);
	  if (aV1x.IsSame(aV2x)) {
	    continue;
	  }
	  bFound=Standard_True;
	  myShapesToAvoid.Add(aE1);
	  myShapesToAvoid.Add(aE2);
	}
      }
    }// for (i=1; i<=aNbE; ++i) {
    //
    if (!bFound) {
      break;
    }
    //
  }//while (1) 
  //printf(" EdgesToAvoid=%d, iCnt=%d\n", EdgesToAvoid.Extent(), iCnt);
}  
开发者ID:dbarbier,项目名称:pythonocc,代码行数:76,代码来源:GEOMAlgo_BuilderFace.cpp


注:本文中的TopTools_IndexedDataMapOfShapeListOfShape类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。