コード例 #1
0
def face_area(face):
    """Area of a face.

    Parameters
    ----------
    face : TopoDS_Face
        The face for which the area is searched.

    Returns
    -------
    float
        Area of the face.

    Notes
    -----
    For references, see

    - https://dev.opencascade.org/doc/refman/html/class_b_rep_g_prop.html#abd91b892df8d0f6b8571deed5562ca1f
    - https://techoverflow.net/2019/06/13/how-to-compute-surface-area-of-topods_face-in-opencascade/
    - https://github.com/tpaviot/pythonocc-demos/blob/master/examples/core_shape_properties.py#L48

    """
    properties = GProp_GProps()
    brepgprop_SurfaceProperties(face, properties)
    return properties.Mass()
コード例 #2
0
    def system(self):
        r"""Initialise the GProp_GProps depending on the topological type

        Notes
        -----
        geom_type could be abstracted with TopoDS... instead of using _topo_type

        Returns
        -------
        OCC.GProp.GProp_GProps

        """
        self._system = GProp_GProps()

        if self._topo_type in GlobalProperties.surfacic_types:
            brepgprop_SurfaceProperties(self.shape, self._system)
        elif self._topo_type in GlobalProperties.linear_types:
            brepgprop_LinearProperties(self.shape, self._system)
        elif self._topo_type in GlobalProperties.volumic_types:
            brepgprop_VolumeProperties(self.shape, self._system)
        else:
            msg = "ShapeType is not linear, surfacic or volumic"
            logger.error(msg)
            raise WrongTopologicalType(msg)
        return self._system
コード例 #3
0
 def system(self):
     self._system = GProp_GProps()
     # todo, type should be abstracted with TopoDS...
     _topo_type = self.instance.topo_type
     if _topo_type == 'face' or _topo_type == 'shell':
         brepgprop_SurfaceProperties(self.instance, self._system)
     elif _topo_type == 'edge':
         brepgprop_LinearProperties(self.instance, self._system)
     elif _topo_type == 'solid':
         brepgprop_VolumeProperties(self.instance, self._system)
     return self._system
コード例 #4
0
ファイル: base.py プロジェクト: aothms/pythonocc-utils
 def system(self):
     self._system = GProp_GProps()
     # todo, type should be abstracted with TopoDS...
     _topo_type = self.instance.topo_type
     if _topo_type == 'face' or _topo_type == 'shell':
         brepgprop_SurfaceProperties(self.instance, self._system)
     elif _topo_type == 'edge':
         brepgprop_LinearProperties(self.instance, self._system)
     elif _topo_type == 'solid':
         brepgprop_VolumeProperties(self.instance, self._system)
     return self._system
コード例 #5
0
def shape_faces_surface():
    """ Compute the surface of each face of a shape
    """
    # first create the shape
    the_shape = BRepPrimAPI_MakeBox(50., 30., 10.).Shape()
    # then loop over faces
    t = TopologyExplorer(the_shape)
    props = GProp_GProps()
    shp_idx = 1
    for face in t.faces():
        brepgprop_SurfaceProperties(face, props)
        face_surf = props.Mass()
        print("Surface for face nbr %i : %f" % (shp_idx, face_surf))
        shp_idx += 1
コード例 #6
0
def shape_faces_surface():
    """ Compute the surface of each face of a shape
    """
    # first create the shape
    the_shape = BRepPrimAPI_MakeBox(50., 30., 10.).Shape()
    # then loop over faces
    t = Topo(the_shape)
    props = GProp_GProps()
    shp_idx = 1
    for face in t.faces():
        brepgprop_SurfaceProperties(face, props)
        face_surf = props.Mass()
        print("Surface for face nbr %i : %f" % (shp_idx, face_surf))
        shp_idx += 1
コード例 #7
0
def CalculateSurfaceArea(shape):
    """Calculates the surface area of input shape
    Parameters
    ----------
    shape : TopoDS_Shape
    Returns
    -------
    Area : scalar
        Calculated surface area
    """
    from OCC.BRepGProp import brepgprop_SurfaceProperties
    from OCC.GProp import GProp_GProps
    System = GProp_GProps()
    brepgprop_SurfaceProperties(shape, System)
    Area = System.Mass()
    return Area
コード例 #8
0
def CalculateSurfaceArea(shape):
    """Calculates the surface area of input shape

    Parameters
    ----------
    shape : TopoDS_Shape

    Returns
    -------
    Area : scalar
        Calculated surface area
    """
    from OCC.BRepGProp import brepgprop_SurfaceProperties
    from OCC.GProp import GProp_GProps
    System = GProp_GProps()
    brepgprop_SurfaceProperties(shape, System)
    Area = System.Mass()
    return Area
コード例 #9
0
ファイル: Common.py プロジェクト: chenkianwee/envuo
 def surface(self):
     '''returns the area of a surface
     '''
     prop = GProp_GProps()
     brepgprop_SurfaceProperties(self.shape, prop, self.tolerance)
     return prop
コード例 #10
0
ファイル: shapes.py プロジェクト: fragmuffin/cadquery
    def Center(self):

        Properties = GProp_GProps()
        brepgprop_SurfaceProperties(self.wrapped, Properties)

        return Vector(Properties.CentreOfMass())
コード例 #11
0
def getFaceArea(face):
    """ Return the area of the face object given """

    system = GProp_GProps()
    brepgprop_SurfaceProperties(face, system)
    return (system.Mass())
コード例 #12
0
 def surface(self):
     '''returns the area of a surface
     '''
     prop = GProp_GProps()
     brepgprop_SurfaceProperties(self.shape, prop, self.tolerance)
     return prop
コード例 #13
0
def area(shape, tolerance=1e-5):
    prop = GProp_GProps()
    brepgprop_SurfaceProperties(shape, prop, tolerance)
    return prop.Mass()