Revision: 57282
          http://sourceforge.net/p/brlcad/code/57282
Author:   starseeker
Date:     2013-08-29 21:53:24 +0000 (Thu, 29 Aug 2013)
Log Message:
-----------
Allow the control points to be inserted into the instance manager after their 
surface definitions - results in a step file where the 'high level' structure 
is grouped at the top of the file, making a study of the high level structure 
slightly easier.

Modified Paths:
--------------
    brlcad/trunk/src/conv/step/g-step/ON_Brep.cpp
    brlcad/trunk/src/conv/step/g-step/ON_Brep.h

Modified: brlcad/trunk/src/conv/step/g-step/ON_Brep.cpp
===================================================================
--- brlcad/trunk/src/conv/step/g-step/ON_Brep.cpp       2013-08-29 21:44:28 UTC 
(rev 57281)
+++ brlcad/trunk/src/conv/step/g-step/ON_Brep.cpp       2013-08-29 21:53:24 UTC 
(rev 57282)
@@ -114,29 +114,55 @@
     }
 }
 
-
+/* Unlike most of the structures we're working with, GenericAggregate seems to 
require that we manually
+ * build its final string with the step file id numbers that identify each 
control point.  To allow for
+ * delayed instance manager population, we build a temporary map of nested 
vectors to hold the information
+ * inthe proper form until we are ready for it.*/
 void
-ON_NurbsSurfaceCV_to_GenericAggregate(ON_NurbsSurface *insrf, 
SdaiB_spline_surface *step_srf, Exporter_Info_AP203 *info) {
-    GenericAggregate *control_pnts_lists = step_srf->control_points_list_();
+ON_NurbsSurfaceCV_Initialize(ON_NurbsSurface *insrf, SdaiB_spline_surface 
*step_srf, Exporter_Info_AP203 *info) {
     ON_3dPoint cv_pnt;
+    std::vector<std::vector<STEPentity *> > i_array;
     for (int i = 0; i < insrf->CVCount(0); i++) {
-       std::ostringstream ss;
-       ss << "(";
+       std::vector<STEPentity *> j_array;
        for (int j = 0; j < insrf->CVCount(1); j++) {
            SdaiCartesian_point *step_cartesian = (SdaiCartesian_point 
*)info->registry->ObjCreate("CARTESIAN_POINT");
            step_cartesian->name_("''");
-           info->instance_list->Append((STEPentity *)step_cartesian, 
completeSE);
            insrf->GetCV(i, j, cv_pnt);
            ON_3dPoint_to_Cartesian_point(&(cv_pnt), step_cartesian);
-           if (j != 0) ss << ", ";
-           ss << "#" << ((SDAI_Application_instance 
*)step_cartesian)->StepFileId();
+           j_array.push_back((STEPentity *)step_cartesian);
        }
-       ss << ")";
-       std::string str = ss.str();
-       control_pnts_lists->AddNode(new GenericAggrNode(str.c_str()));
+       i_array.push_back(j_array);
     }
+    info->surface_cv[(STEPentity*)step_srf] = i_array;
 }
 
+// Call this function after all cartesian points have an instance manager 
instance,
+// (and hence a StepFileID) to populate the surface GenericAggregate control 
point
+// slots.  Must be run *after* ON_NurbsSurfaceCV_Initialize has been run on 
*all*
+// surfaces.
+void
+ON_NurbsSurfaceCV_Finalize_GenericAggregates(Exporter_Info_AP203 *info) 
+{
+    std::map<STEPentity*, std::vector<std::vector<STEPentity *> > >::iterator 
scv_it;
+    std::vector<std::vector<STEPentity *> >::iterator outer_it;
+    std::vector<STEPentity *>::iterator inner_it;
+    for(scv_it = info->surface_cv.begin(); scv_it != info->surface_cv.end(); 
++scv_it) {
+        SdaiB_spline_surface *step_srf = (SdaiB_spline_surface *)scv_it->first;
+       GenericAggregate *control_pnts_lists = step_srf->control_points_list_();
+       for (outer_it = scv_it->second.begin(); outer_it != 
scv_it->second.end(); ++outer_it) {
+           std::ostringstream ss;
+           ss << "(";
+           for (inner_it = (*outer_it).begin(); inner_it != (*outer_it).end(); 
++inner_it) {
+               info->instance_list->Append((STEPentity *)(*inner_it), 
completeSE);
+               if (inner_it != (*outer_it).begin()) ss << ", ";
+               ss << "#" << ((STEPentity *)(*inner_it))->StepFileId();
+           }
+           ss << ")";
+           std::string str = ss.str();
+           control_pnts_lists->AddNode(new GenericAggrNode(str.c_str()));
+       }
+    }
+}
 
 void
 ON_NurbsCurveKnots_to_Aggregates(ON_NurbsCurve *incrv, 
SdaiB_spline_curve_with_knots *step_crv)
@@ -517,7 +543,7 @@
     instance_list->Append((STEPentity *)design_context, completeSE);
     prod_def->frame_of_reference_(design_context);
     design_context->name_("''");
-    design_context->life_cycle_stage_("Design");
+    design_context->life_cycle_stage_("'Design'");
     design_context->frame_of_reference_(app_context);
 
     return ret_entity;
@@ -713,6 +739,8 @@
        info->instance_list->Append((STEPentity *)(*v_it), completeSE);
     }
 
