Revision: 55244
          http://sourceforge.net/p/brlcad/code/55244
Author:   n_reed
Date:     2013-04-25 14:45:47 +0000 (Thu, 25 Apr 2013)
Log Message:
-----------
Technically can't get an SDAI_Select out of a STEPaggregate, only a 
SelectAggregate; fix casts to reflect reality. Also, delete unloaded objects 
rather than storing them (see r55219).

Revision Links:
--------------
    http://sourceforge.net/p/brlcad/code/55219

Modified Paths:
--------------
    brlcad/trunk/src/conv/step/SurfaceCurve.cpp
    brlcad/trunk/src/conv/step/TrimmedCurve.cpp

Modified: brlcad/trunk/src/conv/step/SurfaceCurve.cpp
===================================================================
--- brlcad/trunk/src/conv/step/SurfaceCurve.cpp 2013-04-25 14:08:29 UTC (rev 
55243)
+++ brlcad/trunk/src/conv/step/SurfaceCurve.cpp 2013-04-25 14:45:47 UTC (rev 
55244)
@@ -111,26 +111,27 @@
     if (associated_geometry.empty()) {
        STEPattribute *attr = step->getAttribute(sse, "associated_geometry");
        if (attr) {
-           STEPaggregate *sa = (STEPaggregate *)(attr->ptr.a);
-           EntityNode *sn = (EntityNode *) sa->GetHead();
+           SelectAggregate *sa = static_cast<SelectAggregate *>(attr->ptr.a);
+           SelectNode *sn = static_cast<SelectNode *>(sa->GetHead());
+
            SDAI_Select *p_or_s;
            while (sn != NULL) {
-               p_or_s = (SDAI_Select *) sn->node;
+               p_or_s = static_cast<SDAI_Select *>(sn->node);
 
-               if (p_or_s->CurrentUnderlyingType() == 
config_control_design::t_pcurve_or_surface) {
+               if (p_or_s && p_or_s->CurrentUnderlyingType() == 
config_control_design::t_pcurve_or_surface) {
                    PCurveOrSurface *aPCOS = new PCurveOrSurface();
 
-                   associated_geometry.push_back(aPCOS);
-
                    if (!aPCOS->Load(step, p_or_s)) {
                        std::cout << CLASSNAME << ":Error loading 
PCurveOrSurface select." << std::endl;
+                       delete aPCOS;
                        return false;
                    }
+                   associated_geometry.push_back(aPCOS);
                } else {
                    std::cout << CLASSNAME << ":Unhandled select in attribute 
'associated_geometry': " << p_or_s->CurrentUnderlyingType()->Description() << 
std::endl;
                    return false;
                }
-               sn = (EntityNode *) sn->NextNode();
+               sn = static_cast<SelectNode *>(sn->NextNode());
            }
        }
     }

Modified: brlcad/trunk/src/conv/step/TrimmedCurve.cpp
===================================================================
--- brlcad/trunk/src/conv/step/TrimmedCurve.cpp 2013-04-25 14:08:29 UTC (rev 
55243)
+++ brlcad/trunk/src/conv/step/TrimmedCurve.cpp 2013-04-25 14:45:47 UTC (rev 
55244)
@@ -107,41 +107,40 @@
     if (trim_1.empty()) {
        STEPattribute *attr = step->getAttribute(sse, "trim_1");
        if (attr) {
-           STEPaggregate *sa = (STEPaggregate *)(attr->ptr.a);
-           EntityNode *sn = (EntityNode *) sa->GetHead();
+           SelectAggregate *sa = static_cast<SelectAggregate *>(attr->ptr.a);
+           SelectNode *sn = static_cast<SelectNode *>(sa->GetHead());
            SDAI_Select *p;
            while (sn != NULL) {
-               p = (SDAI_Select *) sn->node;
+               p = static_cast<SDAI_Select *>(sn->node);
                TrimmingSelect *aTS = new TrimmingSelect();
 
-               trim_1.push_back(aTS);
-
-               if (!aTS->Load(step, p)) {
+               if (p && !aTS->Load(step, p)) {
                    std::cout << CLASSNAME << ":Error loading TrimmingSelect 
from list." << std::endl;
+                   delete aTS;
                    return false;
                }
-
-               sn = (EntityNode *) sn->NextNode();
+               trim_1.push_back(aTS);
+               sn = static_cast<SelectNode *>(sn->NextNode());
            }
        }
     }
     if (trim_2.empty()) {
        STEPattribute *attr = step->getAttribute(sse, "trim_2");
        if (attr) {
-           STEPaggregate *sa = (STEPaggregate *)(attr->ptr.a);
-           EntityNode *sn = (EntityNode *) sa->GetHead();
+           SelectAggregate *sa = static_cast<SelectAggregate *>(attr->ptr.a);
+           SelectNode *sn = static_cast<SelectNode *>(sa->GetHead());
            SDAI_Select *p;
            while (sn != NULL) {
-               p = (SDAI_Select *) sn->node;
+               p = static_cast<SDAI_Select *>(sn->node);
                TrimmingSelect *aTS = new TrimmingSelect();
 
-               trim_2.push_back(aTS);
-
-               if (!aTS->Load(step, p)) {
+               if (p && !aTS->Load(step, p)) {
                    std::cout << CLASSNAME << ":Error loading TrimmingSelect 
from list." << std::endl;
+                   delete aTS;
                    return false;
                }
-               sn = (EntityNode *) sn->NextNode();
+               trim_2.push_back(aTS);
+               sn = static_cast<SelectNode *>(sn->NextNode());
            }
        }
     }

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service 
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_apr
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to