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


C++ BRep_Builder::MakeSolid方法代码示例

本文整理汇总了C++中BRep_Builder::MakeSolid方法的典型用法代码示例。如果您正苦于以下问题:C++ BRep_Builder::MakeSolid方法的具体用法?C++ BRep_Builder::MakeSolid怎么用?C++ BRep_Builder::MakeSolid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BRep_Builder的用法示例。


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

示例1: replaceFacesInternal

void OCCRegion::replaceFacesInternal(std::list<GFace*> &new_faces)
{
  // we simply replace old faces by new faces in the structure
  TopExp_Explorer aExpS, aExpF;
  BRep_Builder aBB;
  TopoDS_Compound aCmp;
  aBB.MakeCompound(aCmp);
  TopoDS_Solid _s_replacement;
  aBB.MakeSolid(_s_replacement);
  _s_replacement.Orientation(s.Orientation());
  aExpS.Init(s, TopAbs_SHELL);
  for (; aExpS.More(); aExpS.Next()) {
    const TopoDS_Shell& _shell=TopoDS::Shell(aExpS.Current());
    TopoDS_Shell _shell_replacement;
    aBB.MakeShell(_shell_replacement);
    _shell_replacement.Orientation(_shell.Orientation());
    aExpF.Init(_shell, TopAbs_FACE);
    for (; aExpF.More(); aExpF.Next()) {
      const TopoDS_Face& _face=TopoDS::Face(aExpF.Current());
      TopoDS_Face _face_replacement;

      std::list<GFace*>::iterator it  = l_faces.begin();
      std::list<GFace*>::iterator it2 = new_faces.begin();

      for ( ; it != l_faces.end() ; ++it,++it2){
	OCCFace *occF = dynamic_cast<OCCFace*>(*it);
	if (occF){
	  TopoDS_Face oldf = occF->getTopoDS_Face();
	  if (oldf.IsSame(_face)){
	    _face_replacement = *((TopoDS_Face*)(*it2)->getNativePtr());
	  }
	  else {
	    oldf = occF->getTopoDS_FaceOld();
	    if (oldf.IsSame(_face)){
	      _face_replacement = *((TopoDS_Face*)(*it2)->getNativePtr());
	    }
	  }
	}
      }
      if (_face_replacement.IsNull()){
	Msg::Error("cannot find an face for gluing a region");
      }

      if (_face_replacement.IsSame(_face)) {
	aBB.Add(_shell_replacement, _face);
      }
      else {
	if(FaceHaveDifferentOrientations(_face, _face_replacement))
          _face_replacement.Reverse();
	aBB.Add(_shell_replacement, _face_replacement);
      }
    }
    aBB.Add(_s_replacement, _shell_replacement);
  }
  s = _s_replacement;
  setup();
}
开发者ID:iyer-arvind,项目名称:gmsh,代码行数:57,代码来源:OCCRegion.cpp

示例2: removeFaces

Standard_Boolean ShHealOper_RemoveFace::removeFaces(const TopoDS_Solid& theShape,
                                                    TopoDS_Shape& theNewShape)
{
  Standard_Boolean isDone = Standard_False;
  TopoDS_Solid aSol;
  BRep_Builder aB;
  aB.MakeSolid(aSol);
  TopoDS_Compound aComp;
  aB.MakeCompound(aComp);
  Standard_Boolean isAddSol = Standard_False, isAddComp = Standard_False;

  //firslty faces will be deleted from each shell.
  TopoDS_Iterator aItSol(theShape,Standard_False);
  for( ; aItSol.More(); aItSol.Next()) {
    TopoDS_Shape aSh = aItSol.Value();
    TopoDS_Shape aNewShape;
    if(removeFaces(aSh,aNewShape)) 
      isDone = Standard_True;
    
    if(aNewShape.IsNull())
      continue;
    else if(aNewShape.ShapeType() == TopAbs_SHELL ) {
      aB.Add(aSol,aNewShape);
      isAddSol = Standard_True;
    }
    else {
      aB.Add(aComp,aNewShape);
      isAddComp = Standard_True;
    }
    
  }
  if(isDone) {
    //for getting correct solids class ShapeFix_Solid will be used.
    if(isAddSol) {
      Handle(ShapeFix_Solid) aSfSol = new ShapeFix_Solid(aSol);
      aSfSol->FixShellMode()= Standard_False;
      aSfSol->Perform();
      TopoDS_Shape aresSol = aSfSol->Shape();
      if(!isAddComp) 
        theNewShape = aresSol;
      else 
        aB.Add(aComp,aresSol);
    }
    else if(isAddComp)
        theNewShape = aComp;
    else
      theNewShape.Nullify();
  }
  else
    theNewShape = theShape; 
  return isDone;
}
开发者ID:triggerfish1,项目名称:pythonocc,代码行数:52,代码来源:ShHealOper_RemoveFace.cpp

