Class BREP


  • public class BREP
    extends GeometryData
    Boundary representation (or B-Rep) of a geometric shape, using a collection of
    connected surfaces, edges and vertices.

    In the Shell representation, the geometric shape is formed as a collection of disconnected
    faces. The BREP representation adds more information about the topology, as surface and curve
    elements are connected. For a certain surface, curve or vertex, it is possible to find
    information about the directly connected neighbouring surfaces, edges and vertices. From a
    BREP it is also possible to retrieve a Shell representation, but in the Shell representation
    information about connectedness is lost.

    The half-edge data structure is used internally to store the topological information about
    the faces, edges and vertices, and how they are connected. Subtypes of BREP implements the
    concrete Surface and Curve geometries that can be attached to the faces and edges.

    In general, the procedure for forming a BREP is the following:

    1. Add all the needed vertices by using the addVertex function.
    Each vertex is given an index starting, increasing from zero.

    2. Add the edges. An edge is added between two vertices using their vertex indexes.
    Addition of edges is documented under the specific BREP implementation (depending on the type
    of Curve that is expected). The edge is in general added with a Curve and two vertex indices.
    Notice that the curve must have limits, such that it starts in the first vertex and ends in
    the second vertex (the curve has a direction). Each edge is given an index, increasing from
    zero.

    3. Use the makeLoop function to form loops, based on the edges just added. The makeLoop takes
    an arbitrary number of edge indices. Notice that makeLoop expects the edge indexing to start
    at 1, and supports negative indices to indicate opposite direction of the edge. To form a
    loop, a list of these indexes is given, to form a counter clockwise loop of edges. Each loop
    is given a loop index, increasing from zero.

    4. Attach a Surface to each loop. Again, the addition of surfaces is documented under the
    specific BREP implementation (depending on the type of Surface that is expected). Each
    surface is given an increasing surface index, starting from zero. Notice that this index is
    not necessarily the same as the loop index.
    • Constructor Summary

      Constructors 
      Constructor Description
      BREP​(long cPtr, boolean cMemoryOwn)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addVertex​(Vector3D point)
      Add a vertex to the BREP.
      BREPPtr clone()
      Make a deep copy of the BREP.
      void delete()  
      long edgeCount()
      The number of edges.
      OBB edgeOBR​(long edge)
      Create Oriented Bounding Rectangle for an edge.
      long faceCount()
      The number of faces.

      The number of faces is the number of loops, where a surface has been attached.

      pair_d_d faceExtremums​(long faceIndex, Vector3D dir)
      Find the extent of the surface along a specific direction.

      If the surface has no lower bound, the value -%std::numeric_limits<double>::%max() can
      be returned to indicate that the surface has unbounded minimum value in the given
      direction.

      If the surface has no upper bound, the value %std::numeric_limits<double>::%max() can
      be returned to indicate that the surface has unbounded maximum value in the given
      direction.

      OBB faceOBB​(long faceIndex)
      Create Oriented Bounding Box for a face.
      TriMeshPtr faceTriMesh​(long faceIndex)
      Construct a Triangle Mesh for a face.
      SWIGTYPE_p_rw__core__PtrT_rw__geometry__BREP__CommonCurveSet_const_t getCommonCurves​(SWIGTYPE_p_std__setT_unsigned_long_t faces)
      Get a set of common curves between a set of faces.
      static long getCPtr​(BREP obj)  
      Curve getCurve​(long curveIndex)
      Get curve.
      SWIGTYPE_p_std__vectorT_rw__core__PtrT_rw__geometry__Curve_t_t getCurves​(long loopIdx)
      Get the curves in a given loop.

      The curves will be traversed in an ordered way, and curves will have a direction that
      leads to the next curve.

      Surface getSurface​(long surfaceIndex)
      Get surface.
      long getSurfaceIndex​(long loop)
      Get the surface index of a loop.
      TriMeshPtr getTriMesh()
      Create a TriMesh representation from this boundary representation.

      This function relies on the resolution set with setMeshResolution.
      The resolution is passed on to Curve::discretizeAdaptive and
      Surface::setDiscretizationResolution.


      TriMeshPtr getTriMesh​(boolean forceCopy)
      Create a TriMesh representation from this boundary representation.

      This function relies on the resolution set with setMeshResolution.
      The resolution is passed on to Curve::discretizeAdaptive and
      Surface::setDiscretizationResolution.

      GeometryData.GeometryType getType()
      the type of this primitive
      Vector3D getVertex​(long vertexIndex)
      Get vertex.
      SWIGTYPE_p_std__vectorT_rw__math__Vector3DT_double_t_t getVertices​(long loopIdx)
      Get the vertices in a given loop.

      The curves will be traversed in an ordered way around the loop.

      boolean hasSurfaceSet​(long loop)
      Check if a certain loop has a surface set.
      boolean isConvex()
      test if this geometry data is convex
      long loopCount()
      The number of loops.
      void makeLoop​(int singleEdgeId)
      Create a loop containing a single edge (typically for circles and ellipses and
      similar).

      The half-edge structure requires that an edge must start and end in a vertex.
      OBB obb()
      Create Oriented Bounding Box where the directions are estimated.

      This method is more expensive than obb(const rw::math::Rotation3D<>&),
      because a TriMesh is formed to estimated the principal directions of the OBB.

      OBB obb​(SWIGTYPE_p_rw__math__Rotation3DT_t R)
      Create Oriented Bounding Box with certain principal directions.
      void printObj()
      Print the structure of the BREP for debugging purposes.
      void scale​(double factor)
      Scale the object.
      void setMeshResolution()
      Set the resolution used for discretization in the getTriMesh and faceTriMesh
      functions.

      The meaning of this parameter depends on the type of surface.

      void setMeshResolution​(double resolution)
      Set the resolution used for discretization in the getTriMesh and faceTriMesh
      functions.

      The meaning of this parameter depends on the type of surface.

      ShellCPtr shellProxy()
      Get a Shell representation as a proxy to the BREP.
      void stitchAuto​(double eps)
      Try to stitch edges automatically.
      void stitchEdges​(long first, long second)  
      long verticeCount()
      The number of vertices.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • BREP

        public BREP​(long cPtr,
                    boolean cMemoryOwn)
    • Method Detail

      • getCPtr

        public static long getCPtr​(BREP obj)
      • getTriMesh

        public TriMeshPtr getTriMesh​(boolean forceCopy)
        Create a TriMesh representation from this boundary representation.

        This function relies on the resolution set with setMeshResolution.
        The resolution is passed on to Curve::discretizeAdaptive and
        Surface::setDiscretizationResolution.

        Overrides:
        getTriMesh in class GeometryData
        Parameters:
        forceCopy - [in] generate a new copy, or use a cached TriMesh.
        Returns:
        a new TriMesh if forceCopy is true, or a shared cached TriMesh if forceCopy
        is false.
      • getTriMesh

        public TriMeshPtr getTriMesh()
        Create a TriMesh representation from this boundary representation.

        This function relies on the resolution set with setMeshResolution.
        The resolution is passed on to Curve::discretizeAdaptive and
        Surface::setDiscretizationResolution.


        Overrides:
        getTriMesh in class GeometryData
        Returns:
        a new TriMesh if forceCopy is true, or a shared cached TriMesh if forceCopy
        is false.
      • isConvex

        public boolean isConvex()
        Description copied from class: GeometryData
        test if this geometry data is convex
        Overrides:
        isConvex in class GeometryData
        Returns:
        true if convex
      • getSurface

        public Surface getSurface​(long surfaceIndex)
        Get surface.
        Parameters:
        surfaceIndex - [in] the index of the surface. Should be less than the number
        returned by size().
        Returns:
        a reference to the surface.
      • getCurve

        public Curve getCurve​(long curveIndex)
        Get curve.
        Parameters:
        curveIndex - [in] index of the curve. Should be less than the number returned by
        edgeCount().
        Returns:
        a reference to the curve.
      • scale

        public void scale​(double factor)
        Scale the object.
        Parameters:
        factor - [in] the factor to scale with.
      • clone

        public BREPPtr clone()
        Make a deep copy of the BREP.
        Returns:
        a copy of the BREP.
      • shellProxy

        public ShellCPtr shellProxy()
        Get a Shell representation as a proxy to the BREP.
        Returns:
        smart pointer to a Shell proxy object.
      • getCurves

        public SWIGTYPE_p_std__vectorT_rw__core__PtrT_rw__geometry__Curve_t_t getCurves​(long loopIdx)
        Get the curves in a given loop.

        The curves will be traversed in an ordered way, and curves will have a direction that
        leads to the next curve.

        Parameters:
        loopIdx - [in] the loop index.
        Returns:
        an ordered vector of curves.
      • faceCount

        public long faceCount()
        The number of faces.

        The number of faces is the number of loops, where a surface has been attached.

        Returns:
        the number of faces.
      • loopCount

        public long loopCount()
        The number of loops.
        Returns:
        the number of loops.
      • edgeCount

        public long edgeCount()
        The number of edges.
        Returns:
        the number of edges.
      • verticeCount

        public long verticeCount()
        The number of vertices.
        Returns:
        the number of vertices.
      • getVertex

        public Vector3D getVertex​(long vertexIndex)
        Get vertex.
        Parameters:
        vertexIndex - [in] index of the vertex. Should be less than the number returned by
        vertices().
        Returns:
        reference to the vertex.
      • getVertices

        public SWIGTYPE_p_std__vectorT_rw__math__Vector3DT_double_t_t getVertices​(long loopIdx)
        Get the vertices in a given loop.

        The curves will be traversed in an ordered way around the loop.

        Parameters:
        loopIdx - [in] the loop index.
        Returns:
        a collection of vertices.
      • hasSurfaceSet

        public boolean hasSurfaceSet​(long loop)
        Check if a certain loop has a surface set.
        Parameters:
        loop - [in] index of the loop, which should be less than loopCount().
        Returns:
        true if a surface is set, false otherwise.
      • getSurfaceIndex

        public long getSurfaceIndex​(long loop)
        Get the surface index of a loop.
        Parameters:
        loop - [in] the loop index.
        Returns:
        the corresponding surface index.
      • obb

        public OBB obb​(SWIGTYPE_p_rw__math__Rotation3DT_t R)
        Create Oriented Bounding Box with certain principal directions.
        Parameters:
        R - [in] the directions for the bounding box.
        Returns:
        an OBB around the BREP.
      • obb

        public OBB obb()
        Create Oriented Bounding Box where the directions are estimated.

        This method is more expensive than obb(const rw::math::Rotation3D<>&),
        because a TriMesh is formed to estimated the principal directions of the OBB.

        Returns:
        an OBB around the BREP.
      • addVertex

        public void addVertex​(Vector3D point)
        Add a vertex to the BREP.
        Parameters:
        point - [in] the vertex to add.
      • makeLoop

        public void makeLoop​(int singleEdgeId)
        Create a loop containing a single edge (typically for circles and ellipses and
        similar).

        The half-edge structure requires that an edge must start and end in a vertex. Sometimes
        it is possible to have an edge without any vertices. This is, for example, the case for a
        circular or elliptic cylinder, where there will be two circular or elliptic edges.
        It is necessary to place one vertex on the circle or ellipse that can act as both the
        start and end vertex for the curve.

        Parameters:
        singleEdgeId - [in] id of the edge to create loop for. 1-indexing is expected, with
        a sign that indicates the edge direction.
      • stitchEdges

        public void stitchEdges​(long first,
                                long second)
      • stitchAuto

        public void stitchAuto​(double eps)
        Try to stitch edges automatically.
        Parameters:
        eps - [in] distance threshold for vertices and curves.
      • faceOBB

        public OBB faceOBB​(long faceIndex)
        Create Oriented Bounding Box for a face.
        Parameters:
        faceIndex - [in] the face index, which should be less than loopCount().
        Returns:
        OBB for the given face.
      • edgeOBR

        public OBB edgeOBR​(long edge)
        Create Oriented Bounding Rectangle for an edge.
        Parameters:
        edge - [in] the edge index, which should be less than edgeCount().
        Returns:
        OBB for the given edge (with third half-length set to zero).
      • faceExtremums

        public pair_d_d faceExtremums​(long faceIndex,
                                      Vector3D dir)
        Find the extent of the surface along a specific direction.

        If the surface has no lower bound, the value -%std::numeric_limits<double>::%max() can
        be returned to indicate that the surface has unbounded minimum value in the given
        direction.

        If the surface has no upper bound, the value %std::numeric_limits<double>::%max() can
        be returned to indicate that the surface has unbounded maximum value in the given
        direction.

        Parameters:
        faceIndex - [in] the face index, which should be less than loopCount().
        dir - [in] a normalized direction vector.
        Returns:
        the minimum and maximum values along the given direction.
      • faceTriMesh

        public TriMeshPtr faceTriMesh​(long faceIndex)
        Construct a Triangle Mesh for a face.
        Parameters:
        faceIndex - [in] the face index, which should be less than loopCount().
        Returns:
        a triangle mesh.
      • setMeshResolution

        public void setMeshResolution​(double resolution)
        Set the resolution used for discretization in the getTriMesh and faceTriMesh
        functions.

        The meaning of this parameter depends on the type of surface.

        Parameters:
        resolution - [in] the resolution parameter.
      • setMeshResolution

        public void setMeshResolution()
        Set the resolution used for discretization in the getTriMesh and faceTriMesh
        functions.

        The meaning of this parameter depends on the type of surface.

      • printObj

        public void printObj()
        Print the structure of the BREP for debugging purposes.