A limited attempt at some const correctness in the IfcGeomObjects interface

This commit is contained in:
Thomas Krijnen
2013-05-11 10:03:20 +00:00
parent 80bc1b5dab
commit dccbccfa06
8 changed files with 302 additions and 117 deletions
+2 -1
View File
@@ -270,7 +270,8 @@ void ColladaSerializer::writeHeader() {
}
void ColladaSerializer::writeTesselated(const IfcGeomObjects::IfcGeomObject* o) {
exporter.writeTesselated(o->guid, o->name, o->type, o->id, o->matrix, o->mesh->verts, o->mesh->normals, o->mesh->faces, o->mesh->materials, o->mesh->surface_styles);
const IfcGeomObjects::IfcRepresentationTriangulation& mesh = o->mesh();
exporter.writeTesselated(o->guid(), o->name(), o->type(), o->id(), o->matrix(), mesh.verts(), mesh.normals(), mesh.faces(), mesh.materials(), mesh.surface_styles());
}
void ColladaSerializer::finalize() {
+1 -1
View File
@@ -237,7 +237,7 @@ int main(int argc, char** argv) {
geom_object = IfcGeomObjects::GetShapeModel();
}
std::string lowercase_type = geom_object->type;
std::string lowercase_type = geom_object->type();
for (std::string::iterator c = lowercase_type.begin(); c != lowercase_type.end(); ++c) {
*c = tolower(*c);
}
+10 -2
View File
@@ -35,9 +35,17 @@ bool OpenCascadeBasedSerializer::ready() {
}
void OpenCascadeBasedSerializer::writeShapeModel(const IfcGeomObjects::IfcGeomShapeModelObject* o) {
for (IfcGeom::IfcRepresentationShapeItems::const_iterator it = o->mesh->begin(); it != o->mesh->end(); ++ it) {
for (IfcGeom::IfcRepresentationShapeItems::const_iterator it = o->mesh().begin(); it != o->mesh().end(); ++ it) {
gp_GTrsf gtrsf = it->Placement();
gtrsf.PreMultiply(o->trsf);
// TODO:
gp_GTrsf o_trsf;
int k = 0;
for( int i = 1; i < 5; ++ i )
for ( int j = 1; j < 4; ++ j )
o_trsf.SetValue(j, i, o->matrix()[k++]);
gtrsf.PreMultiply(o_trsf);
const TopoDS_Shape& s = it->Shape();
bool trsf_valid = false;
+10 -8
View File
@@ -64,18 +64,20 @@ void WaveFrontOBJSerializer::writeMaterial(const IfcGeom::SurfaceStyle& style) {
}
}
void WaveFrontOBJSerializer::writeTesselated(const IfcGeomObjects::IfcGeomObject* o) {
const std::string name = o->name.empty() ? o->guid : o->name;
const std::string name = o->name().empty() ? o->guid() : o->name();
obj_stream << "g " << name << std::endl;
obj_stream << "s 1" << std::endl;
const IfcGeomObjects::IfcRepresentationTriangulation& mesh = o->mesh();
const int vcount = o->mesh->verts.size() / 3;
for ( std::vector<float>::const_iterator it = o->mesh->verts.begin(); it != o->mesh->verts.end(); ) {
const int vcount = mesh.verts().size() / 3;
for ( std::vector<float>::const_iterator it = mesh.verts().begin(); it != mesh.verts().end(); ) {
const double x = *(it++);
const double y = *(it++);
const double z = *(it++);
obj_stream << "v " << x << " " << y << " " << z << std::endl;
}
for ( std::vector<float>::const_iterator it = o->mesh->normals.begin(); it != o->mesh->normals.end(); ) {
for ( std::vector<float>::const_iterator it = mesh.normals().begin(); it != mesh.normals().end(); ) {
const double x = *(it++);
const double y = *(it++);
const double z = *(it++);
@@ -83,17 +85,17 @@ void WaveFrontOBJSerializer::writeTesselated(const IfcGeomObjects::IfcGeomObject
}
int previous_material_id = -2;
std::vector<int>::const_iterator material_it = o->mesh->materials.begin();
std::vector<int>::const_iterator material_it = mesh.materials().begin();
for ( std::vector<int>::const_iterator it = o->mesh->faces.begin(); it != o->mesh->faces.end(); ) {
for ( std::vector<int>::const_iterator it = mesh.faces().begin(); it != mesh.faces().end(); ) {
const int material_id = *(material_it++);
if (material_id != previous_material_id) {
const IfcGeom::SurfaceStyle* material_style = 0;
if (material_id >= 0) {
material_style = o->mesh->surface_styles[material_id];
material_style = mesh.surface_styles()[material_id];
} else {
material_style = IfcGeom::get_default_style(o->type);
material_style = IfcGeom::get_default_style(o->type());
}
const std::string material_name = material_style->Name();
obj_stream << "usemtl " << material_name << std::endl;