示例3: switch

//=======================================================================
// function: MakeContainer
// purpose: 
//=======================================================================
  void GEOMAlgo_Tools3D::MakeContainer(const TopAbs_ShapeEnum theType,
                                      TopoDS_Shape& theC)
{
  BRep_Builder aBB;
  //
  switch(theType) {
    case TopAbs_COMPOUND:{
      TopoDS_Compound aC;
      aBB.MakeCompound(aC);
      theC=aC;
    }
      break;
      //
    case TopAbs_COMPSOLID:{
      TopoDS_CompSolid aCS;
      aBB.MakeCompSolid(aCS);
      theC=aCS;
    }
      break;
      //
    case TopAbs_SOLID:{
      TopoDS_Solid aSolid;
      aBB.MakeSolid(aSolid);
      theC=aSolid;
    }  
      break;
      //
      //
    case TopAbs_SHELL:{
      TopoDS_Shell aShell;
      aBB.MakeShell(aShell);
      theC=aShell;
    }  
      break;
      //
    case TopAbs_WIRE: {
      TopoDS_Wire aWire;
      aBB.MakeWire(aWire);
      theC=aWire;
    }
      break;
      //
    default:
      break;
  }
}
开发者ID:dbarbier,项目名称:pythonocc,代码行数:50,代码来源:GEOMAlgo_Tools3D.cpp

示例4: if

