mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-20 15:08:51 +00:00
IfcGeomServer settings
This commit is contained in:
@@ -113,6 +113,8 @@ const int32_t NEXT = MORE + 1;
|
|||||||
const int32_t BYE = NEXT + 1;
|
const int32_t BYE = NEXT + 1;
|
||||||
const int32_t GET_LOG = BYE + 1;
|
const int32_t GET_LOG = BYE + 1;
|
||||||
const int32_t LOG = GET_LOG + 1;
|
const int32_t LOG = GET_LOG + 1;
|
||||||
|
const int32_t DEFLECTION = LOG + 1;
|
||||||
|
const int32_t SETTING = DEFLECTION + 1;
|
||||||
|
|
||||||
class Hello : public Command {
|
class Hello : public Command {
|
||||||
private:
|
private:
|
||||||
@@ -126,7 +128,7 @@ protected:
|
|||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
const std::string& string() { return str; }
|
const std::string& string() { return str; }
|
||||||
Hello() : Command(HELLO), str("IfcOpenShell-" IFCOPENSHELL_VERSION) {}
|
Hello() : Command(HELLO), str("IfcOpenShell-" IFCOPENSHELL_VERSION "-2") {}
|
||||||
};
|
};
|
||||||
|
|
||||||
class More : public Command {
|
class More : public Command {
|
||||||
@@ -286,6 +288,40 @@ public:
|
|||||||
Bye() : Command(BYE) {};
|
Bye() : Command(BYE) {};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class Deflection : public Command {
|
||||||
|
private:
|
||||||
|
double deflection_;
|
||||||
|
protected:
|
||||||
|
void read_content(std::istream& s) {
|
||||||
|
deflection_ = sread<double>(s);
|
||||||
|
}
|
||||||
|
void write_content(std::ostream& s) {
|
||||||
|
swrite(s, deflection_);
|
||||||
|
}
|
||||||
|
public:
|
||||||
|
Deflection(double d = 0.) : Command(DEFLECTION), deflection_(d) {};
|
||||||
|
double deflection() const { return deflection_; }
|
||||||
|
};
|
||||||
|
|
||||||
|
class Setting : public Command {
|
||||||
|
private:
|
||||||
|
uint32_t id_;
|
||||||
|
uint32_t value_;
|
||||||
|
protected:
|
||||||
|
void read_content(std::istream& s) {
|
||||||
|
id_ = sread<uint32_t>(s);
|
||||||
|
value_ = sread<uint32_t>(s);
|
||||||
|
}
|
||||||
|
void write_content(std::ostream& s) {
|
||||||
|
swrite(s, id_);
|
||||||
|
swrite(s, value_);
|
||||||
|
}
|
||||||
|
public:
|
||||||
|
Setting(uint32_t k = 0, uint32_t v = 0) : Command(DEFLECTION), id_(k), value_(v) {};
|
||||||
|
uint32_t id() const { return id_; }
|
||||||
|
uint32_t value() const { return value_; }
|
||||||
|
};
|
||||||
|
|
||||||
int main () {
|
int main () {
|
||||||
// Redirect stdout to this stream, so that involuntary
|
// Redirect stdout to this stream, so that involuntary
|
||||||
// writes to stdout do not interfere with our protocol.
|
// writes to stdout do not interfere with our protocol.
|
||||||
@@ -301,9 +337,11 @@ int main () {
|
|||||||
std::cin.setf(std::ios_base::binary);
|
std::cin.setf(std::ios_base::binary);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
double deflection = 1.e-3;
|
||||||
bool has_more = false;
|
bool has_more = false;
|
||||||
|
|
||||||
IfcGeom::Iterator<float>* iterator = 0;
|
IfcGeom::Iterator<float>* iterator = 0;
|
||||||
|
std::vector< std::pair<uint32_t, uint32_t> > setting_pairs;
|
||||||
|
|
||||||
Hello().write(std::cout);
|
Hello().write(std::cout);
|
||||||
|
|
||||||
@@ -323,6 +361,13 @@ int main () {
|
|||||||
settings.set(IfcGeom::IteratorSettings::CONVERT_BACK_UNITS, true);
|
settings.set(IfcGeom::IteratorSettings::CONVERT_BACK_UNITS, true);
|
||||||
settings.set(IfcGeom::IteratorSettings::INCLUDE_CURVES, true);
|
settings.set(IfcGeom::IteratorSettings::INCLUDE_CURVES, true);
|
||||||
|
|
||||||
|
std::vector< std::pair<uint32_t, uint32_t> >::const_iterator it = setting_pairs.begin();
|
||||||
|
for (; it != setting_pairs.end(); ++it) {
|
||||||
|
settings.set(it->first, it->second != 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
settings.set_deflection_tolerance(deflection);
|
||||||
|
|
||||||
iterator = new IfcGeom::Iterator<float>(settings, data, (int)len);
|
iterator = new IfcGeom::Iterator<float>(settings, data, (int)len);
|
||||||
has_more = iterator->initialize();
|
has_more = iterator->initialize();
|
||||||
|
|
||||||
@@ -359,7 +404,27 @@ int main () {
|
|||||||
exit_code = 0;
|
exit_code = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
case DEFLECTION: {
|
||||||
|
Deflection d; d.read(std::cin);
|
||||||
|
if (!iterator) {
|
||||||
|
deflection = d.deflection();
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
exit_code = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case SETTING: {
|
||||||
|
Setting s; s.read(std::cin);
|
||||||
|
if (!iterator) {
|
||||||
|
setting_pairs.push_back(std::make_pair(s.id(), s.value()));
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
exit_code = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
default:
|
||||||
exit_code = 1;
|
exit_code = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user