StepFile: introduce generated parser code.
parent
26e9591cc9
commit
aceaecaed7
|
@ -724,6 +724,9 @@ SET( Step_SRCS
|
|||
STEPFile.h
|
||||
Importer/StepFile/StepFileImporter.h
|
||||
Importer/StepFile/StepFileImporter.cpp
|
||||
Importer/StepFile/StepFileGen1.cpp
|
||||
Importer/StepFile/StepFileGen2.cpp
|
||||
Importer/StepFile/StepReaderGen.h
|
||||
StepExporter.h
|
||||
StepExporter.cpp
|
||||
)
|
||||
|
|
|
@ -49,7 +49,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <assimp/DefaultIOSystem.h>
|
||||
|
||||
namespace Assimp {
|
||||
namespace STEP {
|
||||
namespace StepFile {
|
||||
|
||||
using namespace STEP;
|
||||
|
||||
static const aiImporterDesc desc = { "StepFile Importer",
|
||||
"",
|
||||
|
@ -105,7 +107,7 @@ void StepFileImporter::InternReadFile(const std::string &file, aiScene* pScene,
|
|||
}
|
||||
}
|
||||
|
||||
} // Namespace STEP
|
||||
} // Namespace StepFile
|
||||
} // Namespace Assimp
|
||||
|
||||
#endif // ASSIMP_BUILD_NO_STEPFILE_IMPORTER
|
||||
|
|
|
@ -48,7 +48,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <assimp/BaseImporter.h>
|
||||
|
||||
namespace Assimp {
|
||||
namespace STEP {
|
||||
namespace StepFile {
|
||||
|
||||
class StepFileImporter : public BaseImporter {
|
||||
public:
|
||||
|
@ -63,7 +63,7 @@ protected:
|
|||
private:
|
||||
};
|
||||
|
||||
} // Namespace STEP
|
||||
} // Namespace StepFile
|
||||
} // Namespace Assimp
|
||||
|
||||
#endif // ASSIMP_BUILD_NO_STEPFILE_IMPORTER
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -356,7 +356,7 @@ void GetImporterInstanceList(std::vector< BaseImporter* >& out)
|
|||
out.push_back( new MMDImporter() );
|
||||
#endif
|
||||
#ifndef ASSIMP_BUILD_NO_STEPFILE_IMPORTER
|
||||
out.push_back(new STEP::StepFileImporter());
|
||||
out.push_back(new StepFile::StepFileImporter());
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -164,7 +164,6 @@ namespace STEP {
|
|||
class DataType
|
||||
{
|
||||
public:
|
||||
|
||||
typedef std::shared_ptr<const DataType> Out;
|
||||
|
||||
public:
|
||||
|
@ -357,6 +356,18 @@ namespace STEP {
|
|||
MemberList members;
|
||||
};
|
||||
|
||||
class BINARY : public PrimitiveDataType<uint32_t> {
|
||||
public:
|
||||
BINARY(uint32_t val)
|
||||
: PrimitiveDataType<uint32_t>(val) {
|
||||
// empty
|
||||
}
|
||||
|
||||
BINARY()
|
||||
: PrimitiveDataType<uint32_t>(TypeError::ENTITY_NOT_SPECIFIED) {
|
||||
// empty
|
||||
}
|
||||
};
|
||||
|
||||
// -------------------------------------------------------------------------------
|
||||
/* Not exactly a full EXPRESS schema but rather a list of conversion functions
|
||||
|
|
|
@ -52,17 +52,23 @@ use_ifc_template = False
|
|||
|
||||
input_step_template_h = 'StepReaderGen.h.template'
|
||||
input_step_template_cpp = 'StepReaderGen.cpp.template'
|
||||
input_template_h = 'IFCReaderGen.h.template'
|
||||
input_template_cpp = 'IFCReaderGen.cpp.template'
|
||||
input_ifc_template_h = 'IFCReaderGen.h.template'
|
||||
input_ifc_template_cpp = 'IFCReaderGen.cpp.template'
|
||||
|
||||
cpp_keywords = "class"
|
||||
|
||||
output_file_h = ""
|
||||
output_file_cpp = ""
|
||||
if (use_ifc_template ):
|
||||
input_template_h = input_ifc_template_h
|
||||
input_template_cpp = input_ifc_template_cpp
|
||||
output_file_h = os.path.join('..','..','code','IFCReaderGen.h')
|
||||
output_file_cpp = os.path.join('..','..','code','IFCReaderGen.cpp')
|
||||
else:
|
||||
output_file_h = os.path.join('..','..','code','StepReaderGen.h')
|
||||
output_file_cpp = os.path.join('..','..','code','StepReaderGen.cpp')
|
||||
input_template_h = input_step_template_h
|
||||
input_template_cpp = input_step_template_cpp
|
||||
output_file_h = os.path.join('..','..','code/Importer/StepFile','StepReaderGen.h')
|
||||
output_file_cpp = os.path.join('..','..','code/Importer/StepFile','StepReaderGen.cpp')
|
||||
|
||||
template_entity_predef = '\tstruct {entity};\n'
|
||||
template_entity_predef_ni = '\ttypedef NotImplemented {entity}; // (not currently used by Assimp)\n'
|
||||
|
@ -109,7 +115,6 @@ template_converter_epilogue = '\treturn base;'
|
|||
|
||||
import ExpressReader
|
||||
|
||||
|
||||
def get_list_bounds(collection_spec):
|
||||
start,end = [(int(n) if n!='?' else 0) for n in re.findall(r'(\d+|\?)',collection_spec)]
|
||||
return start,end
|
||||
|
@ -254,12 +259,14 @@ def work(filename):
|
|||
schema.blacklist_partial -= schema.whitelist
|
||||
schema.whitelist |= schema.blacklist_partial
|
||||
|
||||
# Generate list with reserved keywords from c++
|
||||
cpp_types = cpp_keywords.split(',')
|
||||
|
||||
# uncomment this to disable automatic code reduction based on whitelisting all used entities
|
||||
# (blacklisted entities are those who are in the whitelist and may be instanced, but will
|
||||
# only be accessed through a pointer to a base-class.
|
||||
#schema.whitelist = set(schema.entities.keys())
|
||||
#schema.blacklist_partial = set()
|
||||
|
||||
for ntype in schema.types.values():
|
||||
typedefs += gen_type_struct(ntype,schema)
|
||||
schema_table.append(template_schema_type.format(normalized_name=ntype.name.lower()))
|
||||
|
@ -268,6 +275,9 @@ def work(filename):
|
|||
for entity in sorted_entities:
|
||||
parent = entity.parent+',' if entity.parent else ''
|
||||
|
||||
if ( entity.name in cpp_types ):
|
||||
entity.name = entity.name + "_t"
|
||||
print( "renaming " + entity.name)
|
||||
if entity.name in schema.whitelist:
|
||||
converters += template_converter.format(type=entity.name,contents=gen_converter(entity,schema))
|
||||
schema_table.append(template_schema.format(type=entity.name,normalized_name=entity.name.lower(),argcnt=len(entity.members)))
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (ASSIMP)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2010, ASSIMP Development Team
|
||||
Copyright (c) 2006-2018, ASSIMP Development Team
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
|
@ -40,7 +40,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
/** MACHINE-GENERATED by scripts/ICFImporter/CppGenerator.py */
|
||||
|
||||
#include "AssimpPCH.h"
|
||||
#ifndef ASSIMP_BUILD_NO_IFC_IMPORTER
|
||||
|
||||
#include "IFCReaderGen.h"
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (ASSIMP)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2010, ASSIMP Development Team
|
||||
Copyright (c) 2006-2018, ASSIMP Development Team
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
|
@ -40,13 +40,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
/** MACHINE-GENERATED by scripts/ICFImporter/CppGenerator.py */
|
||||
|
||||
#include "AssimpPCH.h"
|
||||
#ifndef ASSIMP_BUILD_NO_IFC_IMPORTER
|
||||
#ifndef ASSIMP_BUILD_NO_STEPFILE_IMPORTER
|
||||
|
||||
#include "StepReaderGen.h"
|
||||
#include "code/Importer/StepFile/StepReaderGen.h"
|
||||
|
||||
namespace Assimp {
|
||||
using namespace IFC;
|
||||
using namespace StepFile;
|
||||
|
||||
namespace {
|
||||
|
||||
|
@ -57,7 +56,7 @@ namespace {
|
|||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------------
|
||||
void IFC::GetSchema(EXPRESS::ConversionSchema& out)
|
||||
void StepFile::GetSchema(EXPRESS::ConversionSchema& out)
|
||||
{
|
||||
out = EXPRESS::ConversionSchema(schema_raw);
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (ASSIMP)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2010, ASSIMP Development Team
|
||||
Copyright (c) 2006-2018, ASSIMP Development Team
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
|
@ -40,13 +40,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
/** MACHINE-GENERATED by scripts/ICFImporter/CppGenerator.py */
|
||||
|
||||
#ifndef INCLUDED_IFC_READER_GEN_H
|
||||
#define INCLUDED_IFC_READER_GEN_H
|
||||
#ifndef INCLUDED_STEPFILE_READER_GEN_H
|
||||
#define INCLUDED_STEPFILE_READER_GEN_H
|
||||
|
||||
#include "STEPFile.h"
|
||||
#include "code/STEPFile.h"
|
||||
|
||||
namespace Assimp {
|
||||
namespace IFC {
|
||||
namespace StepFile {
|
||||
using namespace STEP;
|
||||
using namespace STEP::EXPRESS;
|
||||
|
||||
|
@ -57,14 +57,14 @@ namespace IFC {
|
|||
|
||||
|
||||
// ******************************************************************************
|
||||
// IFC Custom data types
|
||||
// StepFile Custom data types
|
||||
// ******************************************************************************
|
||||
|
||||
{types}
|
||||
|
||||
|
||||
// ******************************************************************************
|
||||
// IFC Entities
|
||||
// StepFile Entities
|
||||
// ******************************************************************************
|
||||
|
||||
{predefs}
|
||||
|
@ -72,7 +72,7 @@ namespace IFC {
|
|||
|
||||
void GetSchema(EXPRESS::ConversionSchema& out);
|
||||
|
||||
} //! IFC
|
||||
} //! StepFile
|
||||
namespace STEP {
|
||||
|
||||
// ******************************************************************************
|
||||
|
@ -88,4 +88,4 @@ namespace STEP {
|
|||
} //! STEP
|
||||
} //! Assimp
|
||||
|
||||
#endif // INCLUDED_IFC_READER_GEN_H
|
||||
#endif // INCLUDED_STEPFILE_READER_GEN_H
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
import sys
|
||||
|
||||
Entity_token = "ENTITY"
|
||||
Type_token = "TYPE"
|
||||
token = []
|
||||
file = open(sys.argv[1])
|
||||
output = open("step_entitylist.txt", "a")
|
||||
|
@ -55,6 +56,7 @@ for line in lines:
|
|||
name = token[1]
|
||||
print( "Writing entity " + name)
|
||||
output.write(name)
|
||||
|
||||
output.close()
|
||||
file.close()
|
||||
|
||||
|
|
Loading…
Reference in New Issue