MCPcopy Create free account
hub / github.com/assimp/assimp / ProcessRevolvedAreaSolid

Function ProcessRevolvedAreaSolid

code/AssetLib/IFC/IFCGeometry.cpp:210–294  ·  view source on GitHub ↗

------------------------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

208
209// ------------------------------------------------------------------------------------------------
210void ProcessRevolvedAreaSolid(const Schema_2x3::IfcRevolvedAreaSolid& solid, TempMesh& result, ConversionData& conv) {
211 TempMesh meshout;
212
213 // first read the profile description
214 if(!ProcessProfile(*solid.SweptArea,meshout,conv) || meshout.mVerts.size()<=1) {
215 return;
216 }
217
218 IfcVector3 axis, pos;
219 ConvertAxisPlacement(axis,pos,solid.Axis);
220
221 IfcMatrix4 tb0,tb1;
222 IfcMatrix4::Translation(pos,tb0);
223 IfcMatrix4::Translation(-pos,tb1);
224
225 const std::vector<IfcVector3>& in = meshout.mVerts;
226 const size_t size=in.size();
227
228 bool has_area = solid.SweptArea->ProfileType == "AREA" && size>2;
229 const IfcFloat max_angle = solid.Angle*conv.angle_scale;
230 if(std::fabs(max_angle) < 1e-3) {
231 if(has_area) {
232 result = meshout;
233 }
234 return;
235 }
236
237 const unsigned int cnt_segments =
238 std::max(2u,static_cast<unsigned int>(conv.settings.cylindricalTessellation * std::fabs(max_angle)/AI_MATH_HALF_PI_F));
239 const IfcFloat delta = max_angle/cnt_segments;
240
241 has_area = has_area && std::fabs(max_angle) < AI_MATH_TWO_PI_F*0.99;
242
243 result.mVerts.reserve(size*((cnt_segments+1)*4+(has_area?2:0)));
244 result.mVertcnt.reserve(size*cnt_segments+2);
245
246 IfcMatrix4 rot;
247 rot = tb0 * IfcMatrix4::Rotation(delta,axis,rot) * tb1;
248
249 size_t base = 0;
250 std::vector<IfcVector3>& out = result.mVerts;
251
252 // dummy data to simplify later processing
253 for(size_t i = 0; i < size; ++i) {
254 out.insert(out.end(),4,in[i]);
255 }
256
257 for(unsigned int seg = 0; seg < cnt_segments; ++seg) {
258 for(size_t i = 0; i < size; ++i) {
259 const size_t next = (i+1)%size;
260
261 result.mVertcnt.push_back(4);
262 const IfcVector3 base_0 = out[base+i*4+3],base_1 = out[base+next*4+3];
263
264 out.push_back(base_0);
265 out.push_back(base_1);
266 out.push_back(rot*base_1);
267 out.push_back(rot*base_0);

Callers 1

ProcessSweptAreaSolidFunction · 0.85

Calls 12

ProcessProfileFunction · 0.85
ConvertAxisPlacementFunction · 0.85
TranslationClass · 0.85
RotationClass · 0.85
eraseMethod · 0.80
maxFunction · 0.50
sizeMethod · 0.45
reserveMethod · 0.45
endMethod · 0.45
push_backMethod · 0.45
beginMethod · 0.45
TransformMethod · 0.45

Tested by

no test coverage detected