Open CASCADE, the 3D modelling kernel
3D modeling & numerical simulation

Search the Forums
See All Topics
 

problem: making face from wire

problem: making face from wire
shanvens 2012/03/09 07:45
Hello,

I came across a problem making face from wire: the face can not be built.
It's supposed to have a solid in the end, however i get the result like the pic shows.
Could someone tell me where am i wrong?

the code is below:

     TopoDS_Wire aWire1=BRepBuilderAPI_MakeWire(aEdge1,aEdge2,aEdge3,aEdge4);
     TopoDS_Wire aWire2=BRepBuilderAPI_MakeWire(aEdge3,aEdge4,aEdge5);
     BRepBuilderAPI_MakeWire wire;
     wire.Add(aWire1);
     wire.Add(aWire2);
     TopoDS_Wire aWire=wire.Wire();

////////////////     
     gp_Pnt origin(0,0,0);
     gp_Dir xDir(0,0,1);
     gp_Ax1 mirrorAxis(origin,xDir);
     gp_Trsf aTrsf;
     aTrsf.SetMirror(mirrorAxis);
     BRepBuilderAPI_Transform aBrepTrsf(aWire,aTrsf);
     TopoDS_Shape aMirrorShape=aBrepTrsf.Shape();
     TopoDS_Wire aMirrorWire=TopoDS::Wire(aMirrorShape);

     BRepBuilderAPI_MakeWire mkWire;
     mkWire.Add(aWire);
     mkWire.Add(aMirrorWire);
     TopoDS_Wire profileWire=mkWire.Wire();

     TopoDS_Face aFace=BRepBuilderAPI_MakeFace(profileWire);
     gp_Vec aPrismVec(length,0,0);
     TopoDS_Shape body=BRepPrimAPI_MakePrism(aFace,aPrismVec);

You have to be logged in to download the attached file
Game Milky 2012/07/09 17:09
     
Hello shanvens,

In my case, the edges are disconnected and i somehow connected them and created a wire, and I mirrored the wire. When i try to add them to one wire (wire and mirrorWire) it doesn't work. Would you please share your idea!
With regards

Game

Game!
George Feng 2012/07/10 20:40
     The wire should be reordered firstly with ShapeFix.

TopoDS_Wire OccUtility::MakeWireWithEdges(CList <TopoDS_Edge, TopoDS_Edge> &aEdgeList)
{
TopoDS_Edge aEdge;
BRepBuilderAPI_MakeWire aMakeWire;
Standard_Real tol = 0.01;
ShapeFix_ShapeTolerance FTol;

Handle(ShapeExtend_WireData) sbwd1 = new ShapeExtend_WireData();
POSITION pos = aEdgeList.GetHeadPosition();

while (pos)
{
aEdge = aEdgeList.GetNext(pos);
sbwd1->Add(aEdge);
}

Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire;
sfw->Load(sbwd1);
sfw->Perform();
//Reorder edges is very important
sfw->FixReorder();
sfw->SetMaxTolerance(tol);
///////////////////////////////////
sfw->ClosedWireMode() = Standard_True;
sfw->FixConnected(1.e-3);
sfw->FixClosed(1.e-3);

for (int i = 1; i <= sfw->NbEdges(); i ++)
{
TopoDS_Edge Edge = sfw->WireData()->Edge(i);
FTol.SetTolerance(Edge, tol, TopAbs_VERTEX);
aMakeWire.Add(Edge);
}

TopoDS_Wire aWire = aMakeWire.Wire();
return aWire;
}
Game Milky 2012/07/12 13:17
     Dear Feng;

Thank for your reply!
I have a difficulty to implement your suggestion into my case,
I have disconnected, disordered , and wrongly oriented Edges in TopoDS_Shape shapecommon. I have order, connect, and propertly orient this edges and make a wire from them. Finally to make face...........

Standard_Real tol = 0.01;
BRepBuilderAPI_MakeWire brepMake;
ShapeFix_ShapeTolerance FTol;


Handle(ShapeExtend_WireData) aWD = new ShapeExtend_WireData();
TopExp_Explorer edgeExp; for(TopExp_Explorer edgeExp(shapeCommon, TopAbs_EDGE); edgeExp.More(); edgeExp.Next()) //TopDS_Shape shapecommon -consists disconnected edges
      {
TopoDS_Edge Edge = TopoDS::Edge(edgeExp.Current());
POSITION pos = Edge.GetHeadPosition(); // Here I replaced aEdgeList with explored Edge, but it doesn't work!
While(pos) //Doesn't Understand the syntax POSITION
      {
      aEdge = Edge.GetNext(pos);
      aWD->Add(aEdge);
      }
     }

Handle(ShapeFix_Wire) aShFW = new ShapeFix_Wire();
aShFW->Load(aWD);
aShFW->Perform();
// aShFW->ClosedWireMode() = Standard_True;
aShFW->FixReorder();
aShFW->SetMaxTolerance(tol);
aShFW->ClosedWireMode() = Standard_True;
aShFW->FixConnected(1.e-3);
aShFW->FixClosed(1.e-3);
for (int i = 1; i <= aShFW->NbEdges(); i ++)
{
TopoDS_Edge Edge = aShFW->WireData()->Edge(i);
FTol.SetTolerance(Edge, tol, TopAbs_VERTEX);
brepMake.Add(Edge);
}

TopoDS_Wire wire = brepMake.Wire();

So, the program doesn't work as i replaced aEdgeList with explored Edge, but it doesn't work!
Would you please suggest me how to correct!
Thank you very much

Regards
Game
George Feng 2012/07/13 15:55
     TopoDS_Wire OccUtility::OrderWire(TopoDS_Wire &aWire)
{
     TopoDS_Edge aEdge;
     BRepBuilderAPI_MakeWire aMakeWire;
     Standard_Real tol = 0.01;
     ShapeFix_ShapeTolerance FTol;
     TopExp_Explorer ExpEdges;

     Handle(ShapeExtend_WireData) sbwd1 = new ShapeExtend_WireData();

     for (ExpEdges.Init(aWire, TopAbs_EDGE); ExpEdges.More(); ExpEdges.Next())
     {
          aEdge = TopoDS::Edge(ExpEdges.Current());
          sbwd1->Add(aEdge);
     }

     Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire;
     sfw->Load(sbwd1);
     sfw->Perform();
     //Reorder edges is very important
     sfw->FixReorder();
     sfw->SetMaxTolerance(tol);
     ///////////////////////////////////
     sfw->ClosedWireMode() = Standard_True;
     sfw->FixConnected(Precision::Confusion());
     sfw->FixClosed(Precision::Confusion());

     for (int i = 1; i <= sfw->NbEdges(); i ++)
     {
           TopoDS_Edge Edge = sfw->WireData()->Edge(i);
           FTol.SetTolerance(Edge, tol, TopAbs_VERTEX);
           aMakeWire.Add(Edge);
     }

     TopoDS_Wire aWire = aMakeWire.Wire();
     return aWire;
}
 
 
Latest news
  • New features to enhance the development process
  • Open CASCADE Technology 6.7.1 is available for download!
  • Open CASCADE Technology 6.7.0 is available for download!

  • © OPEN CASCADE 2000 - 2014  |  Search  |  Contacts   |  Site map