Archive for May, 2010

Parametric Objects in B-processor

Monday, May 24th, 2010

The first attempts to create curved objects in B-processor lead to the following conclusions:

  • Any curved object will need a series of input parameters usually called control vertices, control polygon or control mesh
  • This input is used to compute the curve from an algorithm
  • There is a desire to change the parameters after the curve was computed. This means the object should provide the flexibility to redraw itself once an input parameter changed.

It was discussed that this problem could be described more generally as a parametric object providing the following functionality and parameters:

  • The object is a group of elements: geometrical input, additional parameters, a script (i.e. the algorithm computing a curve) and the resulting geometry
  • The script would be run each time of the input parameters (geometrical or additional) is changed.
  • Rerunning the script recomputes the resulting geometry. In the case of B-processor this means to delete the previous result and redraw the geometry. It was discussed to only redraw local changes instead of the complete geometry but this will rather be a later optimization.
  • All element parts are organized within the object browser as children of the main geometry object, allowing the user easy access.
  • The geometry parameters of the object will be realized using the existing B-net functionality.
  • The attached scripts should be Java scripts to allow full functionality and access to all methods and properties. In a second step a scripting languages “B-script” could be implemented, allowing the creation of simple scripts.
  • The object should be set up very flexibly, i.e. an object should be allowed to create new objects or being the input for other objects (lofts, sweeps…)

100519 parametric objects

Share

Commit changes to sourceforge project code

Monday, May 24th, 2010
  1. In Eclipse, right-click on the main project folder and chose >team< … >update< in the context menu. This will upload changes other users made into your local code copy.
    step 01
  2. Start Cygwin shell, and direct to your workspace folder
    1. c:
    2. step 02

    3. cd Users/[…]/workspace/build
  3. run the batch build command “./build.sh clean dist”
  4. step 03
    step 04

  5. In Eclipse, right/click on the main project folder and chose >refresh< in the context menu.
  6. step 05

  7. Chose >Project< in the main menu bar and >clean< the project
  8. step-06

  9. Right-click on the main project folder (or changed folder) and chose >team< … >commit< to commit your changes to the server copy of the code.
  10. step-07

Share

Uniform Nonrational B-Splines in B-Processor

Tuesday, May 4th, 2010

Implementation in B-Processor / Java:
public static class UniformNonrationalBSpline extends Command {
  private Space net;
  /**
   * Constructs a frame command
   * @param net Space
   */
  public UniformNonrationalBSpline(Space net) {
    this.net = net;   
    parameters.put(“subdivisions”, 5.0);
    parameters.put(“UNRBSname”, “Unifrom Nonrational BSpline”);
  }
  /**
   *
{@inheritDoc}
   */
  public String title() {
    return “Unifrom Nonrational BSpline”;
  }
  //bring edges in order
  public static List<Edge> order(List<Edge> edges) {
      LinkedList<Edge> ordered = new LinkedList();
      if (edges.size() > 0) {
       Edge first = edges.get(0);
          ordered.add(first);
          edges.remove(0);
          while (edges.size()>0) {
           for (int i = 0; i < edges.size(); i++) {
            search:
            if (edges.get(i).contains(ordered.get(ordered.size()-1).to)) {
             //check direction
             if (!edges.get(i).from.equals(ordered.get(ordered.size()-1).to)) {
              Vertex temp = edges.get(i).to;
              edges.get(i).to = edges.get(i).from;
              edges.get(i).from = temp;
             }
             //add at end of Linked list
             ordered.add(edges.get(i));
             edges.remove(i);
             break search;
            } else if (edges.get(i).contains(ordered.get(0).from)) {
           //check direction
             if (!edges.get(i).to.equals(ordered.get(ordered.size()-1).from)) {
              Vertex temp = edges.get(i).to;
              edges.get(i).to = edges.get(i).from;
              edges.get(i).from = temp;
             }
             // add at beginning of Linked List
             ordered.add(0, edges.get(i));
             edges.remove(i);
             break search;
            }
           }
          }
      }
      return ordered;
    }
 
  public Vertex unrbsCalc(List<Vertex> gConst, double t) {
   Vertex blend = new Vertex(0,0,0);
   if (gConst.size()==4) {
    double[] tempCalc = new double[4];
    tempCalc[0] = ((1-t)*(1-t)*(1-t))/6;
    tempCalc[1] = (3*t*t*t-6*t*t+4)/6;
    tempCalc[2] = (-3*t*t*t+3*t*t+3*t+1)/6;
    tempCalc[3] = (t*t*t)/6;
    for (int i=0; i<=3; i++) {
     blend.x = blend.x + tempCalc[i]*gConst.get(i).x;
     blend.y = blend.y + tempCalc[i]*gConst.get(i).y;
     blend.z = blend.z + tempCalc[i]*gConst.get(i).z;
    }
    System.out.println(blend.x);
   }
 return blend;
  }
  /** {@inheritDoc} */
  @Override
  public void evaluate() {
    String UNRBSname = (String) parameters.get(“UNRBSname”);
    double subdiv = parameters.getDouble(“subdivisions”);
   
    List<Vertex> vertices = new ArrayList(net.getVertices());
    List<Edge> edges = new ArrayList(net.getEdges());
    List<Vertex> orderPoints = new ArrayList();
    List<Vertex> curvePoints = new LinkedList();
    if (vertices.size()>=3) {
     LinkedList<Edge> nEdges = new LinkedList();
     nEdges = (LinkedList) order(edges);
     // write into List
     for (int i=0; i<nEdges.size(); i++) {
      orderPoints.add(nEdges.get(i).from);
     }
     orderPoints.add(nEdges.get(nEdges.size()-1).to);
     // make Spline go through endpoints
     for (int i=0; i<=2; i++) {
      orderPoints.add(orderPoints.get(orderPoints.size()-1));
      orderPoints.add(0,orderPoints.get(0));
     }
     
     // create space object to draw new elements
  Space result = Space.createUnion(UNRBSname);
 // calculate Uniform Nonrational Spline Curve
  for (int i=3; i<= orderPoints.size()-2; i++) {
   for (int t=0; t<subdiv; t++) {
    curvePoints.add(unrbsCalc(orderPoints.subList(i-3, i+1),t/subdiv));
   }
  }
  // draw Spline Curve
  for (int i=1;i<curvePoints.size()-1;i++) {
   result.add(new Edge(curvePoints.get(i-1),curvePoints.get(i)));
  }
  
  
  net.getOwner().add(result);
    }
  }
}
Share