public NamedPointWorld transformWith(OrderedTransformations o) { double[] result=new double[3]; o.apply(x,y,z,result); return new NamedPointWorld(name,result[0],result[1],result[2]); }
public String toIGS() { return "landmark {\n\tname \""+escape(name)+"\"\n\tlocation "+ x+" "+y+" "+z+"\n}"; } }
public int getIndexOfPoint( String name ) { int i = 0; for( NamedPointWorld p : pointsWorld ) { if( p.getName().equals( name ) ) return i; ++i; } return -1; }
public String toString( ) { StringBuffer sb = new StringBuffer(); for( NamedPointWorld npw : pointsWorld ) { sb.append( npw.toString() ); sb.append( "\n" ); } return sb.toString(); }
public ImagePlus register( NamedPointSet points0, NamedPointSet points1 ) { ArrayList< String > sharedNames = points0.namesSharedWith( points1, true ); Point3d[] fromPoints = new Point3d[sharedNames.size()]; Point3d[] toPoints = new Point3d[sharedNames.size()]; int pointIndex = 0; for( String name : sharedNames ) { NamedPointWorld npw0 = points0.getPoint(name); NamedPointWorld npw1 = points1.getPoint(name); toPoints[pointIndex] = npw0.toPoint3d(); fromPoints[pointIndex] = npw1.toPoint3d(); ++ pointIndex; } FastMatrix fm = FastMatrix.bestRigid( fromPoints, toPoints, allowScaling ); TransformedImage ti = new TransformedImage( sourceImages[0], sourceImages[1] ); ti.setTransformation( fm ); ImagePlus transformed = ti.getTransformed(); transformed.setTitle( "Transformed" ); return transformed; } }
synchronized public boolean renamePointTo( int i, String newName ) { NamedPointWorld existing = get( newName ); if( existing == null ) { pointsWorld.get(i).setName( newName ); return true; } else { return false; } }
public NamedPointSet transformPointsWith( OrderedTransformations o ) { NamedPointSet result = new NamedPointSet(); Iterator i0; for( i0 = pointsWorld.listIterator(); i0.hasNext(); ) { NamedPointWorld p = (NamedPointWorld)i0.next(); NamedPointWorld transformed = p.transformWith(o); result.add( transformed ); } return result; }
public boolean saveIGSPointsFile( String savePath ) { try { FileOutputStream fos = new FileOutputStream(savePath); StringBuffer sb=new StringBuffer("! TYPEDSTREAM 1.1\n"); Iterator<NamedPointWorld> i; for(i=listIterator();i.hasNext();) { NamedPointWorld p = i.next(); if(p.set) sb.append(p.toIGS()+"\n"); } fos.write(sb.toString().getBytes("UTF-8")); fos.close(); return true; } catch( IOException e ) { return false; } }
public String xmlDataAsString( ) { StringBuffer result = new StringBuffer(); result.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); result.append("<!DOCTYPE namedpointset [\n"); result.append(" <!ELEMENT namedpointset (pointworld*)>\n"); result.append(" <!ELEMENT pointworld EMPTY>\n"); result.append(" <!ATTLIST namedpointset version CDATA #REQUIRED>\n"); result.append(" <!ATTLIST pointworld set (true|false) #REQUIRED>\n"); result.append(" <!ATTLIST pointworld name CDATA #REQUIRED>\n"); result.append(" <!ATTLIST pointworld x CDATA #IMPLIED>\n"); result.append(" <!ATTLIST pointworld y CDATA #IMPLIED>\n"); result.append(" <!ATTLIST pointworld z CDATA #IMPLIED>\n"); result.append("]>\n\n"); result.append("<namedpointset version=\"1.0\">\n"); Iterator<NamedPointWorld> i = pointsWorld.iterator(); while( i.hasNext() ) { NamedPointWorld p = i.next(); result.append(" "); result.append(p.toXMLElement()); result.append("\n"); } result.append("</namedpointset>\n"); return result.toString(); }
point.set( xWorld, yWorld, zWorld );
public NamedPointWorld transformWith( FastMatrix m ) { m.apply(x,y,z); return new NamedPointWorld( name, m.x, m.y, m.z ); }
public Set< String > getNamesAsSet( ) { HashSet< String > namesSet = new HashSet< String >(); for( NamedPointWorld npw : pointsWorld ) { namesSet.add( npw.getName() ); } return namesSet; }
synchronized public NamedPointWorld addNewPoint( ) { int i = pointsWorld.size(); boolean nameTaken = true; String newName = null; while( nameTaken ) { newName = "Named Point (" + i + ")"; nameTaken = get( newName ) != null; ++ i; } NamedPointWorld toAdd = new NamedPointWorld( newName ); pointsWorld.add( toAdd ); return toAdd; }
public NamedPointWorld get(String name) { Iterator<NamedPointWorld> i0; for(i0=pointsWorld.listIterator();i0.hasNext();) { NamedPointWorld p=i0.next(); if( p.getName().equals(name) ) return p; } return null; }
y = Double.parseDouble( yString ); z = Double.parseDouble( zString ); nps.add( new NamedPointWorld( name, x, y, z ) ); } catch( NumberFormatException e ) { throw new SAXException( "One of 'x', 'y' and 'z' couldn't be parsed as a number" ); nps.add( new NamedPointWorld( name ) );
public void add(NamedPointWorld namedPointWorld) { synchronized (this) { String name = namedPointWorld.getName(); NamedPointWorld existing = get( name ); if( existing != null ) throw new RuntimeException( "Trying to add a point of name '" + name + "', but this NamedPointSet already has one." ); pointsWorld.add( namedPointWorld ); } }
double y = Double.parseDouble( yString ); double z = Double.parseDouble( zString ); nps.add( new NamedPointWorld( name, x, y, z ) ); } else { nps.add( new NamedPointWorld( name ) ); nps.add( new NamedPointWorld( m_data.group(1), Double.parseDouble(m_data.group(2)) * xSpacing, Double.parseDouble(m_data.group(3)) * ySpacing, Double.parseDouble(m_data.group(4)) * zSpacing) ); } else if (m_name_no_data.matches()) { nps.add( new NamedPointWorld( m_name_no_data.group(1) ) ); } else if (m_comment.matches()) { continue;