Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Analyst WebApp
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Package registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
fidentis
Analyst WebApp
Commits
e9c4956e
There was an error fetching the commit references. Please try again later.
Commit
e9c4956e
authored
5 years ago
by
MakroCZ
Browse files
Options
Downloads
Patches
Plain Diff
Synchronizing names with model
parent
94e95cf8
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
MeshModel/src/main/java/cz/fidentis/analyst/mesh/io/MeshObjLoader.java
+20
-23
20 additions, 23 deletions
.../main/java/cz/fidentis/analyst/mesh/io/MeshObjLoader.java
with
20 additions
and
23 deletions
MeshModel/src/main/java/cz/fidentis/analyst/mesh/io/MeshObjLoader.java
+
20
−
23
View file @
e9c4956e
...
...
@@ -10,6 +10,7 @@ import com.mokiat.data.front.parser.OBJObject;
import
com.mokiat.data.front.parser.OBJParser
;
import
com.mokiat.data.front.parser.OBJTexCoord
;
import
com.mokiat.data.front.parser.OBJVertex
;
import
cz.fidentis.analyst.mesh.core.CornerTableRow
;
import
cz.fidentis.analyst.mesh.core.MeshFacet
;
import
cz.fidentis.analyst.mesh.core.MeshModel
;
import
cz.fidentis.analyst.mesh.core.MeshPoint
;
...
...
@@ -20,11 +21,9 @@ import java.io.IOException;
import
java.io.InputStream
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Objects
;
import
java.util.Set
;
import
javax.vecmath.Vector3d
;
...
...
@@ -77,7 +76,7 @@ public class MeshObjLoader {
// Our facet = loader mesh, create and fill all facets
for
(
OBJMesh
mesh
:
object
.
getMeshes
())
{
MeshFacet
meshFacet
=
parseMeshToFacet
(
model
,
mesh
);
//
meshModel.add
Child
(meshFacet);
meshModel
.
add
Facet
(
meshFacet
);
}
return
meshModel
;
}
...
...
@@ -93,10 +92,9 @@ public class MeshObjLoader {
MeshFacet
meshFacet
=
new
MeshFacet
();
Map
<
MeshPoint
,
Integer
>
vertices
=
new
HashMap
();
Map
<
Edge
,
Integer
>
edges
=
new
HashMap
();
Set
<
Edge
>
invertedEdges
=
new
HashSet
();
for
(
OBJFace
face
:
mesh
.
getFaces
())
{
processFace
(
model
,
face
,
meshFacet
,
vertices
,
edges
,
invertedEdges
);
processFace
(
model
,
face
,
meshFacet
,
vertices
,
edges
);
}
return
meshFacet
;
...
...
@@ -110,11 +108,11 @@ public class MeshObjLoader {
* @param vertices Map containing information about processed vertices
* and their index in CornerTable
* @param edges Map containing edges and index of their opposite vertex
* @param invertedEdges Set containing already fully processed edges
* @throws IOException Data are corrupted
*/
private
static
void
processFace
(
OBJModel
model
,
OBJFace
face
,
MeshFacet
meshFacet
,
Map
<
MeshPoint
,
Integer
>
vertices
,
Map
<
Edge
,
Integer
>
edges
,
Set
<
Edge
>
invertedEdges
)
throws
IOException
{
private
static
void
processFace
(
OBJModel
model
,
OBJFace
face
,
MeshFacet
meshFacet
,
Map
<
MeshPoint
,
Integer
>
vertices
,
Map
<
Edge
,
Integer
>
edges
)
throws
IOException
{
List
<
MeshPoint
>
trianglePoints
=
parseFaceToTriangle
(
model
,
face
);
List
<
Integer
>
vertexIndicies
=
new
ArrayList
();
...
...
@@ -122,33 +120,31 @@ public class MeshObjLoader {
for
(
MeshPoint
vertex
:
trianglePoints
)
{
Integer
vertIndex
=
vertices
.
get
(
vertex
);
if
(
vertIndex
==
null
)
{
int
newIndex
=
meshFacet
.
getNumberOfVert
ic
es
();
int
newIndex
=
meshFacet
.
getNumberOfVert
ex
es
();
vertices
.
put
(
vertex
,
newIndex
);
meshFacet
.
addVertex
(
vertex
);
vertIndex
=
newIndex
;
}
vertexIndicies
.
add
(
vertIndex
);
CornerTableRow
cornerTableRow
=
new
CornerTableRow
(
vertIndex
,
-
1
);
meshFacet
.
getCornerTable
().
addRow
(
cornerTableRow
);
}
List
<
Edge
>
triangleEdges
=
new
ArrayList
();
triangleEdges
.
add
(
new
Edge
(
trianglePoints
.
get
(
0
).
getPosition
(),
trianglePoints
.
get
(
1
).
getPosition
(),
vertexIndicies
.
get
(
2
)));
triangleEdges
.
add
(
new
Edge
(
trianglePoints
.
get
(
1
).
getPosition
(),
trianglePoints
.
get
(
2
).
getPosition
(),
vertexIndicies
.
get
(
0
)));
triangleEdges
.
add
(
new
Edge
(
trianglePoints
.
get
(
2
).
getPosition
(),
trianglePoints
.
get
(
0
).
getPosition
(),
vertexIndicies
.
get
(
1
)));
triangleEdges
.
add
(
new
Edge
(
trianglePoints
.
get
(
0
).
getPosition
(),
trianglePoints
.
get
(
1
).
getPosition
(),
vertexIndicies
.
get
(
2
)));
triangleEdges
.
add
(
new
Edge
(
trianglePoints
.
get
(
1
).
getPosition
(),
trianglePoints
.
get
(
2
).
getPosition
(),
vertexIndicies
.
get
(
0
)));
triangleEdges
.
add
(
new
Edge
(
trianglePoints
.
get
(
2
).
getPosition
(),
trianglePoints
.
get
(
0
).
getPosition
(),
vertexIndicies
.
get
(
1
)));
for
(
Edge
e
:
triangleEdges
)
{
// Edge containing same vertices in same order was already processed - non-manifold situation
if
(
invertedEdges
.
contains
(
e
))
{
throw
new
IOException
(
"Mesh contain non-manifold situation"
);
}
// We are processing edge which we already found in opposite direction
// We are processing edge which we already found
// We can set corner.opposite on both corners
if
(
edges
.
containsKey
(
e
))
{
int
oppositeCornerIndex
=
edges
.
get
(
e
);
MeshFacet
.
getCornerTable
().
getRow
(
oppositeCornerIndex
).
setOppositeCornerIndex
(
e
.
getCornerIndex
());
MeshFacet
.
getCornerTable
().
getRow
(
e
.
getCornerIndex
()).
setOppositeCornerIndex
(
oppositeCornerIndex
);
invertedEdges
.
add
(
e
.
getInvertedEdge
());
invertedEdges
.
add
(
e
);
meshFacet
.
getCornerTable
().
getRow
(
oppositeCornerIndex
).
setOppositeCornerIndex
(
e
.
getCornerIndex
());
meshFacet
.
getCornerTable
().
getRow
(
e
.
getCornerIndex
()).
setOppositeCornerIndex
(
oppositeCornerIndex
);
edges
.
remove
(
e
);
}
else
{
edges
.
put
(
e
,
e
.
getCornerIndex
());
...
...
@@ -191,6 +187,7 @@ public class MeshObjLoader {
/**
* Helper class for finding opposite corners
* @author Marek Bařinka
*/
private
static
class
Edge
{
...
...
@@ -230,8 +227,7 @@ public class MeshObjLoader {
}
/**
* Two edges are considered same if they have same vertices in opposite
* order.
* Two edges are considered same if they have same vertices.
* @param obj Other edge to test
* @return true if edges are same with opposite direction
*/
...
...
@@ -247,7 +243,8 @@ public class MeshObjLoader {
return
false
;
}
final
Edge
other
=
(
Edge
)
obj
;
return
other
.
v1
.
equals
(
this
.
v2
)
&&
other
.
v2
.
equals
(
this
.
v1
);
return
(
other
.
v1
.
equals
(
this
.
v1
)
&&
other
.
v2
.
equals
(
this
.
v2
))
||
(
other
.
v1
.
equals
(
this
.
v2
)
&&
other
.
v2
.
equals
(
this
.
v1
));
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment