Added missing Standard_EXPORT and getters.
Fixed metadata loss.
aDoc.SetFilePath (theFile);
aDoc.SetProbeHeader (theToProbe);
aDoc.SetExternalFiles (myExternalFiles);
+ aDoc.SetMetadata (myMetadata);
aDoc.SetErrorPrefix (anErrPrefix);
aDoc.SetCoordinateSystemConverter (myCoordSysConverter);
if (!theToProbe)
}
}
+ 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());
}
}
}
//! 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; }
//! 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; }
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];
//! 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
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;
}
myExtraStatus |= RWMesh_CafReaderStatusEx_Partial;
}
- BRep_Builder aBuilder;
- TopoDS_Shape aShape;
- if (myRootShapes.Size() > 1)
- {
- TopoDS_Compound aCompound;
- aBuilder.MakeCompound (aCompound);
- for (TopTools_SequenceOfShape::Iterator aRootIter (myRootShapes); aRootIter.More(); aRootIter.Next())
- {
- aBuilder.Add (aCompound, aRootIter.Value());
- }
- aShape = aCompound;
- }
- else if (!myRootShapes.IsEmpty())
- {
- aShape = myRootShapes.First();
- }
-
+ TopLoc_Location aDummyLoc;
Standard_Integer aNbNodes = 0, aNbElems = 0, aNbFaces = 0;
- if (!aShape.IsNull())
+ for (TopTools_SequenceOfShape::Iterator aRootIter (myRootShapes); aRootIter.More(); aRootIter.Next())
{
- 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))
return Standard_False;
}
- if (myToFillDoc
- && !myXdeDoc.IsNull())
- {
- const Standard_Boolean wasAutoNaming = aShapeTool->AutoNaming();
- aShapeTool->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);
- }
+ fillDocument();
+ 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[" + 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())
{
- Message::DefaultMessenger()->Send (TCollection_AsciiString ("Mesh ") + theFile
- + "\n" + aStats
- + "\n[PARTIALLY read in " + aLoadingTimer.ElapsedTime() + " s]", Message_Info);
+ return;
}
- else
+
+ 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())
{
- Message::DefaultMessenger()->Send (TCollection_AsciiString ("Mesh ") + theFile
- + "\n" + aStats
- + "\n[read in " + aLoadingTimer.ElapsedTime() + " s]", Message_Info);
+ addShapeIntoDoc (aRootIter.Value(), TDF_Label(), aRootName);
}
- return Standard_True;
+ XCAFDoc_DocumentTool::ShapeTool (myXdeDoc->Main())->UpdateAssemblies();
+ XCAFDoc_ShapeTool::SetAutoNaming (wasAutoNaming);
}
// =======================================================================
//! @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,
- const Handle(Message_ProgressIndicator)& theProgress,
- const Standard_Boolean theToProbe);
+ 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,
- const Handle(Message_ProgressIndicator)& theProgress,
- const Standard_Boolean theToProbe) = 0;
+ 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,