diff --git a/src/RWPly/RWPly_ConfigurationNode.cxx b/src/RWPly/RWPly_ConfigurationNode.cxx index 6e0c7719fc..ecd16f4bbb 100644 --- a/src/RWPly/RWPly_ConfigurationNode.cxx +++ b/src/RWPly/RWPly_ConfigurationNode.cxx @@ -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"; diff --git a/src/RWPly/RWPly_ConfigurationNode.hxx b/src/RWPly/RWPly_ConfigurationNode.hxx index 0b4e122b71..93ac598d8e 100644 --- a/src/RWPly/RWPly_ConfigurationNode.hxx +++ b/src/RWPly/RWPly_ConfigurationNode.hxx @@ -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 diff --git a/src/RWPly/RWPly_Provider.cxx b/src/RWPly/RWPly_Provider.cxx index c13f9571be..1f81de5bbc 100644 --- a/src/RWPly/RWPly_Provider.cxx +++ b/src/RWPly/RWPly_Provider.cxx @@ -14,7 +14,6 @@ #include #include -#include #include #include #include @@ -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 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; } diff --git a/src/TKRWMesh/EXTERNLIB b/src/TKRWMesh/EXTERNLIB index 23b9a92984..80c75df27f 100644 --- a/src/TKRWMesh/EXTERNLIB +++ b/src/TKRWMesh/EXTERNLIB @@ -6,7 +6,6 @@ TKLCAF TKV3d TKBRep TKG3d -TKTopAlgo TKXDE TKService CSF_RapidJSON diff --git a/tests/de_wrapper/configuration/A3 b/tests/de_wrapper/configuration/A3 index 6c80b290d6..2e0d1456fc 100644 --- a/tests/de_wrapper/configuration/A3 +++ b/tests/de_wrapper/configuration/A3 @@ -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