mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-05 18:16:23 +03:00
0030811: Data Exchange, RWGltf_CafReader - fix inaccessibility of properties
Added missing Standard_EXPORT and getters. Fixed metadata loss.
This commit is contained in:
parent
d9dd07545d
commit
82c59511b4
@ -215,6 +215,7 @@ Standard_Boolean RWGltf_CafReader::performMesh (const TCollection_AsciiString& t
|
||||
aDoc.SetFilePath (theFile);
|
||||
aDoc.SetProbeHeader (theToProbe);
|
||||
aDoc.SetExternalFiles (myExternalFiles);
|
||||
aDoc.SetMetadata (myMetadata);
|
||||
aDoc.SetErrorPrefix (anErrPrefix);
|
||||
aDoc.SetCoordinateSystemConverter (myCoordSysConverter);
|
||||
if (!theToProbe)
|
||||
|
@ -250,18 +250,23 @@ void RWGltf_GltfJsonParser::gltfParseAsset()
|
||||
}
|
||||
}
|
||||
|
||||
if (myMetadata == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (const RWGltf_JsonValue* aGenerator = findObjectMember (*anAsset, "generator"))
|
||||
{
|
||||
if (aGenerator->IsString())
|
||||
{
|
||||
myMetadata.Add ("generator", aGenerator->GetString());
|
||||
myMetadata->Add ("generator", aGenerator->GetString());
|
||||
}
|
||||
}
|
||||
if (const RWGltf_JsonValue* aCopyRight = findObjectMember (*anAsset, "copyright"))
|
||||
{
|
||||
if (aCopyRight->IsString())
|
||||
{
|
||||
myMetadata.Add ("copyright", aCopyRight->GetString());
|
||||
myMetadata->Add ("copyright", aCopyRight->GetString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -87,6 +87,9 @@ public:
|
||||
//! Set list for storing external files.
|
||||
void SetExternalFiles (NCollection_IndexedMap<TCollection_AsciiString>& theExternalFiles) { myExternalFiles = &theExternalFiles; }
|
||||
|
||||
//! Set metadata map.
|
||||
void SetMetadata (TColStd_IndexedDataMapOfStringString& theMetadata) { myMetadata = &theMetadata; }
|
||||
|
||||
//! Return transformation from glTF to OCCT coordinate system.
|
||||
const RWMesh_CoordinateSystemConverter& CoordinateSystemConverter() const { return myCSTrsf; }
|
||||
|
||||
@ -105,9 +108,6 @@ public:
|
||||
//! Parse glTF document.
|
||||
Standard_EXPORT bool Parse (const Handle(Message_ProgressIndicator)& theProgress);
|
||||
|
||||
//! Return metadata map.
|
||||
const TColStd_IndexedDataMapOfStringString& Metadata() const { return myMetadata; }
|
||||
|
||||
//! Return face list for loading triangulation.
|
||||
NCollection_Vector<TopoDS_Face>& FaceList() { return myFaceList; }
|
||||
|
||||
@ -387,8 +387,8 @@ protected:
|
||||
NCollection_IndexedMap<TCollection_AsciiString>*
|
||||
myExternalFiles; //!< list of external file references
|
||||
RWMesh_CoordinateSystemConverter myCSTrsf; //!< transformation from glTF to OCCT coordinate system
|
||||
TColStd_IndexedDataMapOfStringString* myMetadata; //!< file metadata
|
||||
|
||||
TColStd_IndexedDataMapOfStringString myMetadata; //!< file metadata
|
||||
NCollection_DataMap<TCollection_AsciiString, Handle(RWGltf_MaterialMetallicRoughness)> myMaterialsPbr;
|
||||
NCollection_DataMap<TCollection_AsciiString, Handle(RWGltf_MaterialCommon)> myMaterialsCommon;
|
||||
NCollection_DataMap<TCollection_AsciiString, TopoDS_Shape> myShapeMap[2];
|
||||
|
@ -79,12 +79,15 @@ public:
|
||||
//! Add primitive array data element.
|
||||
Standard_EXPORT RWGltf_GltfPrimArrayData& AddPrimArrayData (RWGltf_GltfArrayType theType);
|
||||
|
||||
//! Return bounding box defined within glTF file, or VOID if not specified.
|
||||
const Bnd_Box& BoundingBox() const { return myBox; }
|
||||
|
||||
//! This method sets input bounding box and assigns a FAKE data to underlying Poly_Triangulation
|
||||
//! as Min/Max corners of bounding box, so that standard tools like BRepBndLib::Add()
|
||||
//! can be used transparently for computing bounding box of this face.
|
||||
Standard_EXPORT void SetBoundingBox (const Bnd_Box& theBox);
|
||||
|
||||
private:
|
||||
protected:
|
||||
|
||||
NCollection_Sequence<RWGltf_GltfPrimArrayData> myData;
|
||||
Handle(RWGltf_MaterialMetallicRoughness) myMaterialPbr; //!< PBR material
|
||||
|
@ -90,13 +90,10 @@ Standard_Boolean RWMesh_CafReader::perform (const TCollection_AsciiString& theFi
|
||||
const Standard_Boolean theToProbe)
|
||||
{
|
||||
Standard_Integer aNewRootsLower = 1;
|
||||
Handle(XCAFDoc_ShapeTool) aShapeTool = !myXdeDoc.IsNull()
|
||||
? XCAFDoc_DocumentTool::ShapeTool (myXdeDoc->Main())
|
||||
: Handle(XCAFDoc_ShapeTool)();
|
||||
if (!myXdeDoc.IsNull())
|
||||
{
|
||||
TDF_LabelSequence aRootLabels;
|
||||
aShapeTool->GetFreeShapes (aRootLabels);
|
||||
XCAFDoc_DocumentTool::ShapeTool (myXdeDoc->Main())->GetFreeShapes (aRootLabels);
|
||||
aNewRootsLower = aRootLabels.Upper() + 1;
|
||||
}
|
||||
|
||||
@ -118,28 +115,11 @@ Standard_Boolean RWMesh_CafReader::perform (const TCollection_AsciiString& theFi
|
||||
myExtraStatus |= RWMesh_CafReaderStatusEx_Partial;
|
||||
}
|
||||
|
||||
BRep_Builder aBuilder;
|
||||
TopoDS_Shape aShape;
|
||||
if (myRootShapes.Size() > 1)
|
||||
{
|
||||
TopoDS_Compound aCompound;
|
||||
aBuilder.MakeCompound (aCompound);
|
||||
TopLoc_Location aDummyLoc;
|
||||
Standard_Integer aNbNodes = 0, aNbElems = 0, aNbFaces = 0;
|
||||
for (TopTools_SequenceOfShape::Iterator aRootIter (myRootShapes); aRootIter.More(); aRootIter.Next())
|
||||
{
|
||||
aBuilder.Add (aCompound, aRootIter.Value());
|
||||
}
|
||||
aShape = aCompound;
|
||||
}
|
||||
else if (!myRootShapes.IsEmpty())
|
||||
{
|
||||
aShape = myRootShapes.First();
|
||||
}
|
||||
|
||||
Standard_Integer aNbNodes = 0, aNbElems = 0, aNbFaces = 0;
|
||||
if (!aShape.IsNull())
|
||||
{
|
||||
TopLoc_Location aDummyLoc;
|
||||
for (TopExp_Explorer aFaceIter (aShape, TopAbs_FACE); aFaceIter.More(); aFaceIter.Next())
|
||||
for (TopExp_Explorer aFaceIter (aRootIter.Value(), TopAbs_FACE); aFaceIter.More(); aFaceIter.Next())
|
||||
{
|
||||
const TopoDS_Face& aFace = TopoDS::Face (aFaceIter.Current());
|
||||
if (const Handle(Poly_Triangulation)& aPolyTri = BRep_Tool::Triangulation (aFace, aDummyLoc))
|
||||
@ -155,40 +135,39 @@ Standard_Boolean RWMesh_CafReader::perform (const TCollection_AsciiString& theFi
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
if (myToFillDoc
|
||||
&& !myXdeDoc.IsNull())
|
||||
fillDocument();
|
||||
generateNames (theFile, aNewRootsLower, Standard_False);
|
||||
|
||||
aLoadingTimer.Stop();
|
||||
|
||||
Message::DefaultMessenger()->Send (TCollection_AsciiString ("Mesh ") + theFile
|
||||
+ "\n[" + aNbNodes + " nodes] [" + aNbElems + " 2d elements]"
|
||||
+ "\n[" + (!isDone ? "PARTIALLY " : "") + "read in " + aLoadingTimer.ElapsedTime() + " s]", Message_Info);
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : fillDocument
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void RWMesh_CafReader::fillDocument()
|
||||
{
|
||||
if (!myToFillDoc
|
||||
|| myXdeDoc.IsNull()
|
||||
|| myRootShapes.IsEmpty())
|
||||
{
|
||||
const Standard_Boolean wasAutoNaming = aShapeTool->AutoNaming();
|
||||
aShapeTool->SetAutoNaming (Standard_False);
|
||||
return;
|
||||
}
|
||||
|
||||
const Standard_Boolean wasAutoNaming = XCAFDoc_ShapeTool::AutoNaming();
|
||||
XCAFDoc_ShapeTool::SetAutoNaming (Standard_False);
|
||||
const TCollection_AsciiString aRootName; // = generateRootName (theFile);
|
||||
for (TopTools_SequenceOfShape::Iterator aRootIter (myRootShapes); aRootIter.More(); aRootIter.Next())
|
||||
{
|
||||
addShapeIntoDoc (aRootIter.Value(), TDF_Label(), aRootName);
|
||||
}
|
||||
aShapeTool->UpdateAssemblies();
|
||||
aShapeTool->SetAutoNaming (wasAutoNaming);
|
||||
}
|
||||
if (!myXdeDoc.IsNull())
|
||||
{
|
||||
generateNames (theFile, aNewRootsLower, Standard_False);
|
||||
}
|
||||
|
||||
aLoadingTimer.Stop();
|
||||
|
||||
TCollection_AsciiString aStats = TCollection_AsciiString("[") + aNbNodes + " nodes] [" + aNbElems + " 2d elements]";
|
||||
if (!isDone)
|
||||
{
|
||||
Message::DefaultMessenger()->Send (TCollection_AsciiString ("Mesh ") + theFile
|
||||
+ "\n" + aStats
|
||||
+ "\n[PARTIALLY read in " + aLoadingTimer.ElapsedTime() + " s]", Message_Info);
|
||||
}
|
||||
else
|
||||
{
|
||||
Message::DefaultMessenger()->Send (TCollection_AsciiString ("Mesh ") + theFile
|
||||
+ "\n" + aStats
|
||||
+ "\n[read in " + aLoadingTimer.ElapsedTime() + " s]", Message_Info);
|
||||
}
|
||||
return Standard_True;
|
||||
XCAFDoc_DocumentTool::ShapeTool (myXdeDoc->Main())->UpdateAssemblies();
|
||||
XCAFDoc_ShapeTool::SetAutoNaming (wasAutoNaming);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
|
@ -173,18 +173,21 @@ protected:
|
||||
//! @param theFile file to read
|
||||
//! @param optional progress indicator
|
||||
//! @param theToProbe flag indicating that mesh data should be skipped and only basing information to be read
|
||||
virtual Standard_Boolean perform (const TCollection_AsciiString& theFile,
|
||||
Standard_EXPORT virtual Standard_Boolean perform (const TCollection_AsciiString& theFile,
|
||||
const Handle(Message_ProgressIndicator)& theProgress,
|
||||
const Standard_Boolean theToProbe);
|
||||
|
||||
//! Read the mesh from specified file - interface to be implemented by sub-classes.
|
||||
virtual Standard_Boolean performMesh (const TCollection_AsciiString& theFile,
|
||||
Standard_EXPORT virtual Standard_Boolean performMesh (const TCollection_AsciiString& theFile,
|
||||
const Handle(Message_ProgressIndicator)& theProgress,
|
||||
const Standard_Boolean theToProbe) = 0;
|
||||
|
||||
//! @name tools for filling XDE document
|
||||
protected:
|
||||
|
||||
//! Fill document with new root shapes.
|
||||
Standard_EXPORT void fillDocument();
|
||||
|
||||
//! Append new shape into the document (recursively).
|
||||
Standard_EXPORT Standard_Boolean addShapeIntoDoc (const TopoDS_Shape& theShape,
|
||||
const TDF_Label& theLabel,
|
||||
|
Loading…
x
Reference in New Issue
Block a user