Working with TDocStd_Document: Empty document when trying to use TDocStd_Application::Open wrapped by OCP
まだ誰も着手していません。
評価
調査の方向性
Issueで説明されているTDocStd_Application::Open呼び出し、open_ocaf_fileバインディング、およびその後のapp.Close(doc)の失敗から始めてください。BytesIO入力と返されたステータスがどのように処理されるかを確認し、その後、開いたドキュメントがGetFreeShapesを通じてフリーシェイプを公開し、正常に閉じられることを検証してください。
索引モデルが issue の本文から書いたものです。
説明
I'm trying to read/open an XDE/OCAF XML file. I've tried already different ways of doing it. First, I've tried to read from the disk a .xml file, using:
TDocStd_Application::Open
and in my last attempt I've tried to read from an io.BytesIO() that comes from my C++ code also using TDocStd_Application::Open.
Bellow my code:
def read_ocaf_file():
output_stream = io.BytesIO()
# Save the document contents to the provided output stream
success = open_ocaf_file(output_stream) # C++ binded fuction that returns a stream containing the data of the TDocStd_Document
if success:
# prepare a doc
app = XCAFApp_Application.GetApplication_s()
doc = TDocStd_Document(TCollection_ExtendedString("XmlXCAF"))
app.InitDocument(doc)
#app = XCAFApp_Application.GetApplication_s()
tool = XCAFDoc_DocumentTool.ShapeTool_s(doc.Main())
tool.SetAutoNaming_s(False)
ctool = XCAFDoc_DocumentTool.ColorTool_s(doc.Main())
store = XmlXCAFDrivers_DocumentStorageDriver(
TCollection_ExtendedString("Copyright: Open Cascade, 2001-2002")
)
ret = XmlXCAFDrivers_DocumentRetrievalDriver()
app.DefineFormat(
TCollection_AsciiString("XmlXCAF"),
TCollection_AsciiString("Xml XCAF Document"),
TCollection_AsciiString("xml"),
ret,
store,
)
#doc.UnsetIsReadOnly()
status = app.Open(io.BytesIO(output_stream.getvalue()), doc)
assert status == PCDM_StoreStatus.PCDM_SS_OK
else:
print("Failed to save the document.")
labels = TDF_LabelSequence()
tool.GetFreeShapes(labels)
shapes = []
for i in range(1, labels.Length() + 1):
label = labels.Value(i)
shape = self.shape_tool.GetShape_s(label)
shapes.append(shape)
app.Close(doc)
Although, at the end the app.Open returns PCDM_StoreStatus.PCDM_SS_OK when I try to get data from the doc is like it's empty, If I try to do for example: app.Close(doc), I get this following error:
app.Close(doc)
OCP.Standard.Standard_Failure: cannot close a document that has not been opened
Does anyone have experience on working with OCAF/XDE files and has experienced similar difficulties with TDocStd_Document?
Any insights or examples on this matter would be highly appreciated!
Thank you very much for the attention
- 主要言語
- C++
- スター
- 203
- フォーク
- 50
- 平均マージ
- 3日 4時間
- マージ済み PR(30日)
- 1
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
CadQuery/OCP のほかの issue
-
Generation steps fails when OPENGL_INCLUDE_DIRS is a list対応中かも @adam-urbanczyk が 67 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 68/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 58/100
-
Python 3.14t buildオープン
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
-
OCCT8
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
似ている issue
-
new contributor
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
OpenMS/OpenMS#10512 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
mesonbuild/wrapdb#2961 ·
メンテナーはふだん 1 日以内に返信
-
80 Instance - Raid - Northrend
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
azerothcore/azerothcore-wotlk#28075 ·
メンテナーはふだん 1 日以内に返信
-
SCA cis_ubuntu24-04 35664 / cis_ubuntu26-04 41664 "Ensure sudo log file exists": sudoers.d rule is missing the r: prefix, so it can never match対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
MrNeRF/LichtFeld-Studio#3205 ·
メンテナーはふだん 1 日以内に返信