MCPcopy Create free account
hub / github.com/IfcOpenShell/IfcOpenShell / VisualizationInfoHandler

Class VisualizationInfoHandler

src/bcf/bcf/v2/visinfo.py:21–304  ·  view source on GitHub ↗

Handle the VisualizationInfo and related objects.

Source from the content-addressed store, hash-verified

19
20
21class VisualizationInfoHandler:
22 """Handle the VisualizationInfo and related objects."""
23
24 def __init__(
25 self,
26 visualization_info: mdl.VisualizationInfo,
27 snapshot: Optional[bytes] = None,
28 bitmaps: Optional[dict[str, bytes]] = None,
29 xml_handler: Optional[AbstractXmlParserSerializer] = None,
30 ) -> None:
31 self.visualization_info = visualization_info
32 self.snapshot = snapshot
33 self.bitmaps = bitmaps or {}
34 self._xml_handler = xml_handler or XmlParserSerializer()
35
36 @property
37 def guid(self) -> str:
38 """Return the GUID of the visualization info."""
39 return self.visualization_info.guid
40
41 @classmethod
42 def from_topic_viewpoints(
43 cls,
44 topic_dir: zipfile.Path,
45 vps: Iterable[mdl.ViewPoint],
46 xml_handler: Optional[AbstractXmlParserSerializer] = None,
47 ) -> dict[str, "VisualizationInfoHandler"]:
48 """Create VisualizationInfoHandler objects of a Topic's ViewPoints."""
49 viewpoints = {}
50 for vpt in vps:
51 visinfo = cls.load(topic_dir, vpt, xml_handler)
52 if visinfo and vpt.viewpoint:
53 viewpoints[vpt.viewpoint] = visinfo
54 return viewpoints
55
56 @classmethod
57 def load(
58 cls,
59 topic_dir: zipfile.Path,
60 vpt: mdl.ViewPoint,
61 xml_handler: Optional[AbstractXmlParserSerializer] = None,
62 ) -> Optional["VisualizationInfoHandler"]:
63 """
64 Load the VisualizationInfo and related objects from a BCF zip file.
65
66 Args:
67 topic_dir: The directory in the BCF zip file to load from.
68 vpt: The ViewPoint to load.
69 xml_handler: The XML handler to use to parse the VisualizationInfo.
70
71 Returns:
72 The VisualizationInfoHandler object.
73 """
74 visinfo = cls._load_visinfo(topic_dir, vpt.viewpoint, xml_handler)
75 if not visinfo:
76 return None
77 snapshot = cls._load_snapshot(topic_dir, vpt.snapshot)
78 bitmaps = cls._load_bitmaps(topic_dir, visinfo)

Callers 2

test_massive_bcfFunction · 0.90
test_massive_bcfFunction · 0.90

Calls

no outgoing calls

Tested by 2

test_massive_bcfFunction · 0.72
test_massive_bcfFunction · 0.72