]> OCCT Git - occt.git/commitdiff
Data Exchange, GLTF - Change export line type to LINE_STRIP #535
authorElias Cohenca <elias@bananaz.ai>
Sat, 17 May 2025 09:00:40 +0000 (12:00 +0300)
committerdpasukhi <dpasukhi@opencascade.com>
Mon, 19 May 2025 21:22:28 +0000 (22:22 +0100)
GLTF exporter mark edges as a LINE, which is 2 connected points.
OCCT polylines is mostly line strip structure.
Updated GLTF reader to handle new type of lines

src/RWGltf/RWGltf_CafWriter.cxx
src/RWGltf/RWGltf_GltfJsonParser.cxx
src/RWGltf/RWGltf_TriangulationReader.cxx

index d64e459dd6141e51d7acd182f2b117187322938c..d2cff43a6689cd541feeebcb0143b2a90ccdd4dc 100644 (file)
@@ -2030,7 +2030,7 @@ void RWGltf_CafWriter::writePrimArray(const RWGltf_GltfFace&         theGltfFace
     switch (theGltfFace.Shape.ShapeType())
     {
       case TopAbs_EDGE:
-        myWriter->Int(RWGltf_GltfPrimitiveMode_Lines);
+        myWriter->Int(RWGltf_GltfPrimitiveMode_LineStrip);
         break;
       case TopAbs_VERTEX:
         myWriter->Int(RWGltf_GltfPrimitiveMode_Points);
index 292cadbd48cda825cbbe9314a7ff70ba246b15c4..803c2c389500df0dc3b5f341174241608c8dc990 100644 (file)
@@ -1783,7 +1783,7 @@ bool RWGltf_GltfJsonParser::gltfParsePrimArray(TopoDS_Shape&                  th
     }
   }
   if (aMode != RWGltf_GltfPrimitiveMode_Triangles && aMode != RWGltf_GltfPrimitiveMode_Lines
-      && aMode != RWGltf_GltfPrimitiveMode_Points)
+      && aMode != RWGltf_GltfPrimitiveMode_LineStrip && aMode != RWGltf_GltfPrimitiveMode_Points)
   {
     Message::SendWarning(TCollection_AsciiString() + "Primitive array within Mesh '" + theMeshId
                          + "' skipped due to unsupported mode");
@@ -1954,7 +1954,8 @@ bool RWGltf_GltfJsonParser::gltfParsePrimArray(TopoDS_Shape&                  th
         aShape = aVertices;
         break;
       }
-      case RWGltf_GltfPrimitiveMode_Lines: {
+      case RWGltf_GltfPrimitiveMode_Lines:
+      case RWGltf_GltfPrimitiveMode_LineStrip: {
         TColgp_Array1OfPnt aNodes(1, aMeshData->NbEdges());
         for (Standard_Integer anEdgeIdx = 1; anEdgeIdx <= aMeshData->NbEdges(); ++anEdgeIdx)
         {
@@ -1989,7 +1990,7 @@ bool RWGltf_GltfJsonParser::gltfParsePrimArray(TopoDS_Shape&                  th
       aShapeAttribs.RawName = theMeshName;
 
       // assign material and not color
-      if (aMode == RWGltf_GltfPrimitiveMode_Lines)
+      if (aMode == RWGltf_GltfPrimitiveMode_Lines || aMode == RWGltf_GltfPrimitiveMode_LineStrip)
       {
         aShapeAttribs.Style.SetColorCurv(aMeshData->BaseColor().GetRGB());
       }
index 445e315b66f7330c2f71594f338eeb3f15bfb387..3a3d4d4254bb1fdf3964e7bb54d2113b8f50d4e7 100644 (file)
@@ -566,6 +566,7 @@ bool RWGltf_TriangulationReader::readBuffer(
   const TCollection_AsciiString& aName     = theSourceMesh->Id();
   const RWGltf_GltfPrimitiveMode aPrimMode = theSourceMesh->PrimitiveMode();
   if (aPrimMode != RWGltf_GltfPrimitiveMode_Triangles && aPrimMode != RWGltf_GltfPrimitiveMode_Lines
+      && aPrimMode != RWGltf_GltfPrimitiveMode_LineStrip
       && aPrimMode != RWGltf_GltfPrimitiveMode_Points)
   {
     Message::SendWarning(TCollection_AsciiString("Buffer '") + aName