Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong import .sat file #66

Open
dronov-dmitry opened this issue Apr 2, 2023 · 6 comments
Open

Wrong import .sat file #66

dronov-dmitry opened this issue Apr 2, 2023 · 6 comments
Assignees
Labels
enhancement Fixed Issue is fixed

Comments

@dronov-dmitry
Copy link

When i import this file:
https://disk.yandex.ru/d/cayCPNwgRm7w8A
by this plugin
It ask me convert to STEP and after that is wrong imported
Not like this
https://disk.yandex.ru/i/vXHWlYq3zwgfvQ
But like this
https://disk.yandex.ru/i/i4OKv9Xpj_0WJw

@dronov-dmitry dronov-dmitry changed the title Wrong import Wrong import .sat file Apr 2, 2023
@marcocecchiscmgroup
Copy link

marcocecchiscmgroup commented Apr 13, 2023

The reason is because the two smaller elements, the doors, have a non trivial transform from the ACIS which is not applied in the STEP conversion.

def _convertShell(acisShell, representation, shape, parentColor, transformation):
	# FIXME how to distinguish between open or closed shell?
	faces = acisShell.getFaces()
	if (len(faces) > 0):
		color = getColor(acisShell)
		defColor = parentColor if (color is None) else color
		shell = OPEN_SHELL('',[])
		for acisFace in faces:
			faces = _convertFace(acisFace, representation, defColor, representation.context)
			shell.faces += faces

			assignColor(defColor, shell, representation.context)
		return shell

	return None

@jmplonka
Copy link
Owner

Hello,

Thank you very much for the detailed explanation.

Best regards
Jens

@marcocecchiscmgroup
Copy link

marcocecchiscmgroup commented Apr 26, 2023

Jens, I think I understand why you didn't initially provide an implementation for transformations in STEP, as it is a real mess.
I have drafted an implementation that works for me based on:
ITEM_DEFINED_TRANSFORMATION, REPRESENTATION_RELATIONSHIP_WITH_TRANSFORMATION, SHAPE_REPRESENTATION_RELATIONSHIP,
CONTEXT_DEPENDENT_SHAPE_REPRESENTATION and the like

@jmplonka
Copy link
Owner

Hi Marco,
You got the point.
Please, could you share an example?
-Jens

@marcocecchiscmgroup
Copy link

That requires factoring out many arguments that you built implicitly.
Just check this out
Acis2Step.zip

@marcocecchiscmgroup
Copy link

As usual, I am using the -dbg stubs, so I am not sure that the official FreeCAD/Parts module implement Vector.rotate(), Rotation.axis() etc. Just in case;

class Rotation(object):
[...]
	def angle(self):
		return acos(self.w) * 2.0
	def axis(self):
		sin_theta_half = sin(self.angle() / 2.0)
		return Vector(self.x * sin_theta_half, self.y * sin_theta_half, self.z * sin_theta_half)
class Vector(object):
[...]
	def rotation_matrix(self, axis, angle):
		axis.normalize()
		a = cos(angle / 2.0)
		aa = a * a
		v = axis.reversed() * sin(angle / 2.0)
		b = v.x
		c = v.y
		d = v.z
		aa, bb, cc, dd = a * a, b * b, c * c, d * d
		bc, ad, ac, ab, bd, cd = b * c, a * d, a * c, a * b, b * d, c * d
		m11 = aa + bb - cc - dd
		m12 = 2 * (bc + ad)
		m13 = 2 * (bd - ac)
		m21 = 2 * (bc - ad)
		m22 = aa + cc - bb - dd
		m23 = 2 * (cd + ab)
		m31 = 2 * (bd + ac)
		m32 = 2 * (cd - ab)
		m33 = aa + dd - bb - cc
		return Matrix(m11, m12, m13, 0.0, m21, m22, m23, 0.0, m31, m32, m33, 0.0, 0.0, 0.0, 0.0, 0.0)
	def rotate(self, v, angle):
		return self.rotation_matrix(v, angle) * self
	def projectToLine(self, base, line):
		self = base * line / line.square_modulus() * line - base;
		return self

@jmplonka jmplonka self-assigned this Apr 29, 2023
@jmplonka jmplonka added enhancement Fixed Issue is fixed labels Apr 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Fixed Issue is fixed
Projects
None yet
Development

No branches or pull requests

3 participants