Skip to content

Commit

Permalink
add nodes for handling greenhouses
Browse files Browse the repository at this point in the history
  • Loading branch information
Ylannl committed Jun 14, 2020
1 parent 60fd65f commit d7ba65b
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 28 deletions.
1 change: 1 addition & 0 deletions register.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,5 @@ void register_nodes(geoflow::NodeRegister& node_register) {
node_register.register_node<PolygonTriangulatorNode>("PolygonTriangulator");
node_register.register_node<FacesSelectorNode>("FacesSelector");
node_register.register_node<AttributeTesterNode>("AttributeTester");
node_register.register_node<AttrRingsSelectorNode>("AttrRingsSelector");
}
47 changes: 24 additions & 23 deletions src/stepedge_nodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -396,10 +396,10 @@ void PolygonGrowerNode::process(){
void Arr2LinearRingsNode::process(){
auto arr = input("arrangement").get<Arrangement_2>();

auto& floor_elevation = input("floor_elevation").get<float&>();
auto& mesh_error = input("mesh_error").get<float&>();
auto& roof_type = input("roof_type").get<int&>();
auto& arr_complexity = input("arr_complexity").get<int&>();
// auto& floor_elevation = input("floor_elevation").get<float&>();
// auto& mesh_error = input("mesh_error").get<float&>();
// auto& roof_type = input("roof_type").get<int&>();
// auto& arr_complexity = input("arr_complexity").get<int&>();
auto& attributes_in = poly_input("attributes");

auto& linear_rings = vector_output("linear_rings");
Expand All @@ -410,24 +410,24 @@ void Arr2LinearRingsNode::process(){
auto& oterm = poly_output("attributes").add_vector(iterm->get_name(), iterm->get_type());
input_attr_map[oterm.get_name()] = &oterm;
}
auto &floor_elevation_term = poly_output("attributes").add_vector("maaiveld_h", typeid(float));
input_attr_map["maaiveld_h"] = &floor_elevation_term;
auto &attr_error_term = poly_output("attributes").add_vector("rmse", typeid(float));
input_attr_map["rmse"] = &attr_error_term;
auto &attr_rooftype_term = poly_output("attributes").add_vector("dak_type", typeid(int));
input_attr_map["dak_type"] = &attr_rooftype_term;
auto &attr_elevation_term = poly_output("attributes").add_vector("hoogte_abs", typeid(float));
auto &attr_arr_complexity_term = poly_output("attributes").add_vector("arr_complexity", typeid(int));
input_attr_map["arr_complexity"] = &attr_arr_complexity_term;
// auto &floor_elevation_term = poly_output("attributes").add_vector("maaiveld_h", typeid(float));
// input_attr_map["maaiveld_h"] = &floor_elevation_term;
// auto &attr_error_term = poly_output("attributes").add_vector("rmse", typeid(float));
// input_attr_map["rmse"] = &attr_error_term;
// auto &attr_rooftype_term = poly_output("attributes").add_vector("dak_type", typeid(int));
// input_attr_map["dak_type"] = &attr_rooftype_term;
// auto &attr_arr_complexity_term = poly_output("attributes").add_vector("arr_complexity", typeid(int));
// input_attr_map["arr_complexity"] = &attr_arr_complexity_term;

// attributes specific to each roofpart
input_attr_map["hoogte_abs"] = &attr_elevation_term;
auto &attr_roofid_term = poly_output("attributes").add_vector("dak_id", typeid(int));
input_attr_map["dak_id"] = &attr_roofid_term;
auto &attr_elevation_term = poly_output("attributes").add_vector("roof_elevation", typeid(float));
input_attr_map["roof_elevation"] = &attr_elevation_term;
// auto &attr_roofid_term = poly_output("attributes").add_vector("dak_id", typeid(int));
// input_attr_map["dak_id"] = &attr_roofid_term;
// auto &attr_objectid_term = poly_output("attributes").add_vector("building_id", typeid(int));
// input_attr_map["building_id"] = &attr_objectid_term;

int j=0;
// int j=0;
auto& plane_a = vector_output("plane_a");
auto& plane_b = vector_output("plane_b");
auto& plane_c = vector_output("plane_c");
Expand All @@ -449,16 +449,16 @@ void Arr2LinearRingsNode::process(){
plane_d.push_back(float(CGAL::to_double(face->data().plane.d())));

// attributes specific to each roofpart
input_attr_map["hoogte_abs"]->push_back((float)face->data().elevation_avg);
input_attr_map["roof_elevation"]->push_back((float)face->data().elevation_avg);

input_attr_map["dak_id"]->push_back((int)++j);
// input_attr_map["dak_id"]->push_back((int)++j);
// input_attr_map["building_id"]->push_back(int(i+1));

//attributes not specific to roofpart
input_attr_map["rmse"]->push_back((float)mesh_error);
input_attr_map["maaiveld_h"]->push_back((float)floor_elevation);
input_attr_map["dak_type"]->push_back((int)roof_type);
input_attr_map["arr_complexity"]->push_back(arr_complexity);
// input_attr_map["rmse"]->push_back((float)mesh_error);
// input_attr_map["maaiveld_h"]->push_back((float)floor_elevation);
// input_attr_map["dak_type"]->push_back((int)roof_type);
// input_attr_map["arr_complexity"]->push_back(arr_complexity);
for (auto &iterm : poly_input("attributes").sub_terminals()) {
input_attr_map[iterm->get_name()]->push_back_any(iterm->get_data());
}
Expand Down Expand Up @@ -2311,6 +2311,7 @@ void DetectPlanesNode::process() {
output("roof_type").set(building_type);
output("horiz_roofplane_cnt").set(float(horiz_roofplane_cnt));
output("slant_roofplane_cnt").set(float(slant_roofplane_cnt));
output("total_roofplane_cnt").set(int(horiz_roofplane_cnt+slant_roofplane_cnt));
output("roof_pt_cnt").set((int)total_pt_cnt);

vec1i plane_id, is_wall, is_horizontal;
Expand Down
58 changes: 53 additions & 5 deletions src/stepedge_nodes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ namespace geoflow::nodes::stepedge {
void init() {
// add_input("points", TT_any);
add_input("pts_per_roofplane", typeid(IndexedPlanesWithPoints ));
add_input("skip", typeid(bool));
add_output("alpha_rings", typeid(LinearRingCollection));
add_output("edge_points", typeid(PointCollection));
add_output("alpha_edges", typeid(LineStringCollection));
Expand All @@ -66,6 +67,14 @@ namespace geoflow::nodes::stepedge {
add_param(ParamBool(optimal_alpha, "optimal_alpha", "optimal_alpha"));
add_param(ParamBool(optimal_only_if_needed, "optimal_only_if_needed", "optimal_only_if_needed"));
}

bool inputs_valid() {
auto& skipInput = input("skip");
if (skipInput.has_data() && input("pts_per_roofplane").has_data()) {
return !skipInput.get<bool>();
}
return false;
}

// void before_gui(){
// auto param = std::get<ParamBool>(parameters.at("optimal_only_if_needed"));
Expand Down Expand Up @@ -134,10 +143,10 @@ namespace geoflow::nodes::stepedge {
using Node::Node;
void init() {
add_vector_input("arrangement", typeid(Arrangement_2));
add_vector_input("floor_elevation", typeid(float));
add_vector_input("mesh_error", typeid(float));
add_vector_input("roof_type", typeid(int));
add_vector_input("arr_complexity", typeid(int));
// add_vector_input("floor_elevation", typeid(float));
// add_vector_input("mesh_error", typeid(float));
// add_vector_input("roof_type", typeid(int));
// add_vector_input("arr_complexity", typeid(int));
add_poly_input("attributes", {typeid(bool), typeid(int), typeid(float), typeid(std::string)});
add_poly_output("attributes", {typeid(bool), typeid(int), typeid(float), typeid(std::string)});
add_vector_output("linear_rings", typeid(LinearRing));
Expand Down Expand Up @@ -511,6 +520,7 @@ namespace geoflow::nodes::stepedge {
add_output("roof_elevation", typeid(float));
add_output("horiz_roofplane_cnt", typeid(float));
add_output("slant_roofplane_cnt", typeid(float));
add_output("total_roofplane_cnt", typeid(int));
add_output("plane_adj", typeid(std::map<size_t, std::map<size_t, size_t>>));

add_param(ParamBool(only_horizontal, "only_horizontal", "Output only horizontal planes"));
Expand Down Expand Up @@ -847,7 +857,6 @@ namespace geoflow::nodes::stepedge {
};

class FacesSelectorNode:public Node {
// float dupe_threshold = 1E-5;
public:
using Node::Node;
bool inputs_valid() {
Expand Down Expand Up @@ -907,4 +916,43 @@ namespace geoflow::nodes::stepedge {
};
};

class AttrRingsSelectorNode:public Node {
public:
using Node::Node;
bool inputs_valid() {
auto& selectInput = input("selectAB");
if (!selectInput.has_data()) {
return false;
} else {
bool selectAB = selectInput.get<bool>();
if (selectAB) {
return vector_input("linear_rings_A").has_data() && poly_input("attributes_A").has_data();
} else {
return vector_input("linear_rings_B").has_data() && poly_input("attributes_B").has_data();
}
}
}
void init() {
add_input("selectAB", typeid(bool));
add_vector_input("linear_rings_A", typeid(LinearRing));
add_vector_input("linear_rings_B", typeid(LinearRing));
add_poly_input("attributes_A", {typeid(bool), typeid(int), typeid(float), typeid(std::string)});
add_poly_input("attributes_B", {typeid(bool), typeid(int), typeid(float), typeid(std::string)});

add_vector_output("linear_rings", typeid(LinearRing));
add_poly_output("attributes", {typeid(bool), typeid(int), typeid(float), typeid(std::string)});
}
void process() {
auto selectAB = input("selectAB").get<bool>();
auto& out_attributes = poly_output("attributes");
if (selectAB) {
vector_output("linear_rings") = vector_input("linear_rings_A").get_data_vec();
out_attributes = poly_input("attributes_A");
} else {
vector_output("linear_rings") = vector_input("linear_rings_B").get_data_vec();
out_attributes = poly_input("attributes_B");
}
};
};

}

0 comments on commit d7ba65b

Please sign in to comment.