mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-28 16:10:24 -05:00
Port RimSurfaceCollection, RimPolygonCollection and the polygon-in-view side onto the new caf::PdmNestedCollection framework, replacing the per-class folder plumbing (m_subCollections field, topmost-folder flag, add/remove/find sub-collection, factory, "new folder" command) with the shared base. - RimSurfaceCollection and RimPolygonCollection now derive from caf::PdmNestedCollection. Each constructor uses the generic folder icon and exposes a static createTopmost() that marks the top instance and applies the branded domain icon; RimOilField calls the factory. - RimPolygonInViewCollection uses the new RimNestedMirrorCollectionInView helper, and a new RimPolygonContainer carries the source-side polygon link. - RicNewSurfaceCollectionFeature is removed; the generic RicNewNestedCollectionFeature drives the "Add Folder" action against both collections. - Update callers (RimAnnotationCollection, RimEnsembleSurface, polygon command features) and the scripting wrapper (RimcSurfaceCollection), plus the Python add-folder binding and polygon test.
68 lines
2.3 KiB
Python
68 lines
2.3 KiB
Python
import sys
|
|
import os
|
|
import math
|
|
|
|
sys.path.insert(1, os.path.join(sys.path[0], "../../"))
|
|
import rips
|
|
|
|
import dataroot
|
|
|
|
|
|
def test_create_polygon(rips_instance, initialize_test):
|
|
project = rips_instance.project.open(
|
|
dataroot.PATH + "/TEST10K_FLT_LGR_NNC/10KWithWellLog.rsp"
|
|
)
|
|
|
|
c = project.cases()[0]
|
|
bbox = c.reservoir_boundingbox()
|
|
|
|
polygon_collection = rips_instance.project.descendants(rips.PolygonCollection)[0]
|
|
|
|
coordinates = []
|
|
coordinates.append([bbox.min_x, bbox.min_y, -1000.0])
|
|
coordinates.append([bbox.max_x, bbox.min_y, -1000.0])
|
|
coordinates.append([bbox.max_x, bbox.max_y, -1500.0])
|
|
coordinates.append([bbox.min_x, bbox.max_y, -1500.0])
|
|
|
|
name = "{} bounding box".format(c.name)
|
|
p = polygon_collection.create_polygon(name=name, coordinates=coordinates)
|
|
assert p.name == name
|
|
assert len(coordinates) == len(p.coordinates)
|
|
for expected, actual in zip(coordinates, p.coordinates):
|
|
assert len(expected) == len(actual)
|
|
for e, a in zip(expected, actual):
|
|
assert math.isclose(e, a, rel_tol=1e-9, abs_tol=0.0)
|
|
|
|
|
|
def test_add_folders_and_polygons(rips_instance, initialize_test):
|
|
rips_instance.project.open(
|
|
dataroot.PATH + "/TEST10K_FLT_LGR_NNC/10KWithWellLog.rsp"
|
|
)
|
|
|
|
root = rips_instance.project.descendants(rips.PolygonCollection)[0]
|
|
|
|
folder_a = root.add_folder(folder_name="Folder A")
|
|
folder_b = root.add_folder(folder_name="Folder B")
|
|
nested = folder_a.add_folder(folder_name="Nested")
|
|
|
|
sub_names = [s.polygon_collection_name for s in root.sub_collections()]
|
|
assert "Folder A" in sub_names
|
|
assert "Folder B" in sub_names
|
|
assert [s.polygon_collection_name for s in folder_a.sub_collections()] == ["Nested"]
|
|
|
|
coordinates = [
|
|
[0.0, 0.0, -1000.0],
|
|
[100.0, 0.0, -1000.0],
|
|
[100.0, 100.0, -1000.0],
|
|
[0.0, 100.0, -1000.0],
|
|
]
|
|
|
|
root.create_polygon(name="root poly", coordinates=coordinates)
|
|
folder_a.create_polygon(name="A poly", coordinates=coordinates)
|
|
nested.create_polygon(name="nested poly", coordinates=coordinates)
|
|
|
|
assert [p.name for p in root.polygons()] == ["root poly"]
|
|
assert [p.name for p in folder_a.polygons()] == ["A poly"]
|
|
assert [p.name for p in folder_b.polygons()] == []
|
|
assert [p.name for p in nested.polygons()] == ["nested poly"]
|