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

Search the Forums
See All Topics
 

Surface plane section area with OCC

Surface plane section area with OCC
Game Milky 2012/05/29 20:32

Dear All,

My problem is to cut irregular object made of surfaces (imported as IGES file) at different sections and to calculate the section area at different position (say x1, x2, x3, and so on)! ofcourse using OCC!

Does anybody worked same, i need your help,

Regards

Game
Ashish 2012/06/04 13:00
Hi Game,

Sometime in past I had used following code to do the same thing. Hope this will help. You could achieve same result using BRepAlgoAPI_Section.

Ashish

------------------------------------------------
BRepAlgoAPI_Common l_brepCom(l_tdShape,l_tdCutPln);//l_tdShape is object from IGES file, l_tdCutPln is topological object of cut plane
     if (!l_brepCom.IsDone())
          return;
     if (l_brepCom.Shape().IsNull())
          return;
     if (!BRepAlgo::IsValid(l_brepCom.Shape()))
          return;

     TopoDS_Shape l_tdCommon = l_brepCom.Shape();

     GProp_GProps l_gprop;
     BRepGProp::SurfaceProperties(l_tdCommon,l_gprop);
     Standard_Real l_rArea = l_gprop.Mass();
     BRepGProp::LinearProperties(l_tdCommon,l_gprop);
     Standard_Real l_rPeri = l_gprop.Mass();
     Standard_Real l_rDia = 4*l_rArea/l_rPeri;
Game Milky 2012/06/06 17:29
     

Hello Ashish,

Thank you very much for helpfull infomations. It helps a lot! But in my case, i have a surface and plane! I used BRepAlgoAPI_Section based on your suggestions. obviously the intersection is something like a curve or edge/wire. I need to mirrow this mirror this wire and finally should make a face. The face from mirroredwire and wire. Then to calculate the area, and other properties.

I succeeded sectioning, and mirror! and couldn't make the two wires together! So that to construct face and shape to calculate properties.

In addition: BRepGProp::SurfaceProperties(myFaceProfile,l_gprop); // myFaceProfile should be TOPO_DOS-SHape how to make shape from face!

I tried as follow!

The code part
Standard_Boolean PerformNow=Standard_False;
BRepAlgo_Section l_brepinter(shape, aSurface, PerformNow=Standard_True); // shape is imported and the aSurface (geomtric surface)
l_brepinter.ComputePCurveOn1(Standard_True);
l_brepinter.Approximation(Standard_True);
l_brepinter.Build();
TopoDS_Shape l_tdCommon = l_brepinter.Shape(); // l_tdCommon the intersection between shape and aSurface



// TopoDS_Wire WaterLineWire = TopoDS::Wire(l_brepinter.Shape());

// Now to create the face to calculate the waterline area
TopExp_Explorer aExpEdge;
      for(aExpEdge.Init(l_tdCommon,TopAbs_EDGE);aExpEdge.More();aExpEdge.Next())
      {
      TopoDS_Edge WaterLineEdge = TopoDS::Edge(aExpEdge.Current());
      TopLoc_Location aLocation;
      TopoDS_Wire WaterLineWire = BRepBuilderAPI_MakeWire(WaterLineEdge);
      TopoDS_Face WaterLineFace = BRepBuilderAPI_MakeFace(WaterLineWire, false);
      Handle(Geom_Surface) WaterLineSurface = BRep_Tool::Surface(WaterLineFace);

      //Reflect or mirror the wire

      gp_Pnt aOrigin(xmin , ymin , z);
      gp_Dir xDir(xmax , ymin , z);
      gp_Ax1 xAxis(aOrigin , xDir);

      //gp_Ax1 xAxis = gp::OX();
      gp_Trsf aTrsf;
      aTrsf.SetMirror(xAxis);

      BRepBuilderAPI_Transform aBRepTrsf(WaterLineWire , aTrsf);

      TopoDS_Shape aMirroredShape = aBRepTrsf.Shape();

      TopoDS_Wire aMirroredWire = TopoDS::Wire(aBRepTrsf.Shape());

      BRepBuilderAPI_MakeWire mkWire;

      mkWire.Add(WaterLineWire);
      mkWire.Add(aMirroredWire);

      TopoDS_Wire myWireProfile = mkWire.Wire();

      TopoDS_Face myFaceProfile = BRepBuilderAPI_MakeFace(myWireProfile);



      //Global properties of the geometric components
      GProp_GProps l_gprop;
            BRepGProp::SurfaceProperties(myFaceProfile,l_gprop);
            Standard_Real l_rArea = l_gprop.Mass();
            //BRepGProp::LinearProperties(WaterLineSurface,l_gprop);
            Standard_Real l_rPeri = l_gprop.Mass();
            Standard_Real l_rDia = 4*l_rArea/l_rPeri;
            // qDebug ()<<l_rArea;

      }

Have no compiler error,
In output it says!

terminate called after throwing an instance of 'StdFail_NotDone'
 
 
Latest news
  • Open CASCADE Technology 6.8.0 is available for download!
  • New features to enhance the development process
  • Open CASCADE Technology 6.7.1 is available for download!

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