Skip to content
Snippets Groups Projects
Commit efe141b7 authored by Matej Lukes's avatar Matej Lukes
Browse files

Mesh core implemented

parent 5dfbbbb9
No related branches found
No related tags found
No related merge requests found
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Maven: org.netbeans.api:org-netbeans-api-annotations-common:RELEASE82" level="project" />
<orderEntry type="library" name="Maven: javax.vecmath:vecmath:1.5.2" level="project" />
</component>
</module>
\ No newline at end of file
...@@ -33,6 +33,11 @@ ...@@ -33,6 +33,11 @@
<artifactId>org-netbeans-api-annotations-common</artifactId> <artifactId>org-netbeans-api-annotations-common</artifactId>
<version>${netbeans.version}</version> <version>${netbeans.version}</version>
</dependency> </dependency>
<dependency>
<groupId>javax.vecmath</groupId>
<artifactId>vecmath</artifactId>
<version>1.5.2</version>
</dependency>
</dependencies> </dependencies>
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
......
package cz.fidentis.analyst.mesh.core;
import java.util.List;
public abstract class MeshComponent {
private List<MeshComponent> parents;
public List<MeshComponent> getParents(){
return parents;
}
public abstract List<MeshComponent> getChildren();
public boolean addParent(MeshComponent newParent){
if (parents.contains(newParent))
return false;
parents.add(newParent);
return true;
}
public abstract boolean addChild(MeshComponent newChild);
}
package cz.fidentis.analyst.mesh.core;
import java.util.List;
public class MeshComposite extends MeshComponent {
private List<MeshComponent> children;
@Override
public List<MeshComponent> getChildren() {
return children;
}
@Override
public boolean addChild(MeshComponent newChild) {
if (children.contains(newChild))
return false;
children.add(newChild);
newChild.addParent(this);
return true;
}
}
package cz.fidentis.analyst.mesh.core;
public class MeshEdge extends MeshComposite {
@Override
public boolean addChild(MeshComponent newChild) {
if (!(newChild instanceof MeshPoint))
return false;
return super.addChild(newChild);
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof MeshEdge))
return false;
for (MeshComponent component:
this.getChildren()) {
if(!((MeshEdge) obj).getChildren().contains(component))
return false;
}
return true;
}
}
package cz.fidentis.analyst.mesh.core;
public class MeshFace extends MeshComposite {
@Override
public boolean addChild(MeshComponent newChild) {
if (!(newChild instanceof MeshEdge))
return false;
return super.addChild(newChild);
}
}
package cz.fidentis.analyst.mesh.core;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class MeshFacet extends MeshComposite {
Map<MeshPoint, MeshPoint> pointPool = new HashMap<>();
Map<MeshEdge, MeshEdge> edgePool = new HashMap<>();
public MeshPoint getPoint(MeshPoint point) {
MeshPoint result = pointPool.get(point);
if (result == null) {
pointPool.put(point, point);
}
return result;
}
public MeshEdge getEdge(MeshEdge edge) {
MeshEdge result = edgePool.get(edge);
if (result == null) {
edgePool.put(edge, edge);
}
return result;
}
@Override
public boolean addChild(MeshComponent newChild) {
if (!(newChild instanceof MeshFace))
return false;
return super.addChild(newChild);
}
}
package cz.fidentis.analyst.mesh.core;
import java.util.ArrayList;
import java.util.List;
public class MeshLeaf extends MeshComponent {
@Override
public List<MeshComponent> getChildren() {
return null;
}
@Override
public boolean addChild(MeshComponent newChild) {
return false;
}
}
package cz.fidentis.analyst.mesh.core;
import java.util.List;
public class MeshModel extends MeshComposite {
@Override
public List<MeshComponent> getParents() {
return null;
}
@Override
public boolean addParent(MeshComponent newParent) {
return false;
}
@Override
public boolean addChild(MeshComponent newChild) {
if (!(newChild instanceof MeshFacet))
return false;
return super.addChild(newChild);
}
}
package cz.fidentis.analyst.mesh.core;
import javax.vecmath.Vector3d;
import java.util.List;
public class MeshPoint extends MeshLeaf {
private Vector3d position, normal, texCoord;
public Vector3d getNormal() {
return normal;
}
public Vector3d getPosition() {
return position;
}
public Vector3d getTexCoord() {
return texCoord;
}
public void setNormal(Vector3d normal) {
this.normal = normal;
}
public void setPosition(Vector3d position) {
this.position = position;
position.normalize();
}
public void setTexCoord(Vector3d texCoord) {
this.texCoord = texCoord;
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof MeshPoint))
return false;
MeshPoint meshPointObj = (MeshPoint) obj;
return this.position == meshPointObj.position
&& this.normal == meshPointObj.normal
&& this.texCoord == meshPointObj.texCoord;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment