OpenJSCAD.org icon indicating copy to clipboard operation
OpenJSCAD.org copied to clipboard

connectors do not work, not very compatible with V2

Open SimonClark opened this issue 4 years ago • 14 comments

Expected Behavior

Connectors store additional vector metadata in a way that will be very fragile in V2, currently destroyed by any transform, colorize, etc method, even if they did get stored properly in the first place.

Recommend we remove them from the public api, and reconsider if they are worth putting back in at some point.

SimonClark avatar Sep 09 '20 02:09 SimonClark

I like the connectors as a concept, but have not used them in V1 ... if they are problematic right now. It can be worth it to remove them temporarily, to be done "properly" later on.

hrgdavor avatar Sep 09 '20 09:09 hrgdavor

FYI, V1 connectors were added to primitives. For example, the eight sides of a cube each had a connector. However, designs don’t connect cubes to cylinders, etc. And, using the connectors required knowing the exact connectors being used to connect geometry, which was also almost impossible. And connectors were lost if any boolean operations were performed. Etc. Etc. Etc.

So, yeah. I support the retirement of connectors.

I think these could be used inside other functions like aligning the faces of two shapes and connecting those shapes together.

z3dev avatar Sep 09 '20 10:09 z3dev

As someone who uses connecters a good bit, I hope they stay in. For me, connectors are an indispensable part of aligning and positioning complex objects.

johnwebbcole avatar Sep 09 '20 13:09 johnwebbcole

ok, excellent to know, @johnwebbcole . We should have a discussion on how you use them, perhaps some example projects, if you'd be willing to share. For example, do you always use ones you manually create, or do you use the ones that are create for cubes?

If they are useful, let's aim to keep them. If they are fundamentally broken currently, we can take them out temporarily.

SimonClark avatar Sep 09 '20 14:09 SimonClark

@SimonClark here's an example: https://gitlab.com/johnwebbcole/window-motor

I use both my own and the ones on the primitives (mostly on cylinders).

J

johnwebbcole avatar Sep 10 '20 20:09 johnwebbcole

@SimonClark here's an example: https://gitlab.com/johnwebbcole/window-motor

I use both my own and the ones on the primitives (mostly on cylinders).

@johnwebbcole You are a rare bird. This is the first design that I have seen using connectors. I’ll research a little deeper now.

Having said that, I foresee some major work to make your designs work with V2. Have you started converting your utilities?

There’s an object wrapper for V2 already, and you are welcome to take that as a starting place.

z3dev avatar Sep 10 '20 21:09 z3dev

I build and test my utils against v2 and use a compatibility wrapper to get them to work with v1 scripts already :-)

johnwebbcole avatar Sep 10 '20 21:09 johnwebbcole

I use connectors for unfolding (I already have another method) and to be able to center something inside a 3d polygon (I have no other method for the moment), essentially to intrude faces or put text on them. for(i=0; i < nb; i++){ p = CSG.fromPolygons([B[i]]); t = p.getTransformationAndInverseTransformationToFlatLying(); //c = centre(p.polygons); c = {x:0, y:0}; txt = text(c.x, c.y, i.toString()); R.push(color("black", txt.transform(t[1]))); console.log(i+"/"+nb); } (getTransformationAndInverseTransformationToFlatLying() uses connectors)

or directly ` const v1 = p.polygons[0].vertices[0].pos; const v2 = p.polygons[0].vertices[1].pos; const v3 = p.polygons[0].vertices[2].pos;

    const center= v1.plus(v2.minus(v1).times(1/2)).plus(v3.minus(v1.plus(v2.minus(v1).times(1/2))).times(1/3));

	const tC = new CSG.Connector(v1, v2.minus(v1), p.polygons[0].plane.normal);
    const z0xC = new CSG.Connector([0, 0, 0], [0,v2.minus(v1).length(), 0], [0, 0, 1]);

    const tf = z0xC.getTransformationTo(tC, false, 0);
	const tb = tC.getTransformationTo(z0xC, false, 0);

    txt0 = text(0,0, i.toString());
    const xy = center.transform(tb);
    b = txt0.getBounds();
    dxy = xy.minus(b[1].minus(b[0]).times(1/2));

`

gilboonet avatar Sep 20 '20 09:09 gilboonet

FYI. The connectors has been temporarily disabled in V2.

Let's start some discussions about use cases, and then work on some changes to bring connectors (or something else) back into V2.

z3dev avatar Oct 12 '20 00:10 z3dev

I use both my own and the ones on the primitives (mostly on cylinders).

@johnwebbcole for these connectors, i have a few questions.

  • does your design expect a certain order to the connectors available? how does the design know which connector to use?
  • does your design expect connectors to 'transform' whenever the shape transforms?
  • connectors were only created for 3D primitives. would connectors on 2D primitives be useful?

z3dev avatar Oct 12 '20 00:10 z3dev

Connectors are named so you need to know the names for the object you are connecting to/from.

Yes, they should transform with the rest of the shape (like any point on the properties parameter).

And yes, 2d connectors would be very helpful.

johnwebbcole avatar Oct 17 '20 17:10 johnwebbcole

Just had a stupid thought...

Currently, connectors are:

  1. created from point and axis
  2. added to the 'properties' of a geometry by 'name'
  3. the 'properties' are transformed when a geometry is transformed
  4. designs know connectors by 'name', e.g. geometry.properties.center
  5. designs connect geometries together using known connectors
  6. a new geometry is created that aligns to the connectors

So, what if this is inverted, like this:

  1. created from point and axis
  2. geometries can be added to the connector
  3. geometries are transformed when the connector is transformed
  4. designs manage connectors
  5. connectors can be connected together
  6. new geometries are created that align to the connectors

z3dev avatar Jun 04 '21 01:06 z3dev

The addConnector helper that I use helps with naming and construction. https://gitlab.com/johnwebbcole/window-motor/-/blob/master/dist/window-motor.jscad#L733

Here's an example in use https://gitlab.com/johnwebbcole/window-motor/-/blob/master/dist/window-motor.jscad#L733

johnwebbcole avatar Jun 04 '21 19:06 johnwebbcole

After talking to myself in the comments here, I have deleted them, as I have come up with a proposal that is more in line with how jscad scripts work now. I am moving it all here #858

hrgdavor avatar Jun 06 '21 08:06 hrgdavor