1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-14 13:30:48 +03:00

0025279: OCCT fails to read VRML file created by OCCT

1) Version of VRML format is added to VrmlAPI_Writer::Write() and VrmlAPI::Write() to allow use the both versions of the VRML by one writer.
2) Unification of the command to write VRML of both versions. Now "writevrml" command can write VRLM files of v1.0 and v2.0, with wireframe/shaded/both representations. Parameter "Deflection" was removed (next commit will remove meshing, so parameter will be useless).
3) Meshing is removed from writers of both (v1.0 and v2.0) versions. Shaded representation is skipped in case when a mesh does not exist.
Wireframe representation checks the existence of a mesh before. If the mesh exists, a deflected edges are taken from the mesh, otherwise - are generated with the default deflection.
4) Drawing of redundant edges is removed in wireframe representation of VRML version 1.0 (a grid on non-plane surfaces does not match a real edges of TopoDS_Shape and does not match representation in version 2.0).

Test case for issue CR25279
This commit is contained in:
akz
2015-02-05 15:02:01 +03:00
committed by bugmaster
parent 31e0b8e84c
commit f5fa6b335c
13 changed files with 287 additions and 197 deletions

View File

@@ -42,6 +42,7 @@
#include <TopExp_Explorer.hxx>
#include <BRep_Builder.hxx>
#include <Precision.hxx>
#include <Standard_Version.hxx>
#ifdef WNT
#define _CRT_SECURE_NO_DEPRECATE
@@ -75,7 +76,8 @@ VrmlData_Scene::VrmlData_Scene
myAutoNameCounter (0)
{
myWorldInfo = new VrmlData_WorldInfo (* this);
myWorldInfo->AddInfo ("Created by OPEN CASCADE (tm) VrmlData API");
Standard_CString anInfo = "Generated by Open CASCADE Technology " OCC_VERSION_STRING;
myWorldInfo->AddInfo (anInfo);
myLstNodes.Append (myWorldInfo);
myAllNodes.Append (myWorldInfo);
}

View File

@@ -144,7 +144,6 @@ void VrmlData_ShapeConvert::Convert (const Standard_Boolean theExtractFaces,
TopoDS_Shape aTestedShape;
aTestedShape.TShape (aShape.TShape());
aTestedShape.Orientation (isReverse ? TopAbs_REVERSED : TopAbs_FORWARD);
Standard_Boolean isTessellate (Standard_False);
switch (ShapeType[i]) {
case TopAbs_FACE:
{
@@ -158,16 +157,6 @@ void VrmlData_ShapeConvert::Convert (const Standard_Boolean theExtractFaces,
break;
}
if (aTri.IsNull())
isTessellate = Standard_True;
// Check the existing deflection
else if (aTri->Deflection() > aDeflection+ Precision::Confusion())
isTessellate = Standard_True;
if (isTessellate) {
// Triangulate the face by the standard OCC mesher
BRepMesh_IncrementalMesh IM(aFace, aDeflection, Standard_False, theDeflAngle);
aTri = BRep_Tool::Triangulation (aFace, aLoc);
}
if (aTri.IsNull() == Standard_False) {
TopoDS_Shape aTestedShapeRev = aTestedShape;
aTestedShapeRev.Orientation (isReverse ?
@@ -200,8 +189,6 @@ void VrmlData_ShapeConvert::Convert (const Standard_Boolean theExtractFaces,
{
const TopoDS_Edge& aEdge = TopoDS::Edge (aShape);
if (aEdge.IsNull() == Standard_False) {
Handle(Poly_Polygon3D) aPol = BRep_Tool::Polygon3D (aEdge, aLoc);
if (aRelMap.IsBound (aTestedShape)) {
aTShapeNode = aRelMap(aTestedShape);
break;
@@ -214,52 +201,34 @@ void VrmlData_ShapeConvert::Convert (const Standard_Boolean theExtractFaces,
aTShapeNode = aRelMap(aTestedShape);
break;
}
if (aPol.IsNull())
isTessellate = Standard_True;
// Check the existing deflection
else if (aPol->Deflection() > aDeflection+ Precision::Confusion()
&& BRep_Tool::IsGeometric(aEdge))
isTessellate = Standard_True;
if (isTessellate && BRep_Tool::IsGeometric(aEdge)) {
//try to find PolygonOnTriangulation
Handle(Poly_PolygonOnTriangulation) aPT;
Handle(Poly_Triangulation) aT;
TopLoc_Location aL;
Standard_Boolean found = Standard_False;
for(i = 1; ; i++) {
BRep_Tool::PolygonOnTriangulation(aEdge, aPT, aT, aL, i);
//try to find PolygonOnTriangulation
Handle(Poly_PolygonOnTriangulation) aPT;
Handle(Poly_Triangulation) aT;
TopLoc_Location aL;
BRep_Tool::PolygonOnTriangulation(aEdge, aPT, aT, aL);
if(aPT.IsNull() || aT.IsNull()) break;
if(aPT->Deflection() <= aDeflection + Precision::Confusion() &&
aPT->HasParameters()) {
found = Standard_True;
break;
}
// If PolygonOnTriangulation was found -> get the Polygon3D
Handle(Poly_Polygon3D) aPol;
if(!aPT.IsNull() && !aT.IsNull() && aPT->HasParameters()) {
BRepAdaptor_Curve aCurve(aEdge);
Handle(TColStd_HArray1OfReal) aPrs = aPT->Parameters();
Standard_Integer nbNodes = aPT->NbNodes();
TColgp_Array1OfPnt arrNodes(1, nbNodes);
TColStd_Array1OfReal arrUVNodes(1, nbNodes);
for(Standard_Integer j = 1; j <= nbNodes; j++) {
arrUVNodes(j) = aPrs->Value(aPrs->Lower() + j - 1);
arrNodes(j) = aCurve.Value(arrUVNodes(j));
}
if(found) {
aPol = new Poly_Polygon3D(arrNodes, arrUVNodes);
aPol->Deflection (aPT->Deflection());
}
else {
aPol = BRep_Tool::Polygon3D(aEdge, aL);
BRepAdaptor_Curve aCurve(aEdge);
Handle(TColStd_HArray1OfReal) aPrs = aPT->Parameters();
Standard_Integer nbNodes = aPT->NbNodes();
TColgp_Array1OfPnt arrNodes(1, nbNodes);
TColStd_Array1OfReal arrUVNodes(1, nbNodes);
for(Standard_Integer j = 1; j <= nbNodes; j++) {
arrUVNodes(j) = aPrs->Value(aPrs->Lower() + j - 1);
arrNodes(j) = aCurve.Value(arrUVNodes(j));
}
aPol = new Poly_Polygon3D(arrNodes, arrUVNodes);
aPol->Deflection (aPT->Deflection());
}
else{
// If polygon was not found -> generate it
if (aPol.IsNull()) {
BRepAdaptor_Curve aCurve(aEdge);
const Standard_Real aFirst = aCurve.FirstParameter();
const Standard_Real aLast = aCurve.LastParameter();
@@ -277,10 +246,11 @@ void VrmlData_ShapeConvert::Convert (const Standard_Boolean theExtractFaces,
aPol = new Poly_Polygon3D(arrNodes, arrUVNodes);
aPol->Deflection (aDeflection);
}
BRep_Builder aBld;
aBld.UpdateEdge (aEdge, aPol);
}
if (aPol.IsNull())
continue;
aTShapeNode = polToIndexedLineSet (aPol);
myScene.AddNode (aTShapeNode, Standard_False);
// Bind the converted face