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


My first application
  • Profile - defining support points
  • Profile - defining the geometry
  • Profile - defining the topology
  • Profile - completing the profile
  • Body - prism the profile
  • Body - applying fillets
  • Body - adding the neck
  • Body - creating a hollowed solid
  • Threading - creating surfaces
  • Threading - defining 2D curves
  • Threading - building edges and wires
  • Threading - creation and building the resulting compound


  • Open CASCADEShowroomGet it!Developer CornerSupport and ProductsAbout us
    Technical overview
    Areas of use
    Advantages
    FAQ
    Screenshots
    Shape factory
    Shape gallery
    Demonstrations
    What's new
    System requirements
    Download Center
    Public license
    Documentation
    Getting started
    Forums
    Open Source community
    Training and e-learning
    A-la Carte Support
    Value-added software
    Complementary Components
    Customer Corner
    Company Profile
    Marketing Materials
    Contact Us
    News
    Home / Developer Corner / Getting started / My first application / Body - creating a hollowed solid

    Body - creating a hollowed solid

    Since a real bottle is used to contain a liquid, you should now create a hollowed solid from the bottle's top face.

    In Open CASCADE Technology, a hollowed solid is called a Thick Solid and is internally computed as follows:

    - Remove one or more faces from the initial solid to obtain the first wall W1 of the hollowed solid.
    - Create a parallel wall W2 from W1 at a distance D. If D is positive, W2 will be outside the initial solid, otherwise it will be inside.
    - Compute the solid from the two walls W1 and W2.


     



    To compute a thick solid, you create an instance of the BRepOffsetAPI_MakeThickSolid class by giving the following information:

    - The shape which must be hollowed.
    - The tolerance used for the computation (tolerance criterion for coincidence in generated shapes).
    - The thickness between the two walls W1 and W2 (distance D).
    - The face(s) to remove from original solid to compute the first wall W1.

    The challenging part in this procedure is to find the face to remove from your shape - the top face of the neck, which:

    - has a plane surface as underlying geometry
    - is the heighest face (in Z coordinates) of the bottle

    To find the face with such characteristics, you will once again use the explorer to iterate on all faces of the bottle to find the appropriate one.


    for(TopExp_Explorer aFaceExplorer(myBody , TopAbs_FACE) ; aFaceExplorer.More() ; aFaceExplorer.Next()){
    TopoDS_Face aFace = TopoDS::Face(aFaceExplorer.Current());
    TopoDS_Face aFace = TopoDS::Face(aFaceExplorer.Current());
    }


    For each detected face, you retrieve its surface. You then need a tool to access the geometric properties of the shape: use the BRep_Tool class. The most commonly used methods of this class are:

    - Surface to access the surface of a face
    - Curve to access the 3D curve of an edge
    - Point to access the 3D point of a vertex


    Handle(Geom_Surface) aSurface = BRep_Tool::Surface(aFace);


    As you can see, the BRep_Tool::Surface method returns an instance of the Geom_Surface class manipulated by handle. However, the Geom_Surface class does not provide information about the real type of the object aSurface which could be an instance of Geom_Plane, Geom_CylindricalSurface, etc.

    All objects manipulated by handle, like Geom_Surface, inherit from the Standard_Transient class which contains two very useful methods concerning types:

    - DynamicType to know the real type of the object
    - IsKind to know if the object inherits from one particular type

    DynamicType returns the real type of the object, but you need to compare it with the existing known types to determine if aSurface is a plane, a cylindrical surface or some other type.

    To compare a given type with the type you seek, use the STANDARD_TYPE macro which returns the type of a class:


    if(aSurface->DynamicType() == STANDARD_TYPE(Geom_Plane)){
    ...
    }


    If this comparison is true, you know that the aSurface real type is Geom_Plane. You can then convert it from Geom_Surface to Geom_Plane by using another useful function from Standard_Transient: the DownCast method. As its name implies, this static method is used to downcast objects to a given type with the following syntax:


    Handle(Geom_Plane) aPlane = Handle(Geom_Plane)::DownCast(aSurface);


    Remember that the goal of all these conversions is to find the highest face of the bottle lying on a plane. Suppose that you have these two global variables:


    TopoDS_Face faceToRemove;

    Standard_Real zMax = -1;


    You can easily find the plane whose origin is the biggest in Z knowing that the location of the plane is given with the Geom_Plane::Location method. For example:


    gp_Pnt aPnt = aPlane->Location();

    Standard_Real aZ = aPnt.Z();

    if(aZ > zMax){
    zMax = aZ;
    faceToRemove = aFace;
    }


    You have now found the top face of the neck. Your final step before creating the hollowed solid is to put this face on a list. Since more than one face can be removed from the initial solid, the BRepOffsetAPI_MakeThickSolid constructor takes a list of faces as arguments.

    Open CASCADE Technology provides many collections for different kind of objects: TColGeom package for collections of objects from Geom package, TColgp package for collections of objects from gp packages, etc.

    The collection for shapes can be found in the TopTools package. As BRepOffsetAPI_MakeThickSolid requires a list, use the TopTools_ListOfShape class.


    TopTools_ListOfShape facesToRemove;

    facesToRemove.Append(faceToRemove);


    All the necessary data is now available so you can create your hollowed solid by calling the BRepOffsetAPI_MakeThickSolid constructor:


    myBody = BRepOffsetAPI_MakeThickSolid(myBody , facesToRemove , -myThickness / 50 , 1.e-3);

    next step
    previous step


     
     

    © OPEN CASCADE 2000 - 2013  |  Search  |  Contacts   |  Site map