Algorithms
The main "skeleton" of the program is as follows:
Begin
{
Open
.WRL file
if opening
.WRL file = error then end
if opening
.WRL file = fine then continue
Search
for VRML input
{
if VRML input = 'Material' then Search for more data
{
if VRML input = 'diffuseColor' then get RGB data
else exit 'Material' and continue searching
}
if VRML input = 'Translation' then search for more data
{
if VRML input = 'translation' then get translation data
else exit 'Translation' and continue searching
}
if VRML input = 'Rotation' then search for more data
{
if VRML input = 'rotation' then get rotation data
else exit 'rotation' and continue searching
}
if VRML input = 'Cylinder' then search for more data
{
if VRML input = 'height' then get height data
if VRML input = 'radius' then get radius data
else exit 'Cylinder' and continue searching
}
if VRML input = 'Cone' then search for more data
{
if VRML input = 'height' then get height data
if VRML input = 'radius' then get radius data
else exit 'Cone' and continue searching
}
if VRML input = 'Cube' then search for more data
{
if VRML input = 'height' then get height data
if VRML input = 'depth' then get depth data
if VRML input = 'width' then get width data
generate cube definition
else exit 'Cube' and continue searching
}
if VRML input = 'Sphere' then search for more data
{
if VRML input = 'radius' then get radius data
else exit 'Sphere' and continue searching
}
if VRML input = 'Coordinate3' then search for more data
{
if VRML input = 'Point' then get point definitions
else exit 'Coordinate3' and continue searching
}
if VRML input = 'IndexedFaceSet' then search for more data
{
if VRML input = 'coordIndex' then get face definitions
else exit 'IndexedFaceSet' and continue searching
}
}
start
.SAT file generation
calculate
transformation vector using data from 'Translation' and 'Rotation'
write
transformation vector and RGB color definition on ACIS file
write
general features: body, lump, shell
if VRML
input = 'Cone' or 'Sphere' or 'Cylinder'
{
generate basic ACIS primitive:
{
use data from 'radius' and 'height' to define the main ACIS points
generate the main vertices
generate coedges, edges, loops and faces
write .SAT file
}
}
if VRML
input = 'Cube' or 'IndexedFaceSet'
{
generate ACIS polyhedron:
{
use data from 'Point' to define the main points
assign vertices to these points
generate coedges and loops using data from 'IndexedFaceSet' and vertices
generate edges from coedges definition and orient coedges
calculate curves' definition from edge and vertex definition
generate faces from loop and edge definitions
calculate face definition using data from coedge definition
write .SAT file
}
}
End
Here it is important to point out that ACIS data structute is not sequential. This means that ACIS makes reference to entities on any position within the file to define another. The file writing in C is sequential, therefore, we’ll need to keep all ACIS data and definitions in memory before actually writing the ACIS file. We have an example of a VRML and ACIS file in figure 3.
For further reference the source code is included here: project.cpp
You can download the .EXE file: proyecto.exe
}