rdmenezes / ifcplusplus

Automatically exported from code.google.com/p/ifcplusplus
Other
0 stars 0 forks source link

Some IfcProducts got added to osg::Group twice #24

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Load the file from Issue 17
2. Get the geometry generated as osg::Group, save as file
3. Look at the file using some other software

What is the expected output? What do you see instead?
The beams are added twice. Actually, the same node pointer is added twice, 
because when I rename one of them, the other gets renamed too.

What version of the product are you using? On what operating system?
r25, on Windows

Please provide any additional information below.
* There's a slight chance that this may be related to the cause of Issue 17. My 
guess is that when this file is loaded, both the product_shape 
(ReaderWriterIFC.cpp, Ln 505) and the product_switch_curves 
(ReaderWriterIFC.cpp, Ln 521) are valid.

Original issue reported on code.google.com by lizhi...@gmail.com on 20 Aug 2014 at 7:09

GoogleCodeExporter commented 9 years ago
How do you "save as file"? What format and how?
And what other software did you use for opening that file?
Which entity is added twice (entity ID)?

Original comment by fabian.g...@gmail.com on 21 Aug 2014 at 12:20

GoogleCodeExporter commented 9 years ago
I saved it as a file using osgDB::writeNodeFile( <group>, <something.3ds> ) to 
save it as a .3ds file and open using 3D Studio Max.

Actually when I use osg::NodeVisitor to print all the names of the osg nodes 
IfcPlusPlus generates, I am seeing the beams twice; and when I try to rename 
one of the beams using osg::Object's setName(), two beams are being renamed.

All the beams (IfcBeams class) are being saved twice. e.g. #171514.

FYI, this IFC file is exported from Autodesk Revit from a revit file someone 
gave me.

Original comment by lizhi...@gmail.com on 21 Aug 2014 at 3:56

GoogleCodeExporter commented 9 years ago
Beams normally have more than one representation, for example one solid and one 
curve representation.
The curves are added to a separate switch, so that it can be switched on and 
off.
If you look into the osg file, you can see that the second node for one product 
has only lines as PrimitiveSets.

Original comment by fabian.g...@gmail.com on 21 Aug 2014 at 4:37

GoogleCodeExporter commented 9 years ago
I took some time to look at the .osg file saved this way and indeed they are 
represented as switches, and under the switch there are a solid one and one 
named CurveRepresentation. But if you search the .osg file you can see "Use 
Switch_##" (where ## is the UniqueID of one of the Switch for the IfcBeams. I 
believe this means that the same node (reference) is added here in addition to 
the first one.

You can use this piece of code to print the names of all the nodes in the osg 
graph, and you can see they are printed twice:

#include <osg/NodeVisitor>
#include <osg/Node>
class coutNameVisitor : public osg::NodeVisitor
{
public:
    coutNameVisitor() :osg::NodeVisitor( // Traverse all children.
        osg::NodeVisitor::TRAVERSE_ALL_CHILDREN)
    {}
    virtual void apply(osg::Node &searchNode)
    {
        std::string id;
        id = searchNode.getName();
        if (id.length() > 0)
            std::cout << id << std::endl;
        // keep traversing
        traverse(searchNode);
    }
};

//// then in main():
coutNameVisitor printvisitor;
group_->accept(printvisitor);

It might be because in IfcPlusPlusGeometry, ReaderWriterIFC.cpp, the code
    parent_group->addChild( item_grp );
in both Line 218 and Line 532 are both executed for the IfcBeam, since they may 
have both curve and solid representations.

Original comment by lizhi...@gmail.com on 21 Aug 2014 at 10:10

GoogleCodeExporter commented 9 years ago
By printed twice I mean both the switch and its CurveRepresentation are printed 
twice.

Original comment by lizhi...@gmail.com on 21 Aug 2014 at 10:12

Attachments:

GoogleCodeExporter commented 9 years ago
I changed the way the items are added to the product group, that should fix 
this issue.

Original comment by fabian.g...@gmail.com on 19 Sep 2014 at 8:19