Revision: 56633
          http://sourceforge.net/p/brlcad/code/56633
Author:   starseeker
Date:     2013-08-06 17:49:54 +0000 (Tue, 06 Aug 2013)
Log Message:
-----------
First successful generation of STEP formatted content containing data from an 
ON_Brep.

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

Added Paths:
-----------
    brlcad/trunk/src/conv/step/ON_Brep.h

Modified: brlcad/trunk/src/conv/step/CMakeLists.txt
===================================================================
--- brlcad/trunk/src/conv/step/CMakeLists.txt   2013-08-06 17:43:57 UTC (rev 
56632)
+++ brlcad/trunk/src/conv/step/CMakeLists.txt   2013-08-06 17:49:54 UTC (rev 
56633)
@@ -469,6 +469,7 @@
 set(gstep_SOURCES
   ${fedex_srcs}
   BRLCADWrapper.cpp
+  ON_Brep.cpp
   g-step.cpp
   )
 
@@ -507,7 +508,7 @@
 
 DISTCLEAN(${SCHEMA_OUT_DIR}/make_schema)
 
-CMAKEFILES(ON_Brep.cpp)
+CMAKEFILES(ON_Brep.h)
 
 # Local Variables:
 # tab-width: 8

Modified: brlcad/trunk/src/conv/step/ON_Brep.cpp
===================================================================
--- brlcad/trunk/src/conv/step/ON_Brep.cpp      2013-08-06 17:43:57 UTC (rev 
56632)
+++ brlcad/trunk/src/conv/step/ON_Brep.cpp      2013-08-06 17:49:54 UTC (rev 
56633)
@@ -57,22 +57,10 @@
 // Note that STEPentity is the same thing as SDAI_Application_instance... see 
src/clstepcore/sdai.h line 220
 //
 
-STEPattribute * getAttribute(STEPentity *ent, const char *name)
-{
-       STEPattribute *attr, *attr_result;
-       ent->ResetAttributes();
-       while ((attr = ent->NextAttribute()) != NULL) {
-               std::string attrname = attr->Name();
-               if (attrname.compare(name) == 0) {
-                       attr_result = attr;
-                       break;
-               }
-       }
-       ent->ResetAttributes();
-       return attr_result;
-}
+#include "STEPEntity.h"
 
-bool ON_BRep_to_STEP(ON_Brep *brep, Registry *registry)
+
+bool ON_BRep_to_STEP(ON_Brep *brep, Registry *registry, InstMgr *instance_list)
 {
        STEPentity ** vertex_cartesian_pt_array = new 
STEPentity*[brep->m_V.Count()];
        STEPentity ** vertex_pt_array = new STEPentity*[brep->m_V.Count()];
@@ -91,19 +79,20 @@
        for (int i = 0; i < brep->m_V.Count(); ++i) {
                 // Cartesian points (actual 3D geometry)
                vertex_cartesian_pt_array[i] = 
registry->ObjCreate("CARTESIAN_POINT");
-               STEPattribute *coords = 
getAttribute(vertex_cartesian_pt_array[i], "coordinates");
-               RealAggregate_ptr coord_vals = coords->coordinates_();
+               instance_list->Append(vertex_cartesian_pt_array[i], completeSE);
+               RealAggregate_ptr coord_vals = ((SdaiCartesian_point 
*)vertex_cartesian_pt_array[i])->coordinates_();
                 RealNode *xnode = new RealNode();
-                xnode->value = brep->m_V[i].x;
-               coord_vals.AddNode(xnode);
+                xnode->value = brep->m_V[i].Point().x;
+               coord_vals->AddNode(xnode);
                 RealNode *ynode = new RealNode();
-                ynode->value = brep->m_V[i].y;
-               coord_vals.AddNode(ynode);
+                ynode->value = brep->m_V[i].Point().y;
+               coord_vals->AddNode(ynode);
                 RealNode *znode = new RealNode();
-                znode->value = brep->m_V[i].z;
-               coord_vals.AddNode(znode);
+                znode->value = brep->m_V[i].Point().z;
+               coord_vals->AddNode(znode);
                 // Vertex points (topological, references actual 3D geometry)
                vertex_pt_array[i] = registry->ObjCreate("VERTEX_POINT");
-               vertex_pt_array[i]->vertex_geometry_((const 
SdaiPoint_ptr)cartesian_pt_array[i]);
+               ((SdaiVertex_point 
*)vertex_pt_array[i])->vertex_geometry_((const 
SdaiPoint_ptr)vertex_cartesian_pt_array[i]);
+               instance_list->Append(vertex_pt_array[i], completeSE);
        }
 }

