Skip to content

Commit

Permalink
Export alignment curve metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
QuimMoya committed Nov 27, 2023
1 parent 7bacdf3 commit dcc2253
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 5 deletions.
26 changes: 25 additions & 1 deletion src/wasm/geometry/IfcGeometryLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,8 @@ namespace webifc::geometry
_loader.MoveToArgumentOffset(expressID, 7);
double GravityCenterLineHeight = _loader.GetDoubleArgument();

std::string str(type);

switch (Horizontal_alignment_type.at(type))
{
default:
Expand All @@ -502,6 +504,9 @@ namespace webifc::geometry
curve.Add(EndPoint);

alignmentCurve = curve;
alignmentCurve.userData.push_back("TYPE: " + str);
alignmentCurve.userData.push_back("LENGHT: " + std::to_string(SegmentLength));
alignmentCurve.userData.push_back("DIRECTION: " + std::to_string(ifcStartDirection));

break;
}
Expand All @@ -521,6 +526,8 @@ namespace webifc::geometry
}

alignmentCurve = curve;
alignmentCurve.userData.push_back("TYPE: " + str);
alignmentCurve.userData.push_back("RADIUS: " + std::to_string(StartRadiusOfCurvature));

break;
}
Expand Down Expand Up @@ -622,6 +629,10 @@ namespace webifc::geometry
}

alignmentCurve = curve;
alignmentCurve.userData.push_back("TYPE: " + str);
alignmentCurve.userData.push_back("START RADIUS: " + std::to_string(StartRadiusOfCurvature));
alignmentCurve.userData.push_back("END RADIUS: " + std::to_string(EndRadiusOfCurvature));
alignmentCurve.userData.push_back("A: " + std::to_string(A));

break;
}
Expand Down Expand Up @@ -678,6 +689,8 @@ namespace webifc::geometry

IfcProfile profile;

std::string str(type);

switch (Vertical_alignment_type.at(type))
{
default:
Expand All @@ -696,7 +709,9 @@ namespace webifc::geometry
curve.Add(jPoint);

alignmentCurve = curve;

alignmentCurve.userData.push_back("TYPE: " + str);
alignmentCurve.userData.push_back("START HEIGHT: " + std::to_string(StartHeight));
alignmentCurve.userData.push_back("START GRADIENT: " + std::to_string(StartGradient));
break;
}
case 2: // ARC
Expand Down Expand Up @@ -727,6 +742,10 @@ namespace webifc::geometry
}

alignmentCurve = curve;
alignmentCurve.userData.push_back("TYPE: " + str);
alignmentCurve.userData.push_back("RADIUS: " + std::to_string(RadiusOfCurvature));
alignmentCurve.userData.push_back("START GRADIENT: " + std::to_string(StartGradient));
alignmentCurve.userData.push_back("END GRADIENT: " + std::to_string(EndGradient));

break;
}
Expand Down Expand Up @@ -756,6 +775,11 @@ namespace webifc::geometry
}

alignmentCurve = curve;
alignmentCurve.userData.push_back("TYPE: " + str);
alignmentCurve.userData.push_back("LENGHT: " + std::to_string(HorizontalLength));
alignmentCurve.userData.push_back("START GRADIENT: " + std::to_string(StartGradient));
alignmentCurve.userData.push_back("END GRADIENT: " + std::to_string(EndGradient));
alignmentCurve.userData.push_back("R: " + std::to_string(R));

break;
}
Expand Down
3 changes: 2 additions & 1 deletion src/wasm/geometry/representation/IfcCurve.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@ namespace webifc::geometry {
{
std::vector<glm::dvec3> points;
std::vector<uint16_t> indices;
std::vector<std::string> userData;
void Add(glm::dvec3 pt);
void Add(glm::dvec2 pt);
glm::dvec2 Get2d(size_t i) const;
glm::dvec3 Get3d(size_t i) const;
void Invert();
bool IsCCW() const;
glm::dmat4 getPlacementAtDistance(double length);

private:
static constexpr double EPS_TINY = 1e-9;
};
Expand Down
3 changes: 2 additions & 1 deletion src/wasm/web-ifc-api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1069,7 +1069,8 @@ EMSCRIPTEN_BINDINGS(my_module) {
emscripten::register_vector<webifc::geometry::IfcCurve>("IfcCurveVector");

emscripten::value_object<webifc::geometry::IfcCurve>("IfcCurve")
.field("points", &webifc::geometry::IfcCurve::points);
.field("points", &webifc::geometry::IfcCurve::points)
.field("userData", &webifc::geometry::IfcCurve::userData);

emscripten::register_vector<glm::vec<2, glm::f64>>("vector2doubleVector");

Expand Down
14 changes: 12 additions & 2 deletions src/web-ifc-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,12 @@ export class IfcAPI {
const newPoint = { x: pt.x, y: pt.y };
ptList.push(newPoint);
}
const newCurve = { points: ptList };
const dtList = [];
for (let p = 0; p < curve.userData.size(); p++) {
const dt = curve.userData.get(p);
dtList.push(dt);
}
const newCurve = { points: ptList, data: dtList };
horList.push(newCurve);
}
const verList = [];
Expand All @@ -828,7 +833,12 @@ export class IfcAPI {
const newPoint = { x: pt.x, y: pt.y };
ptList.push(newPoint);
}
const newCurve = { points: ptList };
const dtList = [];
for (let p = 0; p < curve.userData.size(); p++) {
const dt = curve.userData.get(p);
dtList.push(dt);
}
const newCurve = { points: ptList, data: dtList };
verList.push(newCurve);
}

Expand Down

0 comments on commit dcc2253

Please sign in to comment.