- Ifc: improved subsampling of curves for IfcSweptDiskSolid entities.
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@1288 67173fc5-114c-0410-ac8e-9d2fd5bffc1fpull/8/head
parent
d7410e6f08
commit
d7fe61c255
|
@ -424,6 +424,12 @@ public:
|
||||||
return base->EstimateSampleCount(TrimParam(a),TrimParam(b));
|
return base->EstimateSampleCount(TrimParam(a),TrimParam(b));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------
|
||||||
|
void SampleDiscrete(TempMesh& out,IfcFloat a,IfcFloat b) const {
|
||||||
|
ai_assert(InRange(a) && InRange(b));
|
||||||
|
return base->SampleDiscrete(out,TrimParam(a),TrimParam(b));
|
||||||
|
}
|
||||||
|
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
ParamRange GetParametricRange() const {
|
ParamRange GetParametricRange() const {
|
||||||
return std::make_pair(static_cast<IfcFloat>( 0. ),maxval);
|
return std::make_pair(static_cast<IfcFloat>( 0. ),maxval);
|
||||||
|
|
|
@ -560,13 +560,19 @@ void ProcessSweptDiskSolid(const IfcSweptDiskSolid solid, TempMesh& result, Conv
|
||||||
result.verts.reserve(cnt_segments * samples * 4);
|
result.verts.reserve(cnt_segments * samples * 4);
|
||||||
result.vertcnt.reserve((cnt_segments - 1) * samples);
|
result.vertcnt.reserve((cnt_segments - 1) * samples);
|
||||||
|
|
||||||
// XXX while EstimateSampleCount() works well for non-composite curves, it
|
std::vector<IfcVector3> points;
|
||||||
// fails badly for composite curves that require non-uniform sampling
|
points.reserve(cnt_segments * samples);
|
||||||
// for good results.
|
|
||||||
IfcFloat p = solid.StartParam, delta = (solid.EndParam-solid.StartParam)/ (samples - 1);
|
|
||||||
|
|
||||||
|
TempMesh temp;
|
||||||
|
curve->SampleDiscrete(temp,solid.StartParam,solid.EndParam);
|
||||||
|
const std::vector<IfcVector3>& curve_points = temp.verts;
|
||||||
|
|
||||||
IfcVector3 current = curve->Eval(p);
|
if(curve_points.empty()) {
|
||||||
|
IFCImporter::LogWarn("curve evaluation yielded no points (IfcSweptDiskSolid)");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
IfcVector3 current = curve_points[0];
|
||||||
IfcVector3 previous = current;
|
IfcVector3 previous = current;
|
||||||
IfcVector3 next;
|
IfcVector3 next;
|
||||||
|
|
||||||
|
@ -575,15 +581,12 @@ void ProcessSweptDiskSolid(const IfcSweptDiskSolid solid, TempMesh& result, Conv
|
||||||
startvec.y = 1.0f;
|
startvec.y = 1.0f;
|
||||||
startvec.z = 1.0f;
|
startvec.z = 1.0f;
|
||||||
|
|
||||||
std::vector<IfcVector3> points;
|
|
||||||
points.reserve(cnt_segments * samples);
|
|
||||||
|
|
||||||
p += delta;
|
|
||||||
|
|
||||||
// generate circles at the sweep positions
|
// generate circles at the sweep positions
|
||||||
for(size_t i = 0; i < samples; ++i, p += delta) {
|
for(size_t i = 0; i < samples; ++i) {
|
||||||
|
|
||||||
next = curve->Eval(p);
|
if(i != samples - 1) {
|
||||||
|
next = curve_points[i + 1];
|
||||||
|
}
|
||||||
|
|
||||||
// get a direction vector reflecting the approximate curvature (i.e. tangent)
|
// get a direction vector reflecting the approximate curvature (i.e. tangent)
|
||||||
IfcVector3 d = (current-previous) + (next-previous);
|
IfcVector3 d = (current-previous) + (next-previous);
|
||||||
|
|
|
@ -154,7 +154,7 @@ void IFCImporter::SetupProperties(const Importer* pImp)
|
||||||
settings.skipCurveRepresentations = pImp->GetPropertyBool(AI_CONFIG_IMPORT_IFC_SKIP_CURVE_REPRESENTATIONS,true);
|
settings.skipCurveRepresentations = pImp->GetPropertyBool(AI_CONFIG_IMPORT_IFC_SKIP_CURVE_REPRESENTATIONS,true);
|
||||||
settings.useCustomTriangulation = pImp->GetPropertyBool(AI_CONFIG_IMPORT_IFC_CUSTOM_TRIANGULATION,true);
|
settings.useCustomTriangulation = pImp->GetPropertyBool(AI_CONFIG_IMPORT_IFC_CUSTOM_TRIANGULATION,true);
|
||||||
|
|
||||||
settings.conicSamplingAngle = 10.f;
|
settings.conicSamplingAngle = 5.f;
|
||||||
settings.skipAnnotations = true;
|
settings.skipAnnotations = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue