本文整理汇总了C++中BRep_Builder::MakeWire方法的典型用法代码示例。如果您正苦于以下问题:C++ BRep_Builder::MakeWire方法的具体用法?C++ BRep_Builder::MakeWire怎么用?C++ BRep_Builder::MakeWire使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BRep_Builder
的用法示例。
在下文中一共展示了BRep_Builder::MakeWire方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
}
示例2: BRepAdaptor_CompCurve
BRepAdaptor_CompCurve* StdMeshers_FaceSide::GetCurve3d() const
{
if ( myEdge.empty() )
return 0;
// if ( myEdge.size() == 1 )
// return new BRepAdaptor_Curve( myEdge[0] );
TopoDS_Wire aWire;
BRep_Builder aBuilder;
aBuilder.MakeWire(aWire);
for ( int i=0; i<myEdge.size(); ++i )
aBuilder.Add( aWire, myEdge[i] );
return new BRepAdaptor_CompCurve( aWire );
}
示例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;
}
}
示例4: MergeEdges
//.........这里部分代码省略.........
TopoDS_Vertex V1 = sae.FirstVertex(edge1);
gp_Pnt PV1 = BRep_Tool::Pnt(V1);
TopoDS_Vertex V2 = sae.LastVertex(edge2);
gp_Pnt PV2 = BRep_Tool::Pnt(V2);
TopoDS_Vertex VM = sae.LastVertex(edge1);
gp_Pnt PVM = BRep_Tool::Pnt(VM);
GC_MakeCircle MC (PV1,PVM,PV2);
Handle(Geom_Circle) C = MC.Value();
TopoDS_Edge E;
if (!MC.IsDone() || C.IsNull()) {
// jfa for Mantis issue 0020228
if (PV1.Distance(PV2) > Precision::Confusion()) continue;
// closed chain
C = C1;
B.MakeEdge (E,C,Precision::Confusion());
B.Add(E,V1);
B.Add(E,V2);
}
else {
gp_Pnt P0 = C->Location();
gp_Dir D1(gp_Vec(P0,PV1));
gp_Dir D2(gp_Vec(P0,PV2));
Standard_Real fpar = C->XAxis().Direction().Angle(D1);
if(fabs(fpar)>Precision::Confusion()) {
// check orientation
gp_Dir ND = C->XAxis().Direction().Crossed(D1);
if(ND.IsOpposite(C->Axis().Direction(),Precision::Confusion())) {
fpar = -fpar;
}
}
Standard_Real lpar = C->XAxis().Direction().Angle(D2);
if(fabs(lpar)>Precision::Confusion()) {
// check orientation
gp_Dir ND = C->XAxis().Direction().Crossed(D2);
if(ND.IsOpposite(C->Axis().Direction(),Precision::Confusion())) {
lpar = -lpar;
}
}
if(lpar<fpar) lpar += 2*M_PI;
Handle(Geom_TrimmedCurve) tc = new Geom_TrimmedCurve(C,fpar,lpar);
B.MakeEdge (E,tc,Precision::Confusion());
B.Add(E,V1);
B.Add(E,V2);
B.UpdateVertex(V1, fpar, E, 0.);
B.UpdateVertex(V2, lpar, E, 0.);
}
aChain.Remove(j);
aChain.SetValue(j,E);
j--;
}
}
if (j < aChain.Length()) {
MESSAGE ("null curve3d in edge...");
return Standard_False;
}
if (aChain.Length() > 1) {
// second step: union edges with various curves
// skl for bug 0020052 from Mantis: perform such unions
// only if curves are bspline or bezier
bool NeedUnion = true;
for(j=1; j<=aChain.Length(); j++) {
TopoDS_Edge edge = TopoDS::Edge(aChain.Value(j));
Handle(Geom_Curve) c3d = BRep_Tool::Curve(edge,Loc,fp1,lp1);
if(c3d.IsNull()) continue;
while(c3d->IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) {
Handle(Geom_TrimmedCurve) tc =
Handle(Geom_TrimmedCurve)::DownCast(c3d);
c3d = tc->BasisCurve();
}
if( ( c3d->IsKind(STANDARD_TYPE(Geom_BSplineCurve)) ||
c3d->IsKind(STANDARD_TYPE(Geom_BezierCurve)) ) ) continue;
NeedUnion = false;
break;
}
if(NeedUnion) {
MESSAGE ("can not make analitical union => make approximation");
TopoDS_Wire W;
B.MakeWire(W);
for(j=1; j<=aChain.Length(); j++) {
TopoDS_Edge edge = TopoDS::Edge(aChain.Value(j));
B.Add(W,edge);
}
Handle(BRepAdaptor_HCompCurve) Adapt = new BRepAdaptor_HCompCurve(W);
Approx_Curve3d Conv(Adapt,Tol,GeomAbs_C1,9,1000);
Handle(Geom_BSplineCurve) bc = Conv.Curve();
TopoDS_Edge E;
B.MakeEdge (E,bc,Precision::Confusion());
B.Add (E,VF);
B.Add (E,VL);
aChain.SetValue(1,E);
}
else {
MESSAGE ("can not make approximation for such types of curves");
return Standard_False;
}
}
anEdge = TopoDS::Edge(aChain.Value(1));
return Standard_True;
}
示例5: Perform
//=======================================================================
//function : Perform
//purpose :
//=======================================================================
void Partition_Loop::Perform()
{
TopTools_DataMapOfShapeListOfShape MVE;
TopTools_DataMapIteratorOfDataMapOfShapeListOfShape Mapit, Mapit1;
TopTools_ListIteratorOfListOfShape itl;
TopoDS_Vertex V1,V2;
//-----------------------------------
// Construction map vertex => edges
//-----------------------------------
for (itl.Initialize(myConstEdges); itl.More(); itl.Next()) {
TopoDS_Edge& E = TopoDS::Edge(itl.Value());
StoreInMVE(myFace,E,MVE);
}
//----------------------------------------------
// Construction of all the wires and of all the new faces.
//----------------------------------------------
TopTools_MapOfOrientedShape UsedEdges;
while (!MVE.IsEmpty()) {
TopoDS_Vertex VF,CV;
TopoDS_Edge CE,NE,EF;
TopoDS_Wire NW;
BRep_Builder B;
Standard_Boolean End= Standard_False;
B.MakeWire(NW);
//--------------------------------
// EF first edge.
//--------------------------------
Mapit.Initialize(MVE);
EF = CE = TopoDS::Edge(Mapit.Value().First());
TopExp::Vertices(CE,V1,V2);
//--------------------------------
// VF first vertex
//--------------------------------
if (CE.Orientation() == TopAbs_FORWARD) {
CV = VF = V1;
}
else {
CV = VF = V2;
}
if (!MVE.IsBound(CV)) continue;
for ( itl.Initialize(MVE(CV)); itl.More(); itl.Next()) {
if (itl.Value().IsEqual(CE)) {
MVE(CV).Remove(itl);
break;
}
}
int i = 0;
while (!End) {
//-------------------------------
// Construction of a wire.
//-------------------------------
TopExp::Vertices(CE,V1,V2);
if (!CV.IsSame(V1)) CV = V1; else CV = V2;
B.Add (NW,CE);
UsedEdges.Add(CE);
//--------------
// stop test
//--------------
if (!MVE.IsBound(CV) || MVE(CV).IsEmpty() || CV.IsSame(VF) ) {
if (CV.IsSame(VF)) {
if (MVE(CV).Extent() == 1 ) MVE.UnBind(CV);
else {
for ( itl.Initialize(MVE(CV)); itl.More(); itl.Next()) {
if (itl.Value().IsEqual(CE)) {
MVE(CV).Remove(itl);
break;
}
}
}
}
End=Standard_True;
}
//--------------
// select edge
//--------------
else {
Standard_Boolean find = SelectEdge(myFace,CE,CV,NE,MVE(CV));
if (find) {
CE=NE;
if (MVE(CV).IsEmpty()) MVE.UnBind(CV);
if (CE.IsNull() ) {
MESSAGE ( " CE is NULL !!! " )
End=Standard_True;
}
}
else {
MESSAGE ( " edge doesn't exist " )
//.........这里部分代码省略.........
示例6: 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());
//.........这里部分代码省略.........