Added: brlcad/trunk/src/conv/step/ON_Brep.h
===================================================================
--- brlcad/trunk/src/conv/step/ON_Brep.h                                (rev 0)
+++ brlcad/trunk/src/conv/step/ON_Brep.h        2013-08-06 17:49:54 UTC (rev 
56633)
@@ -0,0 +1,41 @@
+/*                 ON_Brep.h
+ * BRL-CAD
+ *
+ * Copyright (c) 2013 United States Government as represented by
+ * the U.S. Army Research Laboratory.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * version 2.1 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this file; see the file named COPYING for more
+ * information.
+ */
+/** @file step/ON_Brep.h
+ *
+ */
+
+#ifndef ON_BREP_H_
+#define ON_BREP_H_
+
+#include "STEPWrapper.h"
+
+bool ON_BRep_to_STEP(ON_Brep *brep, Registry *registry, InstMgr 
*instance_list);
+
+#endif /* ON_BREP_H_ */
+
+/*
+ * Local Variables:
+ * tab-width: 8
+ * mode: C
+ * indent-tabs-mode: t
+ * c-file-style: "stroustrup"
+ * End:
+ * ex: shiftwidth=4 tabstop=8
+ */


Property changes on: brlcad/trunk/src/conv/step/ON_Brep.h
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: brlcad/trunk/src/conv/step/g-step.cpp
===================================================================
--- brlcad/trunk/src/conv/step/g-step.cpp       2013-08-06 17:43:57 UTC (rev 
56632)
+++ brlcad/trunk/src/conv/step/g-step.cpp       2013-08-06 17:49:54 UTC (rev 
56633)
@@ -34,6 +34,7 @@
 //
 #include <BRLCADWrapper.h>
 #include <STEPWrapper.h>
+#include "ON_Brep.h"
 
 //
 // include NIST step related headers
@@ -128,73 +129,18 @@
     ON_TextLog dump(wstr);
     brep->Dump(dump);
     ON_String ss = wstr;
-    //std::cout << ss.Array() << "\n";
-    //
+    bu_log("Brep:\n %s\n", ss.Array()); 
+
     Registry *registry = new Registry( SchemaInit );
     InstMgr instance_list;
-    //STEPfile *sfile = new STEPfile(*registry, instance_list);
+    STEPfile *sfile = new STEPfile(*registry, instance_list);
 
-    int entities_cnt = brep->m_S.Count() + brep->m_C3.Count() + 
brep->m_C2.Count() +
-                       brep->m_V.Count() + brep->m_E.Count() + 
brep->m_T.Count() +
-                       brep->m_L.Count() + brep->m_F.Count() + 
registry->GetEntityCnt();
-    STEPentity ** SEarray = new STEPentity*[entities_cnt];
-   // SEarray[0] = registry->ObjCreate("Advanced_Brep_Shape_Representation);
+    registry->ResetSchemas();
+    registry->ResetEntities();
+    ON_BRep_to_STEP(brep, registry, &instance_list);
 
-   registry->ResetSchemas();
-   registry->ResetEntities();
+    sfile->WriteExchangeFile(std::cout);
 
-//   ON_BRep_to_STEP(brep, registry);
-
-   const SchemaDescriptor * schema = registry->NextSchema();
-   cout << "Printing entities in schema " << schema->Name() << endl;
-   const EntityDescriptor * ent;  // needs to be declared const...
-   for( int i = 0; i < registry->GetEntityCnt(); i++ ) {
-       ent = registry->NextEntity();
-       SEarray[i] = registry->ObjCreate( ent->Name());
-       instance_list.Append( SEarray[i], completeSE );
-       std::cout << "  " << ent->Name() << "\n";
-       SEarray[i]->ResetAttributes();
-       STEPattribute *attr = SEarray[i]->NextAttribute();
-       while (attr != 0) {
-          std::cout << "    " << attr->aDesc->Name() << ": " << 
attr->aDesc->TypeName() << "\n";
-          attr = SEarray[i]->NextAttribute();
-       }
-   }
-
-
-// TODO - Need to create proper load for .g files and OpenFile for .stp files 
- maybe rework slightly with an
-// eye towards supporting read/write scenarios for both file types...
-#if 0
-    STEPWrapper *step = new STEPWrapper();
-
-    /* load STEP file */
-    if (step->load(iflnm)) {
-
-       step->printLoadStatistics();
-
-       if (!dotg) {
-           std::cerr << "ERROR: unable to create BRL-CAD instance" << 
std::endl;
-           ret = 3;
-       } else {
-
-           std::cerr << "Writing output file [" << oflnm << "] ...";
-           if (dotg->OpenFile(oflnm.c_str())) {
-               step->convert(dotg);
-               std::cerr << "done!" << std::endl;
-           } else {
-               std::cerr << "ERROR: unable to open BRL-CAD output file [" << 
oflnm << "]" << std::endl;
-               ret = 4;
-           }
-
-           dotg->Close();
-           delete dotg;
-       }
-    }
-    delete step;
-    Factory::DeleteObjects();
-
-#endif
-
     return ret;
 }
 

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


------------------------------------------------------------------------------
Get 100% visibility into Java/.NET code with AppDynamics Lite!
It's a free troubleshooting tool designed for production.
Get down to code-level detail for bottlenecks, with <2% overhead. 
Download for free and get started troubleshooting in minutes. 
http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to