+    // Now that we know the ids for all the points, we can finalize the 
surface definitions
+    ON_NurbsSurfaceCV_Finalize_GenericAggregates(info); 
 }
 
 bool
@@ -892,7 +920,7 @@
            curr_surface->name_("''");
            curr_surface->u_degree_(p_nurb.Degree(0));
            curr_surface->v_degree_(p_nurb.Degree(1));
-           ON_NurbsSurfaceCV_to_GenericAggregate(&p_nurb, curr_surface, info);
+           ON_NurbsSurfaceCV_Initialize(&p_nurb, curr_surface, info);
 
            SdaiB_spline_surface_with_knots *surface_knots = 
(SdaiB_spline_surface_with_knots *)info->surfaces.at(i);
            ON_NurbsSurfaceKnots_to_Aggregates(&p_nurb, surface_knots);
@@ -917,7 +945,7 @@
            curr_surface->name_("''");
            curr_surface->u_degree_(n_surface->Degree(0));
            curr_surface->v_degree_(n_surface->Degree(1));
-           ON_NurbsSurfaceCV_to_GenericAggregate(n_surface, curr_surface, 
info);
+           ON_NurbsSurfaceCV_Initialize(n_surface, curr_surface, info);
 
            SdaiB_spline_surface_with_knots *surface_knots = 
(SdaiB_spline_surface_with_knots *)info->surfaces.at(i);
            ON_NurbsSurfaceKnots_to_Aggregates(n_surface, surface_knots);
@@ -944,7 +972,7 @@
            curr_surface->name_("''");
            curr_surface->u_degree_(sum_nurb.Degree(0));
            curr_surface->v_degree_(sum_nurb.Degree(1));
-           ON_NurbsSurfaceCV_to_GenericAggregate(&sum_nurb, curr_surface, 
info);
+           ON_NurbsSurfaceCV_Initialize(&sum_nurb, curr_surface, info);
 
            SdaiB_spline_surface_with_knots *surface_knots = 
(SdaiB_spline_surface_with_knots *)info->surfaces.at(i);
            ON_NurbsSurfaceKnots_to_Aggregates(&sum_nurb, surface_knots);

Modified: brlcad/trunk/src/conv/step/g-step/ON_Brep.h
===================================================================
--- brlcad/trunk/src/conv/step/g-step/ON_Brep.h 2013-08-29 21:44:28 UTC (rev 
57281)
+++ brlcad/trunk/src/conv/step/g-step/ON_Brep.h 2013-08-29 21:53:24 UTC (rev 
57282)
@@ -47,7 +47,7 @@
     SdaiAdvanced_brep_shape_representation *advanced_brep;
     SdaiRepresentation *shape_rep;
 
-    std::map<STEPentity *, ON_NurbsSurface*> surface_map;
+    std::map<STEPentity*, std::vector<std::vector<STEPentity *> > > surface_cv;
 };
 
 bool ON_BRep_to_STEP(ON_Brep *brep, Exporter_Info_AP203 *info);

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


------------------------------------------------------------------------------
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58040911&iu=/4140/ostg.clktrk
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to