diff --git a/register.hpp b/register.hpp index b367e29..ed8cb90 100644 --- a/register.hpp +++ b/register.hpp @@ -38,4 +38,5 @@ void register_nodes(geoflow::NodeRegister& node_register) { node_register.register_node("PolygonTriangulator"); node_register.register_node("FacesSelector"); node_register.register_node("AttributeTester"); + node_register.register_node("AttrRingsSelector"); } \ No newline at end of file diff --git a/src/stepedge_nodes.cpp b/src/stepedge_nodes.cpp index df3d08d..a0daddd 100644 --- a/src/stepedge_nodes.cpp +++ b/src/stepedge_nodes.cpp @@ -396,10 +396,10 @@ void PolygonGrowerNode::process(){ void Arr2LinearRingsNode::process(){ auto arr = input("arrangement").get(); - auto& floor_elevation = input("floor_elevation").get(); - auto& mesh_error = input("mesh_error").get(); - auto& roof_type = input("roof_type").get(); - auto& arr_complexity = input("arr_complexity").get(); + // auto& floor_elevation = input("floor_elevation").get(); + // auto& mesh_error = input("mesh_error").get(); + // auto& roof_type = input("roof_type").get(); + // auto& arr_complexity = input("arr_complexity").get(); auto& attributes_in = poly_input("attributes"); auto& linear_rings = vector_output("linear_rings"); @@ -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"); @@ -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()); } @@ -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; diff --git a/src/stepedge_nodes.hpp b/src/stepedge_nodes.hpp index f5d7b0e..61faa4d 100644 --- a/src/stepedge_nodes.hpp +++ b/src/stepedge_nodes.hpp @@ -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)); @@ -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(); + } + return false; + } // void before_gui(){ // auto param = std::get(parameters.at("optimal_only_if_needed")); @@ -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)); @@ -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>)); add_param(ParamBool(only_horizontal, "only_horizontal", "Output only horizontal planes")); @@ -847,7 +857,6 @@ namespace geoflow::nodes::stepedge { }; class FacesSelectorNode:public Node { - // float dupe_threshold = 1E-5; public: using Node::Node; bool inputs_valid() { @@ -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(); + 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(); + 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"); + } + }; + }; + } \ No newline at end of file