////////////////////////////////////////////////////////////////////////////////
// Construct TopoDS from BRL-CAD data
////////////////////////////////////////////////////////////////////////////////
BRLTopo::BRLTopo(struct rt_arb_internal *arb)
{
    TopoDS_Vertex v[8];
    for(int i=0;i<8;i++)
        v[i]=BRepBuilderAPI_MakeVertex(
            gp_Pnt(
                scale*arb->pt[i][0],
                scale*arb->pt[i][1],
                scale*arb->pt[i][2]
            )
        );

    int arbn;
    if(!BRepTools::Compare(v[6],v[7]))
        arbn=8;
    else if(!BRepTools::Compare(v[4],v[5]))
        arbn=7;
    else if(!BRepTools::Compare(v[5],v[6]))
        arbn=6;
    else if(!BRepTools::Compare(v[0],v[3]))
        arbn=5;
    else
        arbn=4;

    switch(arbn) {
    case 8: {
        TopoDS_Edge e[12];
        for(int i=0;i<4;i++) { 
            e[i]=BRepBuilderAPI_MakeEdge(v[i],v[(i+1)%4]);
            e[i+4]=BRepBuilderAPI_MakeEdge(v[i+4],v[(i+1)%4+4]);
            e[i+8]=BRepBuilderAPI_MakeEdge(v[i],v[(i+4)%8]);
        }

        TopoDS_Wire w[6];
        w[0]=BRepBuilderAPI_MakeWire(e[0],e[1],e[2],e[3]);
        w[1]=BRepBuilderAPI_MakeWire(e[4],e[5],e[6],e[7]);
        w[2]=BRepBuilderAPI_MakeWire(e[0],e[9],e[4],e[8]);
        w[3]=BRepBuilderAPI_MakeWire(e[1],e[10],e[5],e[9]);
        w[4]=BRepBuilderAPI_MakeWire(e[2],e[11],e[6],e[10]);
        w[5]=BRepBuilderAPI_MakeWire(e[3],e[8],e[7],e[11]);

        BRep_Builder BB;
        TopoDS_Shell shell;
        BB.MakeShell(shell);
        for(int i=0;i<6;i++) {
            TopoDS_Face f=BRepBuilderAPI_MakeFace(w[i]);
            BB.Add(shell,i? f.Reversed():f);
        }
        TopoDS_Solid solid;
        BB.MakeSolid(solid);
        BB.Add(solid,shell);
        ShapeFix_Solid sf(solid);
        sf.Perform();
        shape=sf.Solid();
        } break;
    case 6: {
        TopoDS_Edge e[9];
        e[0]=BRepBuilderAPI_MakeEdge(v[0],v[1]);
        e[1]=BRepBuilderAPI_MakeEdge(v[1],v[2]);
        e[2]=BRepBuilderAPI_MakeEdge(v[2],v[3]);
        e[3]=BRepBuilderAPI_MakeEdge(v[3],v[0]);
        e[4]=BRepBuilderAPI_MakeEdge(v[0],v[4]);
        e[5]=BRepBuilderAPI_MakeEdge(v[1],v[4]);
        e[6]=BRepBuilderAPI_MakeEdge(v[2],v[6]);
        e[7]=BRepBuilderAPI_MakeEdge(v[3],v[6]);
        e[8]=BRepBuilderAPI_MakeEdge(v[4],v[6]);

        TopoDS_Wire w[5];
        w[0]=BRepBuilderAPI_MakeWire(e[0],e[1],e[2],e[3]);
        w[1]=BRepBuilderAPI_MakeWire(e[0],e[4],e[5]);
        w[2]=BRepBuilderAPI_MakeWire(e[2],e[6],e[7]);
        w[3]=BRepBuilderAPI_MakeWire(e[3],e[4],e[8],e[7]);
        w[4]=BRepBuilderAPI_MakeWire(e[1],e[5],e[8],e[6]);

        BRep_Builder BB;
#if 0
        TopoDS_Compound result;
        BB.MakeCompound(result);
        for(int i=0;i<5;i++) {
            BB.Add(result,BRepBuilderAPI_MakeFace(w[i]));
        }
        shape=result;
#else
        TopoDS_Shell shell;
        BB.MakeShell(shell);
        for(int i=0;i<5;i++) {
            TopoDS_Face f=BRepBuilderAPI_MakeFace(w[i]);
            BB.Add(shell,f); //i? f:f.Reversed());
        }
        TopoDS_Solid solid;
        BB.MakeSolid(solid);
        BB.Add(solid,shell);
        ShapeFix_Solid sf(solid);
        sf.Perform();
        shape=sf.Solid();
#endif
        } break;
//.........这里部分代码省略.........
开发者ID:feelpp,项目名称:debian-gmsh,代码行数:101,代码来源:BRLFile.cpp

示例5: MakeScaledPrism


//.........这里部分代码省略.........

  // 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++;
    }
    if (ifa > 0) {
      aSewing.Perform();
      TopoDS_Shape aShell;

      TopoDS_Shape sh = aSewing.SewedShape();
      if (sh.ShapeType() == TopAbs_FACE && ifa == 1) {
        // case for creation of shell from one face
        TopoDS_Shell ss;
        B.MakeShell(ss);
        B.Add(ss,sh);
        aShell = ss;
      }
      else {
        TopExp_Explorer exp (sh, TopAbs_SHELL);
        Standard_Integer ish = 0;
        for (; exp.More(); exp.Next()) {
          aShell = exp.Current();
          ish++;
        }
        if (ish != 1)
          aShell = sh;
      }
      BRepCheck_Shell chkShell (TopoDS::Shell(aShell));
      if (chkShell.Closed() == BRepCheck_NoError) {
        TopoDS_Solid Sol;
        B.MakeSolid(Sol);
        B.Add(Sol, aShell);
        BRepClass3d_SolidClassifier SC (Sol);
        SC.PerformInfinitePoint(Precision::Confusion());
        if (SC.State() == TopAbs_IN) {
          B.MakeSolid(Sol);
          B.Add(Sol, aShell.Reversed());
        }
        aShape = Sol;
      }
    }
  }

  return aShape;
}
开发者ID:dbarbier,项目名称:pythonocc,代码行数:101,代码来源:GEOMImpl_PrismDriver.cpp

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

示例7: 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


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