General Algorithm for Primitive Calculation?


RE: General Algorithm for Primitive Calculation?
#2
LDView is open source, and has primitive substitution for most LDraw primitives. Of course, it's in C++, and since it is using the values in-memory, it never rounds them, but it should be trivial to round to 4 decimal places (or whatever) during final output to the file. (You don't want to round anything except the final points written the file.)

The actual code in LDView is spread over a bunch of add... member functions in TREModel.cpp. Search for the following functions:
  • addSlopedCylinder
  • addSlopedCylinder2
  • addCylinder
  • addChrd
  • addDisc
  • addNotDisc
  • addCone
  • addTorusIO
  • addTorusIOConditionals
  • addEighthSphere
  • addEighthSphereConditionals
  • addOpenCone
  • addOpenConeConditionals
  • addSlopedCylinder2Conditionals
  • addCircularEdge
  • addRing
Note: numSegments would by 16 for typical LDraw; it's the total number of segments in a 360 degree circle; usedSegments is the number of segments to generate, so 4 for a quarter-circle when numSegments is 16.
Reply
« Next Oldest | Next Newest »



Messages In This Thread
RE: General Algorithm for Primitive Calculation? - by Travis Cobbs - 2016-08-11, 4:15

Forum Jump:


Users browsing this thread: 1 Guest(s)