mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-19 13:40:49 +03:00
Data Exchange, RWObj_Reader - Facets with empty normals like 'f 1// 2// 3//' (#520)
Removing an obsolete header comment in the PPM writer Correcting the handling of facet indices when normals or texture coordinates are empty in the OBJ reader. - In Image_AlienPixMap.cxx, the unused header comment is removed. - In Graphic3d_Aspects.hxx, the default viewer settings comment is updated. - In RWObj_Reader.cxx, additional checks are added to correctly parse OBJ face definitions with empty texture and normal indices.
This commit is contained in:
committed by
dpasukhi
parent
90b0e1d590
commit
468bcd0c27
@@ -301,15 +301,21 @@ void RWObj_Reader::pushIndices(const char* thePos)
|
||||
if (*thePos == '/')
|
||||
{
|
||||
++thePos;
|
||||
a3Indices[1] = int(strtol(thePos, &aNext, 10) - 1);
|
||||
thePos = aNext;
|
||||
if (*thePos != '/')
|
||||
{
|
||||
a3Indices[1] = int(strtol(thePos, &aNext, 10) - 1);
|
||||
thePos = aNext;
|
||||
}
|
||||
|
||||
// parse Normal index
|
||||
if (*thePos == '/')
|
||||
{
|
||||
++thePos;
|
||||
a3Indices[2] = int(strtol(thePos, &aNext, 10) - 1);
|
||||
thePos = aNext;
|
||||
if (!IsSpace(*thePos))
|
||||
{
|
||||
a3Indices[2] = int(strtol(thePos, &aNext, 10) - 1);
|
||||
thePos = aNext;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
44
tests/de_mesh/obj_read/emptynorm
Normal file
44
tests/de_mesh/obj_read/emptynorm
Normal file
@@ -0,0 +1,44 @@
|
||||
puts "========"
|
||||
puts "Data Exchange, RWObj_Reader - fix reading facets with empty normals like 'f 1// 2// 3//'"
|
||||
puts "Test reads small generated file."
|
||||
puts "========"
|
||||
|
||||
set sample_obj {g Group1
|
||||
v 0 0 0
|
||||
v 2 0 0
|
||||
v 2 1 0
|
||||
v 1 2 0
|
||||
v 0 1 0
|
||||
v 0 0 2
|
||||
v 2 0 2
|
||||
v 2 1 2
|
||||
v 1 2 2
|
||||
v 0 1 2
|
||||
f 5// 4// 3// 2// 1//
|
||||
f 7// 8// 9// 10// 6//
|
||||
f 10// 9// 4// 5//
|
||||
f 9// 8// 3// 4//
|
||||
f 6// 10// 5// 1//
|
||||
f 2// 3// 8// 7//
|
||||
f 1// 2// 7// 6//}
|
||||
|
||||
set fd [open ${imagedir}/${casename}.obj w]
|
||||
fconfigure $fd -translation lf
|
||||
puts $fd $sample_obj
|
||||
close $fd
|
||||
readobj mlf ${imagedir}/${casename}.obj -singleFace
|
||||
checknbshapes mlf -face 1
|
||||
checktrinfo mlf -tri 16 -nod 10
|
||||
|
||||
# read OBJ into document
|
||||
ReadObj D ${imagedir}/${casename}.obj
|
||||
|
||||
# Delete the temporary file after reading
|
||||
file delete ${imagedir}/${casename}.obj
|
||||
|
||||
vclear
|
||||
vinit View1
|
||||
vdisplay -dispMode 1 mlf
|
||||
vaxo
|
||||
vfit
|
||||
vdump ${imagedir}/${casename}_raw.png
|
Reference in New Issue
Block a user