从RCC(8)规范或类似维恩图生成软件类似、软件、RCC、维恩图

2023-09-11 22:48:38 作者:太阳落山了

请注意:虽然赏金不再可用,我还是渴望与任何人回答这个问题作出贡献;我还在看着它,我在等待,看看是否有更好的答案。感谢,并请往下看......

Please note: While the bounty is no longer available, I'm still keen for anyone with an answer to this question to contribute; I'm still watching it, and I'm waiting to see if there is a better answer. Thanks, and please read on...

我要寻找一种方式来转换任意一组 RCC 般的空间关系(或类似)描述的约束网络为德维恩 - 图般的画面。例如,约束网络pssed在RCC8前$ P $

I am looking for a way to convert an arbitrary set of RCC-like spatial relations (or similar) describing a constraint network into Venn-diagram-like images. For example, the constraint network as expressed in RCC8:

W {EC}是, X {TPP}是,以Z {NTPP }是以Z {PO} X

..可以重新用圆形或正方形区域psented通过以下图示$ P $

..could be represented by the following diagram with circular or square regions:

..alternatively:&NBSP ;

..alternatively:

是任何人都知道的软件,至少可以通过编程产生这样的图表(通过API)从规范RCC-样的约束?

Is anyone aware of software that can at least generate such diagrams programmatically (via an API) from a specification of RCC-like constraints?

据我所知,这样的约束网络能够得以确认,precluding匹配任何单个这样的图(很多解决方案可能存在的)。理想情况下,我想通过能够产生可能的替代办法来处理这​​个问题,但可以诉诸无(和引发错误)现在。

I am aware that such a constraint network could be underspecified, precluding a match to any single such diagram (many solutions may exist). Ideally, I would like to deal with this by being able to generate possible alternatives, but can resort to none (and raising an error) for now.

只是要清楚,在这个问题上,我专门询问了软件,它可以计算的的图布局的基于RCC样的约束在 声明方式的。我不关心与工具把一个DSL的碾压到其他一些语法,我也没有兴趣在特定的图像序列化格式或方法。我希望能找到一个算法来做到这一点的处理任意数量限制为最多六个独特的套。

Just to be clear, in this question I am specifically asking for software which can calculate a diagram layout based on RCC-like constraints in a declarative manner. I am not concerned with tools to turn a DSL for RCC into some other syntax, nor am I interested in particular image serialization formats or methods. I am hoping to find an algorithm to do this for dealing with an arbitrary number of constraints for up to six unique sets.

注:的 的Graphviz (如@vickirk下面提到)是图排版软件,这是类似于我后的一个例子。不幸的是,它似乎的Graphviz本身不能这个问题帮助的(但我会很高兴被证明是错误的!)。看来这是一个非常困难的问题。

Notes: Graphviz (as @vickirk mentioned below) is an example of a diagram layout software package, which is akin to what I'm after. Unfortunately, it seems that Graphviz itself cannot help with this problem (but I'd be very happy to be proven wrong!). It seems this is a very hard problem.

推荐答案

谁需要一个后台?这里有一个工作原型使用HTML / CSS / JS:

Who need's a backend? Here's a working prototype using HTML/CSS/JS:

http://jsfiddle.net/RuvE6/6/

刚进入该领域的RCC8 code语法,然后按下按钮!

Just enter the RCC8 code syntax in the field and hit the button!

当前的一些限制:

在不处理含糊 有没有错误处理,如果语法是关闭 也许在某些情况下,有效突破(我没有测试过很多) 在没有实施任何反例(没有?)

编辑:工作原理

基本上,有两种的家庭的与这些图中所示的关系:

Basically, there are two families of relationships shown with these diagrams:

A 包含 B A 紧邻 B 。

有那么子类型或变化,如:

There are then sub-types or variations, like:

A 包含 B 和 B 相切的A A 紧邻 B 和 A 与重叠的到B A contains B and B is tangential to A A is adjacent to B and A overlaps with to B

这两个基本概念的样的的烤成HTML呈现世界:

Both of the basic concepts are kind of baked into the HTML rendering world:

在遏制 - >嵌套的HTML元素:&LT; D​​IV CLASS =区域&GT;&LT; D​​IV CLASS =区域&GT;&LT; / DIV&GT;&LT; / DIV&GT; 在邻居 - >兄弟HTML元素:&LT; D​​IV CLASS =区域&GT;&LT; / DIV&GT;&LT; D​​IV CLASS =区域&GT;&LT; / DIV&GT; containment --> nested HTML elements: <div class="region"><div class="region"></div></div> adjacency --> sibling HTML elements: <div class="region"></div><div class="region"></div>

我处理与特殊类的变异(而粗制滥造)左右摆动的利润来实现所需的布局:

I handle the variations with special classes that (rather crudely) wiggle margins around to accomplish the desired layout:

遏制,与切线: &LT; D​​IV CLASS =区域&GT;&LT; D​​IV CLASS =区域接触父&GT;&LT; / DIV&GT;&LT ; / DIV&GT; (孩子有负面的顶边摸父) 相邻,有重叠: &LT; D​​IV CLASS =法师&GT;&LT; D​​IV CLASS =区域&GT;&LT; / DIV&GT;&LT; D​​IV类=区域接触父&GT;&LT; / DIV&GT;&LT; / DIV&GT; (包装被添加到触发CSS的孩子 - 第二个元素具有负左边距重叠第一。 ) containment, with tangent: <div class="region"><div class="region touches-parent"></div></div> (child has negative top margin to touch parent) adjacency, with overlap: <div class="ven"><div class="region"></div><div class="region touches-parent"></div></div> (a wrapper is added to trigger CSS on the children - the second element has negative left margin to overlap the first.)

有一些静态标记在的jsfiddle注释掉展示我开始与结构。

There is some static markup commented out in the jsfiddle showing the structure I started with.

要完成的功能循环,有一点code解析的RCC8语句转换成A {XX}乙的部分,并尝试给予必要的标记的每个部分。它检查,因为它去不重复的区域。我也经历后,并设置所有的高度兄弟一样,这保证了他们将重合和/或紧靠正常。

To complete the functional loop, there is a bit of code that parses the RCC8 statement into A {XX} B parts, and attempts to render the necessary markup for each part. It checks as it goes to not duplicate regions. I also go through afterwards and set the heights of all sibling the same, which ensures they will overlap and/or abut properly.

这code是真的只是一个开始,它有它的自负。这基本上是一个的线性的图,这意味着它没有,比如,处理那里有复杂的邻接的情况下,像这样的:

This code is really just a start, and it has it's conceits. It's basically a linear diagram, which means it doesn't, for instance, handle cases where there are complicated adjacencies, like this:

A {} EC B,C {EC} B,D {EC}乙

这些可能会被处理JS聪明远超分析和更复杂的CSS,但可能很快冒险进入更大的力导向布局的境界(一聪明的的