symcad.parts.endcaps

 1#!/usr/bin/env python3
 2# Copyright (C) 2022, Will Hedgecock
 3#
 4# This program is free software: you can redistribute it and/or modify
 5# it under the terms of the GNU General Public License as published by
 6# the Free Software Foundation, either version 3 of the License, or
 7# (at your option) any later version.
 8#
 9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
17from __future__ import annotations
18from ...core.SymPart import SymPart
19from typing import Callable, Union
20from ...core.ML import NeuralNet
21import abc, os
22
23class EndcapShape(SymPart, metaclass=abc.ABCMeta):
24   """Base class from which all endcap shapes should derive."""
25
26   def __init__(self, identifier: str,
27                      cad_representation: Union[str, Callable],
28                      properties_model: Union[str, NeuralNet, None],
29                      material_density_kg_m3: float) -> None:
30      """Initializes a `SymPart` for use as an endcap.
31
32      Parameters
33      ----------
34      identifier : `str`
35         Unique, identifying name for the `EndcapShape`.
36      cad_representation : `Union[str, Callable]`
37         Either the path to a representative CAD model for the given `EndcapShape` or a
38         callable method that can create such a model.
39      properties_model : `Union[str, NeuralNet, None]`
40         Path to or instance of a neural network that may be evaluated to obtain the underlying
41         geometric properties for the given `EndcapShape`.
42      material_density_kg_m3 : `float`
43         Uniform material density in `kg/m^3` to be used in mass property calculations.
44      """
45      super().__init__(identifier,
46                       os.path.join('endcaps', cad_representation)
47                          if isinstance(cad_representation, str) else
48                       cad_representation,
49                       os.path.join('endcaps', properties_model)
50                          if properties_model and isinstance(properties_model, str) else
51                       properties_model,
52                       material_density_kg_m3)
53
54from .ConicalFrustrum import ConicalFrustrum
55from .FlangedFlatPlate import FlangedFlatPlate
56from .Hemisphere import Hemisphere
57from .Semiellipsoid import Semiellipsoid
58from .Torisphere import Torisphere
class EndcapShape(symcad.core.SymPart.SymPart):
24class EndcapShape(SymPart, metaclass=abc.ABCMeta):
25   """Base class from which all endcap shapes should derive."""
26
27   def __init__(self, identifier: str,
28                      cad_representation: Union[str, Callable],
29                      properties_model: Union[str, NeuralNet, None],
30                      material_density_kg_m3: float) -> None:
31      """Initializes a `SymPart` for use as an endcap.
32
33      Parameters
34      ----------
35      identifier : `str`
36         Unique, identifying name for the `EndcapShape`.
37      cad_representation : `Union[str, Callable]`
38         Either the path to a representative CAD model for the given `EndcapShape` or a
39         callable method that can create such a model.
40      properties_model : `Union[str, NeuralNet, None]`
41         Path to or instance of a neural network that may be evaluated to obtain the underlying
42         geometric properties for the given `EndcapShape`.
43      material_density_kg_m3 : `float`
44         Uniform material density in `kg/m^3` to be used in mass property calculations.
45      """
46      super().__init__(identifier,
47                       os.path.join('endcaps', cad_representation)
48                          if isinstance(cad_representation, str) else
49                       cad_representation,
50                       os.path.join('endcaps', properties_model)
51                          if properties_model and isinstance(properties_model, str) else
52                       properties_model,
53                       material_density_kg_m3)

Base class from which all endcap shapes should derive.

EndcapShape( identifier: str, cad_representation: Union[str, Callable], properties_model: Union[str, symcad.core.ML.NeuralNet.NeuralNet, NoneType], material_density_kg_m3: float)
27   def __init__(self, identifier: str,
28                      cad_representation: Union[str, Callable],
29                      properties_model: Union[str, NeuralNet, None],
30                      material_density_kg_m3: float) -> None:
31      """Initializes a `SymPart` for use as an endcap.
32
33      Parameters
34      ----------
35      identifier : `str`
36         Unique, identifying name for the `EndcapShape`.
37      cad_representation : `Union[str, Callable]`
38         Either the path to a representative CAD model for the given `EndcapShape` or a
39         callable method that can create such a model.
40      properties_model : `Union[str, NeuralNet, None]`
41         Path to or instance of a neural network that may be evaluated to obtain the underlying
42         geometric properties for the given `EndcapShape`.
43      material_density_kg_m3 : `float`
44         Uniform material density in `kg/m^3` to be used in mass property calculations.
45      """
46      super().__init__(identifier,
47                       os.path.join('endcaps', cad_representation)
48                          if isinstance(cad_representation, str) else
49                       cad_representation,
50                       os.path.join('endcaps', properties_model)
51                          if properties_model and isinstance(properties_model, str) else
52                       properties_model,
53                       material_density_kg_m3)

Initializes a SymPart for use as an endcap.

Parameters
  • identifier (str): Unique, identifying name for the EndcapShape.
  • cad_representation (Union[str, Callable]): Either the path to a representative CAD model for the given EndcapShape or a callable method that can create such a model.
  • properties_model (Union[str, NeuralNet, None]): Path to or instance of a neural network that may be evaluated to obtain the underlying geometric properties for the given EndcapShape.
  • material_density_kg_m3 (float): Uniform material density in kg/m^3 to be used in mass property calculations.