11import numpy as np
2+ from abc import ABC , abstractmethod
23
34
4- class BaseRegion :
5- def __init__ (self ):
6- self .type = "BaseRegion"
5+ class BaseRegion (ABC ):
6+ @abstractmethod
7+ def __init__ (self , feature , vector = None , point = None ):
8+ self .feature = feature
9+ self .vector = vector
10+ self .point = point
11+ self .name = None
12+ self .parent = None
13+
14+ @abstractmethod
15+ def __call__ (self , xyz ) -> np .ndarray :
16+ """Evaluate the region based on the input coordinates."""
17+ pass
718
819
920class RegionEverywhere (BaseRegion ):
@@ -24,18 +35,18 @@ def __call__(self, xyz):
2435 return self .function (xyz )
2536
2637
27- class PositiveRegion :
38+ class PositiveRegion ( BaseRegion ) :
2839 """Helper class for evaluating whether you are in the positive region of a scalar field.
2940 If its outside of the support it will interpolate the average gradient at a point on the 0 isovalue
3041 and calculate the distance from this. Alternatively, a point and vector can be used to save computational time
3142 """
3243
3344 def __init__ (self , feature , vector = None , point = None ):
34- self . feature = feature
35- self .vector = vector
36- self .point = point
45+ super (). __init__ ( feature , vector , point )
46+ self .name = 'PositiveRegion'
47+ self .parent = feature
3748
38- def __call__ (self , xyz ):
49+ def __call__ (self , xyz ) -> np . ndarray :
3950 val = self .feature .evaluate_value (xyz )
4051 # find a point on/near 0 isosurface
4152 if self .point is None :
@@ -62,18 +73,18 @@ def __call__(self, xyz):
6273 )
6374
6475
65- class NegativeRegion :
76+ class NegativeRegion ( BaseRegion ) :
6677 """Helper class for evaluating whether you are in the positive region of a scalar field.
6778 If its outside of the support it will interpolate the average gradient at a point on the 0 isovalue
6879 and calculate the distance from this. Alternatively, a point and vector can be used to save computational time
6980 """
7081
7182 def __init__ (self , feature , vector = None , point = None ):
72- self . feature = feature
73- self .vector = vector
74- self .point = point
83+ super (). __init__ ( feature , vector , point )
84+ self .name = 'NegativeRegion'
85+ self .parent = feature
7586
76- def __call__ (self , xyz ):
87+ def __call__ (self , xyz ) -> np . ndarray :
7788 val = self .feature .evaluate_value (xyz )
7889 # find a point on/near 0 isosurface
7990 if self .point is None :
0 commit comments