|
1 | 1 | from LoopStructural.utils import getLogger |
2 | 2 | from LoopStructural.utils import LoopImportError |
3 | | -from LoopStructural.modelling.features import FeatureType |
4 | 3 |
|
5 | 4 | logger = getLogger(__name__) |
6 | 5 |
|
|
18 | 17 | FeatureType, |
19 | 18 | GeologicalFeature, |
20 | 19 | BaseFeature, |
| 20 | + StructuralFrame, |
21 | 21 | ) |
22 | 22 | from LoopStructural.utils.helper import create_surface, get_vectors, create_box |
23 | 23 |
|
@@ -812,79 +812,87 @@ def add_data(self, feature, disks=False, vectors=False, **kwargs): |
812 | 812 | add_tang = kwargs["tang"] |
813 | 813 | if "interface" in kwargs: |
814 | 814 | add_interface = kwargs["interface"] |
815 | | - grad = feature.builder.get_gradient_constraints() |
816 | | - norm = feature.builder.get_norm_constraints() |
817 | | - value = feature.builder.get_value_constraints() |
818 | | - tang = feature.builder.get_tangent_constraints() |
819 | | - interface = feature.builder.get_interface_constraints() |
820 | | - symbol_type = self.default_vector_symbol |
821 | | - if disks: |
822 | | - symbol_type = "disk" |
823 | | - if vectors: |
824 | | - symbol_type = "arrow" |
825 | | - if vectors and disks: |
826 | | - logger.warning("Cannot use both disks and arrows, using disks") |
827 | | - symbol_type = "disk" |
828 | | - if grad.shape[0] > 0 and add_grad: |
829 | | - self.add_vector_data( |
830 | | - self.model.rescale(grad[:, :3], inplace=False), |
831 | | - grad[:, 3:6], |
832 | | - name + "_grad_cp", |
833 | | - symbol_type=symbol_type, |
834 | | - **kwargs, |
835 | | - ) |
| 815 | + if isinstance(feature, StructuralFrame): |
| 816 | + features = feature.features |
| 817 | + else: |
| 818 | + features = [feature] |
| 819 | + for feature in features: |
| 820 | + |
| 821 | + grad = feature.builder.get_gradient_constraints() |
| 822 | + norm = feature.builder.get_norm_constraints() |
| 823 | + value = feature.builder.get_value_constraints() |
| 824 | + tang = feature.builder.get_tangent_constraints() |
| 825 | + interface = feature.builder.get_interface_constraints() |
| 826 | + symbol_type = self.default_vector_symbol |
| 827 | + if disks: |
| 828 | + symbol_type = "disk" |
| 829 | + if vectors: |
| 830 | + symbol_type = "arrow" |
| 831 | + if vectors and disks: |
| 832 | + logger.warning("Cannot use both disks and arrows, using disks") |
| 833 | + symbol_type = "disk" |
| 834 | + if grad.shape[0] > 0 and add_grad: |
| 835 | + self.add_vector_data( |
| 836 | + self.model.rescale(grad[:, :3], inplace=False), |
| 837 | + grad[:, 3:6], |
| 838 | + name + "_grad_cp", |
| 839 | + symbol_type=symbol_type, |
| 840 | + **kwargs, |
| 841 | + ) |
836 | 842 |
|
837 | | - if norm.shape[0] > 0 and add_grad: |
838 | | - self.add_vector_data( |
839 | | - self.model.rescale(norm[:, :3], inplace=False), |
840 | | - norm[:, 3:6], |
841 | | - name + "_norm_cp", |
842 | | - symbol_type=symbol_type, |
843 | | - **kwargs, |
844 | | - ) |
845 | | - if value.shape[0] > 0 and add_value: |
846 | | - kwargs["range"] = [feature.min(), feature.max()] |
847 | | - self.add_value_data( |
848 | | - self.model.rescale(value[:, :3], inplace=False), |
849 | | - value[:, 3], |
850 | | - name + "_value_cp", |
851 | | - **kwargs, |
852 | | - ) |
853 | | - if tang.shape[0] > 0 and add_tang: |
854 | | - self.add_vector_data( |
855 | | - self.model.rescale(tang[:, :3], inplace=False), |
856 | | - tang[:, 3:6], |
857 | | - name + "_tang_cp", |
858 | | - **kwargs, |
859 | | - ) |
860 | | - if interface.shape[0] > 0 and add_interface: |
861 | | - self.add_points( |
862 | | - self.model.rescale(interface[:, :3], inplace=False), |
863 | | - name + "_interface_cp", |
864 | | - ) |
| 843 | + if norm.shape[0] > 0 and add_grad: |
| 844 | + self.add_vector_data( |
| 845 | + self.model.rescale(norm[:, :3], inplace=False), |
| 846 | + norm[:, 3:6], |
| 847 | + name + "_norm_cp", |
| 848 | + symbol_type=symbol_type, |
| 849 | + **kwargs, |
| 850 | + ) |
| 851 | + if value.shape[0] > 0 and add_value: |
| 852 | + kwargs["range"] = [feature.min(), feature.max()] |
| 853 | + self.add_value_data( |
| 854 | + self.model.rescale(value[:, :3], inplace=False), |
| 855 | + value[:, 3], |
| 856 | + name + "_value_cp", |
| 857 | + **kwargs, |
| 858 | + ) |
| 859 | + if tang.shape[0] > 0 and add_tang: |
| 860 | + self.add_vector_data( |
| 861 | + self.model.rescale(tang[:, :3], inplace=False), |
| 862 | + tang[:, 3:6], |
| 863 | + name + "_tang_cp", |
| 864 | + **kwargs, |
| 865 | + ) |
| 866 | + if interface.shape[0] > 0 and add_interface: |
| 867 | + self.add_points( |
| 868 | + self.model.rescale(interface[:, :3], inplace=False), |
| 869 | + name + "_interface_cp", |
| 870 | + ) |
865 | 871 |
|
866 | | - def add_intersection_lineation(self, feature, **kwargs): |
867 | | - name = feature.name |
868 | | - if "name" in kwargs: |
869 | | - name = kwargs["name"] |
870 | | - del kwargs["name"] |
871 | | - intersection = feature.builder.fold.foldframe.calculate_intersection_lineation( |
872 | | - feature.builder |
873 | | - ) |
874 | | - gpoints = feature.builder.interpolator.get_gradient_constraints()[:, :6] |
875 | | - npoints = feature.builder.interpolator.get_norm_constraints()[:, :6] |
876 | | - points = [] |
877 | | - if gpoints.shape[0] > 0: |
878 | | - points.append(gpoints) |
879 | | - if npoints.shape[0] > 0: |
880 | | - points.append(npoints) |
881 | | - points = np.vstack(points) |
882 | | - if intersection.shape[0] > 0: |
883 | | - self.add_vector_data( |
884 | | - self.model.rescale(points[:, :3], inplace=False), |
885 | | - intersection, |
886 | | - name + "_intersection", |
| 872 | + def add_intersection_lineation(self, feature, **kwargs): |
| 873 | + name = feature.name |
| 874 | + if "name" in kwargs: |
| 875 | + name = kwargs["name"] |
| 876 | + del kwargs["name"] |
| 877 | + intersection = ( |
| 878 | + feature.builder.fold.foldframe.calculate_intersection_lineation( |
| 879 | + feature.builder |
| 880 | + ) |
887 | 881 | ) |
| 882 | + gpoints = feature.builder.interpolator.get_gradient_constraints()[:, :6] |
| 883 | + npoints = feature.builder.interpolator.get_norm_constraints()[:, :6] |
| 884 | + points = [] |
| 885 | + if gpoints.shape[0] > 0: |
| 886 | + points.append(gpoints) |
| 887 | + if npoints.shape[0] > 0: |
| 888 | + points.append(npoints) |
| 889 | + points = np.vstack(points) |
| 890 | + if intersection.shape[0] > 0: |
| 891 | + self.add_vector_data( |
| 892 | + self.model.rescale(points[:, :3], inplace=False), |
| 893 | + intersection, |
| 894 | + name + "_intersection", |
| 895 | + ) |
888 | 896 |
|
889 | 897 | def add_points(self, points, name, **kwargs): |
890 | 898 | """ |
|
0 commit comments