]> OCCT Git - occt.git/commitdiff
0033055: Data Exchange, RWPly_Provider - remove dependency from BRepLib_PointCloudShape
authoratychini <atychini@opencascade.com>
Mon, 11 Jul 2022 13:07:23 +0000 (16:07 +0300)
committeratychini <atychini@opencascade.com>
Mon, 18 Jul 2022 04:32:54 +0000 (07:32 +0300)
Removing PointCloud writing feature from the RWPly_Provider class.
Getting rid of Pointcloud-related parameters in the RWPly_ConfigurationNode.

src/RWPly/RWPly_ConfigurationNode.cxx
src/RWPly/RWPly_ConfigurationNode.hxx
src/RWPly/RWPly_Provider.cxx
src/TKRWMesh/EXTERNLIB
tests/de_wrapper/configuration/A3

index 6e0c7719fcc1e687cbddf33661fc8715ca53dca0..ecd16f4bbbfba625dc17f3052d18eb01cbf5b8c4 100644 (file)
@@ -56,14 +56,6 @@ bool RWPly_ConfigurationNode::Load(const Handle(DE_ConfigurationContext)& theRes
   InternalParameters.FileCS = 
     (RWMesh_CoordinateSystem)(theResource->IntegerVal("file.cs", (int)InternalParameters.SystemCS, aScope) % 2);
 
-  InternalParameters.WritePntSet = 
-    theResource->BooleanVal("write.pnt.set", InternalParameters.WritePntSet, aScope);
-  InternalParameters.WriteDistance =
-    theResource->RealVal("write.distance", InternalParameters.WriteDistance, aScope);
-  InternalParameters.WriteDensity =
-    theResource->RealVal("write.density", InternalParameters.WriteDensity, aScope);
-  InternalParameters.WriteTolerance =
-    theResource->RealVal("write.tolerance", InternalParameters.WriteTolerance, aScope);
   InternalParameters.WriteNormals =
     theResource->BooleanVal("write.normals", InternalParameters.WriteNormals, aScope);
   InternalParameters.WriteColors =
@@ -118,30 +110,6 @@ TCollection_AsciiString RWPly_ConfigurationNode::Save() const
   aResult += "!Write parameters:\n";
   aResult += "!\n";
 
-  aResult += "!\n";
-  aResult += "!Flag for write point cloud instead without triangulation indices\n";
-  aResult += "!Default value: 0(false). Available values: 0(false), 1(true)\n";
-  aResult += aScope + "write.pnt.set :\t " + InternalParameters.WritePntSet + "\n";
-  aResult += "!\n";
-
-  aResult += "!\n";
-  aResult += "!Distance from shape into the range [0, Value]\n";
-  aResult += "!Default value: 0. Available values: [0, Value]\n";
-  aResult += aScope + "write.distance :\t " + InternalParameters.WriteDistance + "\n";
-  aResult += "!\n";
-
-  aResult += "!\n";
-  aResult += "!Density of points to generate randomly on surface\n";
-  aResult += "!Default value: 2.e+100. Available values: [0, inf]\n";
-  aResult += aScope + "write.density :\t " + InternalParameters.WriteDensity + "\n";
-  aResult += "!\n";
-
-  aResult += "!\n";
-  aResult += "!Internal tolerance\n";
-  aResult += "!Default value: 1.e-7. Available values: [0, inf]\n";
-  aResult += aScope + "write.tolerance :\t " + InternalParameters.WriteTolerance + "\n";
-  aResult += "!\n";
-
   aResult += "!\n";
   aResult += "!Flag for write normals\n";
   aResult += "!Default value: 1(true). Available values: 0(false), 1(true)\n";
index 0b4e122b71632c2e0713c2e6ee04cd614d2036cc..93ac598d8eb6d44f0f67fdbe2b572a95924e8f5c 100644 (file)
@@ -94,10 +94,6 @@ public:
     RWMesh_CoordinateSystem SystemCS = RWMesh_CoordinateSystem_Zup; //!< System origin coordinate system to perform conversion into during read
     RWMesh_CoordinateSystem FileCS = RWMesh_CoordinateSystem_Yup; //!< File origin coordinate system to perform conversion during read
     // Writing
-    bool WritePntSet = false; //!< Flag for write point cloud instead without triangulation indices
-    double WriteDistance = 0.0; //!< Distance from shape into the range [0, Value]
-    double WriteDensity = Precision::Infinite(); //!< Density of points to generate randomly on surface
-    double WriteTolerance = Precision::Confusion(); //!< Internal tolerance
     bool WriteNormals = true; //!< Flag for write normals
     bool WriteColors = true; //!< Flag for write colors
     bool WriteTexCoords = false; //!< Flag for write UV / texture coordinates
index c13f9571be85cc381ebb3a79e4aa68e73b02685c..1f81de5bbc3f25604bb80f89f0fc9d81e747074f 100644 (file)
@@ -14,7 +14,6 @@
 #include <RWPly_Provider.hxx>
 
 #include <BRep_Builder.hxx>
-#include <BRepLib_PointCloudShape.hxx>
 #include <DE_Wrapper.hxx>
 #include <Message.hxx>
 #include <RWPly_ConfigurationNode.hxx>
@@ -80,122 +79,34 @@ bool RWPly_Provider::Write(const TCollection_AsciiString& thePath,
     return Standard_True;
   }
 
-  if (aNode->InternalParameters.WritePntSet)
+  TColStd_IndexedDataMapOfStringString aFileInfo;
+  if (!aNode->InternalParameters.WriteAuthor.IsEmpty())
   {
-    class PointCloudPlyWriter : public BRepLib_PointCloudShape, public RWPly_PlyWriterContext
-    {
-    public:
-      PointCloudPlyWriter(Standard_Real theTol)
-        : BRepLib_PointCloudShape(TopoDS_Shape(), theTol)
-      {}
-
-      void AddFaceColor(const TopoDS_Shape& theFace, const Graphic3d_Vec4ub& theColor)
-      {
-        myFaceColor.Bind(theFace, theColor);
-      }
-
-    protected:
-      virtual void addPoint(const gp_Pnt& thePoint,
-                            const gp_Vec& theNorm,
-                            const gp_Pnt2d& theUV,
-                            const TopoDS_Shape& theFace)
-      {
-        Graphic3d_Vec4ub aColor;
-        myFaceColor.Find(theFace, aColor);
-        RWPly_PlyWriterContext::WriteVertex(thePoint,
-                                            Graphic3d_Vec3((float)theNorm.X(), (float)theNorm.Y(), (float)theNorm.Z()),
-                                            Graphic3d_Vec2((float)theUV.X(), (float)theUV.Y()),
-                                            aColor);
-      }
-
-    private:
-      NCollection_DataMap<TopoDS_Shape, Graphic3d_Vec4ub> myFaceColor;
-    };
-
-    PointCloudPlyWriter aPlyCtx(aNode->InternalParameters.WriteTolerance);
-    aPlyCtx.SetNormals(aNode->InternalParameters.WriteNormals);
-    aPlyCtx.SetColors(aNode->InternalParameters.WriteColors);
-    aPlyCtx.SetTexCoords(aNode->InternalParameters.WriteTexCoords);
-
-    TopoDS_Compound aComp;
-    BRep_Builder().MakeCompound(aComp);
-    for (XCAFPrs_DocumentExplorer aDocExplorer(theDocument, aRootLabels, XCAFPrs_DocumentExplorerFlags_OnlyLeafNodes);
-         aDocExplorer.More(); aDocExplorer.Next())
-    {
-      const XCAFPrs_DocumentNode& aDocNode = aDocExplorer.Current();
-      for (RWMesh_FaceIterator aFaceIter(aDocNode.RefLabel, aDocNode.Location, true, aDocNode.Style); aFaceIter.More(); aFaceIter.Next())
-      {
-        BRep_Builder().Add(aComp, aFaceIter.Face());
-        Graphic3d_Vec4ub aColorVec(255);
-        if (aFaceIter.HasFaceColor())
-        {
-          Graphic3d_Vec4 aColorF = aFaceIter.FaceColor();
-          aColorVec.SetValues((unsigned char)int(aColorF.r() * 255.0f),
-                              (unsigned char)int(aColorF.g() * 255.0f),
-                              (unsigned char)int(aColorF.b() * 255.0f),
-                              (unsigned char)int(aColorF.a() * 255.0f));
-        }
-        aPlyCtx.AddFaceColor(aFaceIter.Face(), aColorVec);
-      }
-    }
-    aPlyCtx.SetShape(aComp);
-    Standard_Integer aNbPoints = aNode->InternalParameters.WriteDensity > 0
-      ? aPlyCtx.NbPointsByDensity(aNode->InternalParameters.WriteDensity)
-      : aPlyCtx.NbPointsByTriangulation();
-    if (aNbPoints <= 0)
-    {
-      Message::SendFail() << "Error in the RWPly_Provider during writing the file " <<
-        thePath << "\t: Incorrect number of points";
-      return false;
-    }
-
-    if (!aPlyCtx.Open(thePath)
-        || !aPlyCtx.WriteHeader(aNbPoints, 0, TColStd_IndexedDataMapOfStringString()))
-    {
-      Message::SendFail() << "Error in the RWPly_Provider during writing the file " << thePath;
-      return false;
-    }
-
-    Standard_Boolean isDone = aNode->InternalParameters.WriteDensity > 0
-      ? aPlyCtx.GeneratePointsByDensity(aNode->InternalParameters.WriteDensity)
-      : aPlyCtx.GeneratePointsByTriangulation();
-    if (!isDone)
-    {
-      Message::SendFail() << "Error in the RWPly_Provider during writing the file " 
-        << thePath << "\t: Error during generating point process";
-      return false;
-    }
+    aFileInfo.Add("Author", aNode->InternalParameters.WriteAuthor);
   }
-  else
+  if (!aNode->InternalParameters.WriteComment.IsEmpty())
   {
-    TColStd_IndexedDataMapOfStringString aFileInfo;
-    if (!aNode->InternalParameters.WriteAuthor.IsEmpty())
-    {
-      aFileInfo.Add("Author", aNode->InternalParameters.WriteAuthor);
-    }
-    if (!aNode->InternalParameters.WriteComment.IsEmpty())
-    {
-      aFileInfo.Add("Comments", aNode->InternalParameters.WriteComment);
-    }
-    RWMesh_CoordinateSystemConverter aConverter;
-    aConverter.SetInputLengthUnit(aNode->GlobalParameters.LengthUnit / 1000);
-    aConverter.SetInputCoordinateSystem(aNode->InternalParameters.SystemCS);
-    aConverter.SetOutputLengthUnit(aNode->InternalParameters.FileLengthUnit);
-    aConverter.SetOutputCoordinateSystem(aNode->InternalParameters.FileCS);
-
-    RWPly_CafWriter aPlyCtx(thePath);
-    aPlyCtx.SetNormals(aNode->InternalParameters.WriteNormals);
-    aPlyCtx.SetColors(aNode->InternalParameters.WriteColors);
-    aPlyCtx.SetTexCoords(aNode->InternalParameters.WriteTexCoords);
-    aPlyCtx.SetPartId(aNode->InternalParameters.WritePartId);
-    aPlyCtx.SetFaceId(aNode->InternalParameters.WriteFaceId);
-    if (!aPlyCtx.Perform(theDocument, aFileInfo, theProgress))
-    {
-      Message::SendFail() << "Error in the RWPly_Provider during writing the file " 
-        << thePath << "\t: Cannot perform the document";
-      return false;
-    }
+    aFileInfo.Add("Comments", aNode->InternalParameters.WriteComment);
+  }
+  RWMesh_CoordinateSystemConverter aConverter;
+  aConverter.SetInputLengthUnit(aNode->GlobalParameters.LengthUnit / 1000);
+  aConverter.SetInputCoordinateSystem(aNode->InternalParameters.SystemCS);
+  aConverter.SetOutputLengthUnit(aNode->InternalParameters.FileLengthUnit);
+  aConverter.SetOutputCoordinateSystem(aNode->InternalParameters.FileCS);
+
+  RWPly_CafWriter aPlyCtx(thePath);
+  aPlyCtx.SetNormals(aNode->InternalParameters.WriteNormals);
+  aPlyCtx.SetColors(aNode->InternalParameters.WriteColors);
+  aPlyCtx.SetTexCoords(aNode->InternalParameters.WriteTexCoords);
+  aPlyCtx.SetPartId(aNode->InternalParameters.WritePartId);
+  aPlyCtx.SetFaceId(aNode->InternalParameters.WriteFaceId);
+  if (!aPlyCtx.Perform(theDocument, aFileInfo, theProgress))
+  {
+    Message::SendFail() << "Error in the RWPly_Provider during writing the file " 
+      << thePath << "\t: Cannot perform the document";
+    return false;
   }
+
   return true;
 }
 
index 23b9a929849d05c5f63a437b68e7a8d9aecb0666..80c75df27fa8dcdf5822b6c9678bcbda373f1446 100644 (file)
@@ -6,7 +6,6 @@ TKLCAF
 TKV3d
 TKBRep
 TKG3d
-TKTopAlgo
 TKXDE
 TKService
 CSF_RapidJSON
index 6c80b290d66110a441f8804a792a876a443ffd5d..2e0d1456fcfdda5f0dd3e12ad0abab36e1f36024 100644 (file)
@@ -145,10 +145,6 @@ provider.IGES.OCC.write.layer :  1
 provider.PLY.OCC.file.length.unit :      1
 provider.PLY.OCC.system.cs :     0
 provider.PLY.OCC.file.cs :       1
-provider.PLY.OCC.write.pnt.set :         0
-provider.PLY.OCC.write.distance :        0
-provider.PLY.OCC.write.density :         2e+100
-provider.PLY.OCC.write.tolerance :       1e-07
 provider.PLY.OCC.write.normals :         1
 provider.PLY.OCC.write.colors :  1
 provider.PLY.OCC.write.tex.coords :      0