mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-10 06:00:51 +00:00
Implement --use-names and --use-guids for DAE, OBJ, and SVG output.
This commit is contained in:
@@ -72,17 +72,17 @@ namespace IfcGeom
|
||||
/// model in other modelling application in any case.
|
||||
//NO_NORMALS = 1 << 11,
|
||||
/// Use entity names instead of unique IDs for naming objects and materials.
|
||||
/// Applicable for .obj and .dae output.
|
||||
//USE_NAMES = 1 << 12,
|
||||
/// Applicable for OBJ, DAE, and SVG output.
|
||||
USE_NAMES = 1 << 12,
|
||||
/// Use entity GUIDs instead of unique IDs for naming objects.
|
||||
/// Overrides possible usage of --use-names for objects but not for materials.
|
||||
/// Applicable for .obj and .dae output.
|
||||
//USE_GUIDS = 1 << 13,
|
||||
/// Applicable for OBJ, DAE, and SVG output.
|
||||
USE_GUIDS = 1 << 13,
|
||||
/// Centers the models upon serialization by the applying the center point of
|
||||
/// the scene bounds as an offset. Applicable only for .dae output currently.
|
||||
//CENTER_MODEL = 1 << 14,
|
||||
/// Generates UVs by using simple box projection. Requires normals.
|
||||
/// Applicable only for .dae output currently.
|
||||
/// Applicable only for DAE output currently.
|
||||
//GENERATE_UVS = 1 << 15,
|
||||
//NUM_SETTINGS = 15
|
||||
};
|
||||
|
||||
@@ -30,5 +30,6 @@ const double* IfcGeom::Material::diffuse() const { if (hasDiffuse()) return &((*
|
||||
const double* IfcGeom::Material::specular() const { if (hasSpecular()) return &((*style->Specular()).R()); else return black; }
|
||||
double IfcGeom::Material::transparency() const { if (hasTransparency()) return *style->Transparency(); else return 0; }
|
||||
double IfcGeom::Material::specularity() const { if (hasSpecularity()) return *style->Specularity(); else return 0; }
|
||||
const std::string IfcGeom::Material::name() const { return style->Name(); }
|
||||
const std::string &IfcGeom::Material::name() const { return style->Name(); }
|
||||
const std::string &IfcGeom::Material::original_name() const { return style->original_name(); }
|
||||
bool IfcGeom::Material::operator==(const IfcGeom::Material& other) const { return style == other.style; }
|
||||
|
||||
@@ -41,10 +41,11 @@ namespace IfcGeom {
|
||||
const double* specular() const;
|
||||
double transparency() const;
|
||||
double specularity() const;
|
||||
const std::string name() const;
|
||||
const std::string &name() const;
|
||||
const std::string &original_name() const;
|
||||
bool operator==(const Material& other) const;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -44,22 +44,22 @@ namespace IfcGeom {
|
||||
double& B() { return data[2]; }
|
||||
};
|
||||
private:
|
||||
std::string original_name_;
|
||||
boost::optional<std::string> name;
|
||||
boost::optional<int> id;
|
||||
boost::optional<ColorComponent> diffuse, specular;
|
||||
boost::optional<double> transparency;
|
||||
boost::optional<double> specularity;
|
||||
public:
|
||||
SurfaceStyle() {
|
||||
this->name = "surface-style";
|
||||
}
|
||||
SurfaceStyle() : name("surface-style") {}
|
||||
SurfaceStyle(int id) : id(id) {
|
||||
std::stringstream sstr;
|
||||
sstr << "surface-style-" << id;
|
||||
this->name = sstr.str();
|
||||
}
|
||||
SurfaceStyle(const std::string& name) : name(name) {}
|
||||
SurfaceStyle(int id, const std::string& name) : id(id) {
|
||||
SurfaceStyle(const std::string& name) : name(name), original_name_(name) {}
|
||||
SurfaceStyle(int id, const std::string& name) : id(id), original_name_(name)
|
||||
{
|
||||
std::stringstream sstr;
|
||||
std::string sanitized = name;
|
||||
std::transform(sanitized.begin(), sanitized.end(), sanitized.begin(), ::tolower);
|
||||
@@ -72,7 +72,7 @@ namespace IfcGeom {
|
||||
// architecture can just as easily be accomplished by comparing the
|
||||
// pointer addresses of the styles, as they are always referenced
|
||||
// from out of a global map of some sort.
|
||||
bool operator==(const SurfaceStyle& other) {
|
||||
bool operator==(const SurfaceStyle& other) const {
|
||||
if (name && other.name) {
|
||||
return *name == *other.name;
|
||||
} else if (id && other.id) {
|
||||
@@ -82,7 +82,10 @@ namespace IfcGeom {
|
||||
}
|
||||
}
|
||||
|
||||
const std::string& Name() const { return *name; }
|
||||
/// ID name, e.g. "surface-style-66675-metal---aluminium"
|
||||
const std::string& Name() const { return *name; }
|
||||
/// Original name, if available, e.g. "Metal - Aluminium"
|
||||
const std::string& original_name() const { return original_name_; }
|
||||
|
||||
const boost::optional<ColorComponent>& Diffuse() const { return diffuse; }
|
||||
const boost::optional<ColorComponent>& Specular() const { return specular; }
|
||||
@@ -97,4 +100,4 @@ namespace IfcGeom {
|
||||
const SurfaceStyle* get_default_style(const std::string& ifc_type);
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user